1
Name:
Anonymous
2010-11-18 17:28
is math.h functions not recommended when wanting speed? I remember seeing one of you guys commenting on someone using pow awhile ago, so what's the secret here?
2
Name:
Anonymous
2010-11-18 17:32
Use it. If you notice any unacceptable slowdown, find out what's taking so long. Chances are, it won't be from math.h.
3
Name:
Anonymous
2010-11-18 17:58
Heh, inefficient implementation. You should see the Prelude.
6
Name:
Anonymous
2010-11-19 2:44
>>1
Read gcc(1). It says something about "unsafe" optimizaiton and float numbers. Or here
http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
TL;DR consider this:
#include <math.h>
double z(double x)
{
return sin(x);
}
gcc -O3 -S a.cpp
__Z1zd:
pushl %ebp
movl %esp, %ebp
popl %ebp
jmp _sin
gcc -ffast-math -O3 -S a.cpp
__Z1zd:
pushl %ebp
movl %esp, %ebp
fldl 8(%ebp)
popl %ebp
fsin
ret
inb4:YOU HERPED HIM
11
Name:
Anonymous
2010-11-20 11:14
use this:
double powd(double x,double y)
{
int i;
for(i=0;i<y;i++)
x*=x;
return x;
}
13
Name:
Anonymous
2010-11-20 14:28
>>12
Well done, you have pointed out the obvious
14
Name:
Anonymous
2010-11-20 17:27
>>13
Notice how he didn't even sage.
How rude.