help-octave
[Top][All Lists]
Advanced

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

de-for-ing..


From: Gorazd Brumen
Subject: de-for-ing..
Date: Sun, 06 Feb 2005 22:42:36 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913

Hi again,

Last time I received great suggestions from the list.
Thanks again.

I have another problem.
I wonder if the following can be done nicer:
x_init and x are two vectors. I want to get another
vector - place - that is generated by

for i = 1:lx
    place(i) = sum( x_init <= x(i) );
end

I thought of doing it this way (with kronecker products -
I am deeply into this right now, so it was the first thing
that pops up)

x_ext = kron (x, ones (n, 1))
x_init_ext = kron (ones (lx, 1), x_init )
x_tog = (x_init_ext <= x_ext)
sum(reshape (x_tog,n,lx))'

The results are the same, but the for loop is much
faster and less memory consuming. the kron solution
is preety much stupid.

Is there a better way than the for loop?

Regards,

--
Gorazd Brumen
Mail: address@hidden
WWW: http://valjhun.fmf.uni-lj.si/~brumen
PGP: Key at http://pgp.mit.edu, ID BCC93240



-------------------------------------------------------------
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]