help-octave
[Top][All Lists]
Advanced

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

Re: Need help with vectorizing the code


From: PetrSt
Subject: Re: Need help with vectorizing the code
Date: Tue, 16 Apr 2013 01:15:33 -0700 (PDT)

I would advice you to leave it as it is. i.e. 
for ii=1:100, x(ii) = sum(sum(lsode("octave2",Z(ii,:),t))); end
You can call lsode in for loop, colect outputs to single matrix and make the
double sumation just once. The best way to do it seems to me in colecting
outputs into a three dimenional matrix X[length(t), 100, 100] and sum it
along the first two dims. But it doesn't seem to be of much improvement.
Finally you can call lsode just once with Z rearranged to a vector and solve
all Z(ii,:) at once. In that case the core of vectorization lies exactly in
the "Do something" statement. However, I discourage you from the approach
due to sizes of Z and t, where Z would be of length 1e4 as well as t, so the
returned output X would be of size 1e4 x 1e4, which is quite a lot. If you
do not provide an analytical Jacobian I wouldn't expect any improvement in
performance, rather it will be worse.



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Need-help-with-vectorizing-the-code-tp4651809p4651916.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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