[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: row vectors changed to column vectors?
From: |
Christian T. Steigies |
Subject: |
Re: row vectors changed to column vectors? |
Date: |
Tue, 10 Feb 2004 17:46:55 +0100 |
User-agent: |
Mutt/1.5.4i |
On Tue, Feb 10, 2004 at 07:57:26AM -0800, Jonathan Stickel wrote:
> As a former Matlab user, I remember being frustrated with row vectors
> begin the default. So I got in the habit of always assigning vector
> elements like this:
>
> a(1,1)=1;
> a(2,1)=2;
> a(3,1)=3;
After playing with size() and transposing the matrix I realized this is the
easier way to do this, too.
> John W. Eaton wrote:
> >
> >Yes, this change is permanent, for compatibility with Matlab. In the
> >past, you could use the built-in variable prefer_column_vectors to
> >choose what Octave would do for things like
Either way is fine with me, since I never used matlab.
> >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.
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?
Thanks,
Christian
-------------------------------------------------------------
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
-------------------------------------------------------------
- row vectors changed to column vectors?, Christian T. Steigies, 2004/02/10
- row vectors changed to column vectors?, John W. Eaton, 2004/02/10
- Re: row vectors changed to column vectors?, Jonathan Stickel, 2004/02/10
- Re: row vectors changed to column vectors?,
Christian T. Steigies <=
- Re: row vectors changed to column vectors?, Mike Miller, 2004/02/10
- Re: row vectors changed to column vectors?, Christian T. Steigies, 2004/02/11
- Re: row vectors changed to column vectors?, Christoph Dalitz, 2004/02/10
- Re: row vectors changed to column vectors?, Przemek Klosowski, 2004/02/10
- Re: row vectors changed to column vectors?, Christian T. Steigies, 2004/02/11
- Re: row vectors changed to column vectors?, Henry F. Mollet, 2004/02/11
- Re: row vectors changed to column vectors?, Paul Kienzle, 2004/02/10
- Re: row vectors changed to column vectors?, Andy Adler, 2004/02/11
- Re: row vectors changed to column vectors?, Paul Kienzle, 2004/02/11