I am in the process of optimizing my code and I was wondering what the fastest way is to compute trig functions.
I profiled my code and to my astonishment discovered that one of the most time-consuming processes is computing cos(theta) and sin(theta) using the implementation of cos() and sin() in the cmath library.
Are there other libraries that function better or should I consider computing these functions as truncated Taylor series'?
I have already taken the step to ensure that these functions are only computed once for each value of theta (and then stored in a double which is used afterwards in the code), but it seems that there is a high cost involved in even computing these functions once for each value of theta (3000 times in my code right now).
Anyway help would be greatly appreciated.
Incidentally, (maybe this is common knowledge), it turned out that the most time consuming process was using the pow() function! Lesson learned for me: never use pow!
Thanks in advance,