56 #ifdef Vc_COMMON_MATH_H_INTERNAL
64 template <
typename T,
typename Abi>
65 using Const =
typename std::conditional<std::is_same<Abi, VectorAbi::Avx>::value,
66 AVX::Const<T>, SSE::Const<T>>::type;
68 template<LogarithmBase Base>
71 template<
typename T,
typename Abi>
static Vc_ALWAYS_INLINE
void log_series(Vector<T, Abi> &Vc_RESTRICT x,
typename Vector<T, Abi>::AsArg
exponent) {
72 typedef Vector<T, Abi> V;
73 typedef Detail::Const<T, Abi> C;
88 V y2 = (C::P(6) * x2 + C::P(7) * x) + C::P(8);
89 V y0 = (C::P(0) * x2 + C::P(1) * x) + C::P(2);
90 V y1 = (C::P(3) * x2 + C::P(4) * x) + C::P(5);
94 V y = (y0 * x9 + y1 * x6) + y2 * x3;
95 #elif defined Vc_LOG_ILP2
128 const V x4 = x2 * x2;
129 const V x5 = x2 * x3;
130 const V x6 = x3 * x3;
131 const V x7 = x4 * x3;
132 const V x8 = x4 * x4;
133 const V x9 = x5 * x4;
134 const V x10 = x5 * x5;
135 const V x11 = x5 * x6;
136 V y = C::P(0) * x11 + C::P(1) * x10 + C::P(2) * x9 + C::P(3) * x8 + C::P(4) * x7
137 + C::P(5) * x6 + C::P(6) * x5 + C::P(7) * x4 + C::P(8) * x3;
140 Vc::Common::unrolled_loop<int, 1, 9>([&](
int i) { y = y * x + C::P(i); });
146 y += exponent * C::ln2_small();
149 x += exponent * C::ln2_large();
152 y += exponent * C::ln2_small();
155 x += exponent * C::ln2_large();
163 y -= x_ * x * C::_1_2();
171 template <
typename Abi>
172 static Vc_ALWAYS_INLINE
void log_series(Vector<double, Abi> &Vc_RESTRICT x,
173 typename Vector<double, Abi>::AsArg exponent)
175 typedef Vector<double, Abi> V;
176 typedef Detail::Const<double, Abi> C;
180 Vc::Common::unrolled_loop<int, 1, 5>([&](
int i) {
182 y2 = y2 * x + C::Q(i);
191 y += exponent * C::ln2_small();
194 x += exponent * C::ln2_large();
197 y += exponent * C::ln2_small();
200 x += exponent * C::ln2_large();
208 y -= x_ * x * C::_1_2();
216 template <
typename T,
typename Abi,
typename V = Vector<T, Abi>>
217 static inline Vector<T, Abi> calc(V _x)
219 typedef typename V::Mask M;
220 typedef Detail::Const<T, Abi> C;
224 const M invalidMask = x <
V::Zero();
225 const M infinityMask = x ==
V::Zero();
226 const M denormal = x <=
C::min();
228 x(denormal) *= V(Vc::Detail::doubleConstant<1, 0, 54>());
232 x.setZero(C::exponentMask());
242 const M smallX = x < C::_1_sqrt2();
247 log_series(x, exponent);
249 x.setQnan(invalidMask);
250 x(infinityMask) = C::neginf();
257 template <
typename T,
typename Abi>
258 Vc_INTRINSIC Vc_CONST Vector<T, Abi>
log(
const Vector<T, Abi> &x)
260 return Detail::LogImpl<BaseE>::calc<T, Abi>(x);
262 template <
typename T,
typename Abi>
263 Vc_INTRINSIC Vc_CONST Vector<T, Abi>
log10(
const Vector<T, Abi> &x)
265 return Detail::LogImpl<Base10>::calc<T, Abi>(x);
267 template <
typename T,
typename Abi>
268 Vc_INTRINSIC Vc_CONST Vector<T, Abi>
log2(
const Vector<T, Abi> &x)
270 return Detail::LogImpl<Base2>::calc<T, Abi>(x);
273 #endif // Vc_COMMON_MATH_H_INTERNAL
Vc::Vector< T > log2(const Vc::Vector< T > &v)
Vc::Vector< T > min(const Vc::Vector< T > &x, const Vc::Vector< T > &y)
result_vector_type< L, R > operator|(L &&lhs, R &&rhs)
Applies | component-wise and concurrently.
Vc::Vector< T > log(const Vc::Vector< T > &v)
Vc::Vector< T > log10(const Vc::Vector< T > &v)
SimdArray< T, N, V, M > exponent(const SimdArray< T, N, V, M > &x)
Applies the std:: exponent function component-wise and concurrently.
constexpr VectorSpecialInitializerZero Zero
The special object Vc::Zero can be used to construct Vector and Mask objects initialized to zero/fals...
constexpr VectorSpecialInitializerOne One
The special object Vc::One can be used to construct Vector and Mask objects initialized to one/true...