# Sine or Cosine of every element in Mat (c++)

I was wondering if there is any way to take the sine or cosine of every element in a matrix?

Thanks!

EDIT: For future reference, I did the Taylor expansion of Sine. For pretty good accuracy, I only had to calculate up to the fourth term. However, keep note that if you are trying to estimate sin(pi) or sin(-pi) you have to calculate additional terms (probably 8 total terms).

This link will be useful for those who want to do this: http://en.wikipedia.org/wiki/Taylor_s...

Actually, you only need to go from -pi/4 to pi/4. For angles between pi/4 and pi/2, you can use the series for cos, substituting (pi/2-x) for your angle. Angles outside this range can be translated into it.