[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple vector to matrix transformation

From: Jonathan King
Subject: Re: simple vector to matrix transformation
Date: Tue, 22 Jun 1999 09:42:15 -0500 (CDT)

On Tue, 22 Jun 1999, Daniel Heiserer wrote:

> address@hidden wrote:
> > 


> > Of course, the multiplication is inefficient.  I seem to remember
> > there was a more direct way to do this transformation, but I can't
> > find it in the docs.  Is there?
> Sure 
> b=a*ones(1,4);
> you will see the efficiency once you go to bigger
> problems:
> octave:7> a=rand(1000,1);tic;b=a*ones(1,1000);toc
> ans = 0.22280
> octave:8> a=rand(1000,1);tic;c=diag(a)*ones(1000,1000);toc
> ans = 142.55
> octave:9> 142.55/0.22280
> ans = 639.81
> A speedup of a factor of 639 is OK or?

On my machine, this is a factor of 6 or so faster still in Matlab, anyway:

>> tic; b=a*ones(1,1000); toc
elapsed_time =

>> tic; b=a(:,ones(1,1000)); toc
elapsed_time =

If memory serves, octave was similarly faster using the indexing-only

Alas, memory has to serve at the moment since I just found out
that my recent upgrade to RH 6.0 fried my octave installation...and the
rpm package I could find cores out, too. :-( Yeah, I can remake the thing,
easily enough, but has anybody else built an rpm of 2.0.14 for x86 Linux?  
If not, this might be my chance to do something useful for a change.


Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see
Instructions for unsubscribing:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]