Commit 5c6bac5b authored by PACANOWSKI Romain's avatar PACANOWSKI Romain

unrolling the recursion to speed up a little bit the evaluatio

parent 47e3d8e4
......@@ -34,6 +34,30 @@ double rational_function_legendre_1d::legendre(double x, int i) const
{
return x;
}
else if (i == 2)
{
return (3*x*x - 1) * 0.5;
}
else if (i == 3)
{
return ( (5*x*x - 3) * x ) * 0.5;
}
else if (i == 4)
{
return ((7*x*x - 6) * 5*x*x + 3) * 0.125;
}
else if (i== 5)
{
return (((63*x*x - 70)*x*x + 15)*x)*0.125;
}
else if (i== 6)
{
return (((231*x*x-315)*x*x + 105)*x*x - 5) * 0.0625;
}
else if (i==7)
{
return ((((429*x*x-693)*x*x + 315)*x*x - 35)*x) * 0.0625;
}
else
{
return ((2*i-1)*x*legendre(x, i-1) - (i-1)*legendre(x, i-2)) / (double)i ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment