Vectorized Trig functions in C?

℡╲_俬逩灬. 提交于 2019-12-03 12:58:46

Since you said you were using GCC it looks like there are some options:

That said, I'd probably look into GPGPU for a solution. Maybe writing it in CUDA or OpenCL (If I remember correctly CUDA supports the sine function). Here are some libraries that look like they might make it easier.

Since you are looking to calculate harmonics here, I have some code that addressed a similar problem. It is vectorized already and faster than anything else I have found. As a side benefit, you get the cosine for free.

What platform are you using? Many libraries of this sort already exist:

  • Intel's provides the Vector Math Library (VML) with icc.
  • Apple provides the vForce library as part of the Accelerate framework.
  • HP provides their own Vector Math Library for Itanium (and may other architectures, too).
  • Sun provided libmvec with their compiler tools.
  • ...

Instead of the taylor series, I would look at the algorithms fdlibm uses. They should get you as much precision with fewer steps.

My answer was to create my own library to do exactly this called vectrig: https://github.com/jeremysalwen/vectrig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!