Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Very slow evaluation of iterative algorithm' topicStudent Support Forum > General > "Very slow evaluation of iterative algorithm"

Next Comment >Help | Reply To Topic
Author Comment/Response
03/12/12 06:15am

Hello everyone,

I am having trouble with the evaluation speed of a simple algorithm to compute the integrated time reversed squared impulse response of a list. That may sound complicated, but the formula is simply (in Mathematica form):
E[t] = Integrate[p[tau]^2, {tau, t, Infinity}]

With E(t) is the desired result and p(t) is the input.

To solve this in discrete form, I tried to implement it in the following way:

timeReversedIntegratedResponse[array_] :=
Module[{arraySquared, outputArray, arrayLength, ii},
arrayLength = Length[array];
arraySquared = array*array;
outputArray = Table[Null, {arrayLength}];

(* First solve the limiting case, i.e. the last entry *)
outputArray[[arrayLength]] = arraySquared[[arrayLength]];

(* Then solve the rest iteratively *)
(* This is the time reversal step *)
outputArray[[arrayLength - ii]] =
outputArray[[arrayLength - ii + 1]] +
arraySquared[[arrayLength - ii]];
, {ii, 1, arrayLength - 1}]


The problem now is: this works, but only very slowly: typically at a rate of around 1000 iterations a second. Since an input array is typically of size half a million, this is unacceptable. In contrast a very similar MATLAB module can do this in less than a second. Am I doing something terribly wrong?

By the way: I ensured that the input array contains only Reals, so it can't be that Mathematica is doing complicated algebraic computations.

All help is appreciated, thanks in advance!

URL: ,

Subject (listing for 'Very slow evaluation of iterative algorithm')
Author Date Posted
Very slow evaluation of iterative algorithm Jelle 03/12/12 06:15am
Re: Very slow evaluation of iterative algorithm yehuda 03/13/12 2:35pm
Re: Re: Very slow evaluation of iterative algor... Jelle 03/14/12 05:29am
Next Comment >Help | Reply To Topic