update: fix loop to be 55, it's faster with -O2
This commit is contained in:
parent
d03ad61916
commit
df5933ed5c
6
sin.c
6
sin.c
@ -68,7 +68,7 @@ int trig(double theta, double *xy, double *dxy)
|
|||||||
|
|
||||||
xy[0] = x0;
|
xy[0] = x0;
|
||||||
xy[1] = y0;
|
xy[1] = y0;
|
||||||
while (i < 100 && fabs(alpha) > 1e-16)
|
for (i = 0; i < 56; i++)
|
||||||
{
|
{
|
||||||
d = alpha > 0 ? 1 : (alpha < 0 ? -1 : 0);
|
d = alpha > 0 ? 1 : (alpha < 0 ? -1 : 0);
|
||||||
dxy[0] = -d * xy[1] * t;
|
dxy[0] = -d * xy[1] * t;
|
||||||
@ -76,7 +76,6 @@ int trig(double theta, double *xy, double *dxy)
|
|||||||
xy[0] += dxy[0];
|
xy[0] += dxy[0];
|
||||||
xy[1] += dxy[1];
|
xy[1] += dxy[1];
|
||||||
alpha -= d * atanlist[i];
|
alpha -= d * atanlist[i];
|
||||||
i++;
|
|
||||||
t /= 2.0;
|
t /= 2.0;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
@ -124,7 +123,7 @@ double sin11(double theta, int *it, double *dsin)
|
|||||||
xy[0] = x0;
|
xy[0] = x0;
|
||||||
xy[1] = y0;
|
xy[1] = y0;
|
||||||
dxy[1] = 1;
|
dxy[1] = 1;
|
||||||
while (i < 100 && fabs(dxy[1]) > 1e-16)
|
for (i = 0; i < 56; i++)
|
||||||
{
|
{
|
||||||
d = alpha > 0 ? 1 : (alpha < 0 ? -1 : 0);
|
d = alpha > 0 ? 1 : (alpha < 0 ? -1 : 0);
|
||||||
dxy[0] = -d * xy[1] * t;
|
dxy[0] = -d * xy[1] * t;
|
||||||
@ -132,7 +131,6 @@ double sin11(double theta, int *it, double *dsin)
|
|||||||
xy[0] += dxy[0];
|
xy[0] += dxy[0];
|
||||||
xy[1] += dxy[1];
|
xy[1] += dxy[1];
|
||||||
alpha -= d * atanlist[i];
|
alpha -= d * atanlist[i];
|
||||||
i++;
|
|
||||||
t /= 2.0;
|
t /= 2.0;
|
||||||
}
|
}
|
||||||
*dsin = dxy[1];
|
*dsin = dxy[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user