help-octave
[Top][All Lists]
Advanced

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

Re: Vectorize a function that depends on previous function value


From: Macy
Subject: Re: Vectorize a function that depends on previous function value
Date: Mon, 19 May 2014 06:40:17 -0700

Not capable to respond to your specific request [since I don't understand it, 
not your fault, mine, very dense], but here are a few 'in general' comments.

1. For me, since learned in Fortran, EVERYTHING starts as a for-loop. But 
sometimes need to gain speed so learned to become extravagant at creating HUGE 
matrices of variables.

Example, a vector becomes a matrix that is now as wide as the number of 
for-loops. Then operate on that matrix, amazingly faster.

Often create 'shifted' matrices, where the index rolls over pme ste[ for each 
member of the matrix, it's like a shifting/rolling vector along the matrix.

My point is, don't think in terms of a single vector of variables, rather a 
matrix, so you essentially do simulataneous operations.  

2. Have you looked through the functions that relate to what you're doing? 
[This is meant as a suggestion, not an upgrading. For I continually find 
functions, even done circa 1987, that have done what I'm trying to do.]  

*IF* each optimization step uses the results of the previous step, not sure how 
it is possible to avoid a for-loop. 

3. I never quite learned how to use the complete power of 'conditional' 
indexing. like x(x>0)=0; to 'clip' a matrix, nor the power of creating a matrix 
as in point 1. and the revectorizing it to a linear vector and operating on 
that. but there may be something in doing those kinds of things.

apologies for not knowing more to help.





--- address@hidden wrote:

From: gergo <address@hidden>
To: address@hidden
Subject: Vectorize a function that depends on previous function value
Date: Mon, 19 May 2014 04:08:35 -0700 (PDT)

Dear list members! 

I have have a discrete time dynamical system:

function [a,b] = dynamicalSystmem(data, params)
a(n) = a(n-1) + data(n) + b(n-1) + someNonLinearFunction(a(n-1))
b(n) = b(n-1) + someOtherNonlinearFctn(a(n-1)) 

To fit the model to my data, I'm minimizing a simple cost function, which
requires me to iterate the dynamical system function. Currently this is done
by a simple for-loop, which makes the optimization very slow, because this
is done in every optimization step.

However I couldn't find a way to vectorize this for loop. Has anybody of you
an idea how to solve this? 

Thank you very much in advance!

Gerald



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Vectorize-a-function-that-depends-on-previous-function-value-tp4664169.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave





reply via email to

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