Compile-time trigonometry in C
Posted
by
lhahne
on Stack Overflow
See other posts from Stack Overflow
or by lhahne
Published on 2011-01-08T10:41:04Z
Indexed on
2011/01/08
10:53 UTC
Read the original article
Hit count: 256
c
|optimization
I currently have code that looks like
while (very_long_loop) {
...
y1 = getSomeValue();
...
x1 = y1*cos(PI/2);
x2 = y2*cos(SOME_CONSTANT);
...
outputValues(x1, x2, ...);
}
the obvious optimization would be to compute the cosines ahead-of-time. I could do this by filling an array with the values but I was wondering would it be possible to make the compiler compute these at compile-time?
© Stack Overflow or respective owner