Commit 6b582d32 authored by Martin Reinecke's avatar Martin Reinecke

add a (currently disabled) alternative for trig computation

parent e33d1db6
Pipeline #101025 passed with stages
in 29 minutes and 53 seconds
......@@ -73,6 +73,64 @@ template<typename T, typename Tc> class UnityRoots
}
}
}
#if 0 // alternative version, similar speed, but maybe a bit more accurate
static cmplx_ calc2(size_t x, size_t n)
{
static constexpr Thigh pi = Thigh(3.141592653589793238462643383279502884197L);
Thigh n4 = Thigh(n<<2);
x<<=3;
if (x<4*n) // first half
{
if (x<2*n) // first quadrant
{
if (x<n)
{
auto ang = (x/n4)*pi;
return {cos(ang), sin(ang)};
}
auto ang = ((2*n-x)/n4)*pi;
return {sin(ang), cos(ang)};
}
else // second quadrant
{
x-=2*n;
if (x<n)
{
auto ang = (x/n4)*pi;
return {-sin(ang), cos(ang)};
}
auto ang = ((2*n-x)/n4)*pi;
return {-cos(ang), sin(ang)};
}
}
else
{
x=8*n-x;
if (x<2*n) // third quadrant
{
if (x<n)
{
auto ang = (x/n4)*pi;
return {cos(ang), -sin(ang)};
}
auto ang = ((2*n-x)/n4)*pi;
return {sin(ang), -cos(ang)};
}
else // fourth quadrant
{
x-=2*n;
if (x<n)
{
auto ang = (x/n4)*pi;
return {-sin(ang), -cos(ang)};
}
auto ang = ((2*n-x)/n4)*pi;
return {-cos(ang), -sin(ang)};
}
}
}
#endif
public:
UnityRoots(size_t n)
......
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