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: Jordi Gutiérrez Hermoso
Subject: Re: Vectorize a function that depends on previous function value
Date: Mon, 19 May 2014 22:02:06 -0400

On Mon, 2014-05-19 at 17:36 +0200, Francesco Potortì wrote:

> If it were a linear dependence, you could have used linear
> filtering. For non-linear functions there may be
> application-specific methods, but as a non-matematician I too think
> there is no general method...

Well, the general method is an idea from functional programming called
reduce in lisp or fold (left or right) in Haskell:

    
https://en.wikipedia.org/wiki/Fold_%28higher-order_function%29#Folds_in_various_languages

We have a few functions in Octave that do this kind of folding for
specific binary functions. The sum and prod functions come to mind as
the folds for the plus and times functions. In order to vectorise
Gerald's kind of code, we would need some sort of fold or reduce
function in Octave that accepts an arbitrary binary function to fold
an array with. This general folding function would not be that
difficult to implement in Octave itself. It could just be a thin oct
file wrapper to C++'s std::accumulate.

However, for Gerald's purpose, if he's already going to be writing oct
files, might as well write an oct file that implements his dynamical
system.

Sorry Gerald, there's no easy solution to your problem using only
m-filees. :-(

- Jordi G. H.






reply via email to

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