X

sincos()

Guest Author

If you are computing both the sine and cosine of an angle, then you will be twice as quick if you call sincos() than if you call cos() and sin() independently:

#include 
int main()
{
double a,b,c;
a=1.0;
for (int i=0;i<100000000;i++) { b=sin(a); c=cos(a); }
}
$ cc -O sc.c -lm
$ timex ./a.out
real 19.13

vs

#include 
int main()
{
double a,b,c;
a=1.0;
for (int i=0;i<100000000;i++) { sincos(a,&b,&c); }
}
$ cc -O sc.c -lm
$ timex ./a.out
real 9.80

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.