Computing exponentials and Trig functions
Fredrik Johansson
fredrik.johansson at gmail.com
Thu Dec 6 18:22:58 CET 2007
On Dec 6, 2007 6:15 PM, <mr.janus at mac.com> wrote:
> Thanks for the quick response.
>
> I have already done the modulo pi/2 trick to speed things up. I think the biggest part of my problem is that each time i call a trig function i create storage for the temporary calculations. I am currently modifying the code so there is a global 'scratch' matrix that i can just dump data into without having to ask malloc for more space and initialise each time. Hopefully this will speed things up nicely.
There shouldn't be a need for a lot of temporary storage. Are you
computing each term from scratch? To compute exp(x) (for example), you
should only need two variables besides the input: one variable s to
store the accumulated sum and one temporary variable t:
t = 1
s = t
t = t * x / 1
s += t
t = t * x / 2
s += t
t = t * x / 3
s += t
t = t * x / 4
s += t
etc
Fredrik
More information about the gmp-discuss
mailing list