
October 22nd, 2004, 01:19 PM
|
|
Contributing User
|
|
Join Date: Mar 2001
Location: Dublin
Posts: 413
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 8
|
|
Unusual looking polynomial, but how and ever. Time it to see where the biggest drain is, I'd try the following to speed it up:
Code:
x[0]=a0;
if (0<i)
{i2[1]=1;//i2 will be cached array of i squared values
i3[1]=1;//i3 will be cached array of i cubed values
for(i=2;i<93;i++)
{i2[i]=i*i;
i3[i]=i*i2[i];
}
x[1]=a0+a1+a2+a3;
for(i=1;i<93;i++)
{x[i]=a0+a1*i+a2*i2[i]+a3*i3[i];}
}
Plenty of other options to speed it up further, the above should start by cutting out any repeated calculations etc. Don't know if you can speed up the array access etc or find a language that will do the matrix multiplication for you in an optimised way.
The next step I would take would be to look at calculating the difference between the consecutive items, x[t]-x[t-1], and that would, for a start, allow you to substitute two additions in place of a multiplications in the loop etc - for instance, consider calculating a1*i1, a2*i2, a3*i3 as (iteratively derived) arrays separately.
Hope this makes sense etc, good luck.
|