I do some explicitly vectorised computations using SSE types, such as __m128 (defined in xmmintrin.h etc), but now I need to raise all elements of the vector to some (same) power, i.e. ideally I would want something like __m128 _mm_pow_ps(__m128, float), which unfortunately doesn't exist.
What is the best way around this? I could store the vector, call std::pow on each element, and then reload it. Is this the best I can do? How do compilers implement a call to std::pow when auto-vectorising code that otherwise is well vectorisable? Are there any libraries that provide something useful?
(note that this question is related by not a duplicate and certainly doesn't have a useful answer.)
Use the formula
exp(y*log(x))forpow(x, y)and a library with SSE implementations ofexp()andlog().Edit by @Royi: The above holds only for cases both
xandyare positive. Otherwise more carefull Math is needed. See https://math.stackexchange.com/questions/2089690.