help-octave
[Top][All Lists]
Advanced

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

Re: row vectors changed to column vectors?


From: Mike Miller
Subject: Re: row vectors changed to column vectors?
Date: Tue, 10 Feb 2004 11:59:43 -0600 (CST)

On Tue, 10 Feb 2004, Christian T. Steigies wrote:

> > >BTW, if you are creating vectors by doing things like
> > >
> > >  clear a;
> > >  for i = 1:N
> > >    a(i) = something();
> > >  end
> > >
> > >then you should probably rethink your method, because this type of
> > >loop the vector A to be resized N times, which will be slow.
>
> Yes, it is slow, what do you suggest? Should I create a matrix with
> zero(N,1) first? Looks as if it is just a few ms difference.

If N is 1000000, is it still just a matter of a few ms?  For small N there
well be very little difference.  I think the zeros(N,1) method is good.


> But what takes much more time is creating a N:N matrix out of these
> vectors. I have to "glue" the matrix using a() as a column, where for
> each column a() has to be "rotated" by one position. I tried first with
> two for loops. Now I use a matrix multiplication and addition and the
> shift() function, which makes it 4 times faster, but it still takes
> about a minute for N=1023, whereas the first loop to create a() is only
> half a second. Any hints on how to make the matrix creation even faster?

If you can be more exlicit about what you're doing (e.g., with "gluing"
and "rotating"), we might help you better.

Mike



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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