| Author |
Comment/Response |
Jelle
|
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 *)
Do[
(* This is the time reversal step *)
outputArray[[arrayLength - ii]] =
outputArray[[arrayLength - ii + 1]] +
arraySquared[[arrayLength - ii]];
, {ii, 1, arrayLength - 1}]
Return[outputArray]
];
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: , |
|