Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
arch/AltiVec/MathFunctions.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2007 Julien Pommier
5// Copyright (C) 2009 Gael Guennebaud <[email protected]>
6// Copyright (C) 2016 Konstantinos Margaritis <[email protected]>
7//
8// This Source Code Form is subject to the terms of the Mozilla
9// Public License v. 2.0. If a copy of the MPL was not distributed
10// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
12#ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H
13#define EIGEN_MATH_FUNCTIONS_ALTIVEC_H
14
15// IWYU pragma: private
16#include "../../InternalHeaderCheck.h"
17
18namespace Eigen {
19
20namespace internal {
21
22EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet4f)
23#ifdef EIGEN_VECTORIZE_VSX
24EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_DOUBLE(Packet2d)
25#endif
26
27#ifdef EIGEN_VECTORIZE_VSX
28template <>
29EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4f psqrt<Packet4f>(const Packet4f& x) {
30 return vec_sqrt(x);
31}
32
33template <>
34EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet2d psqrt<Packet2d>(const Packet2d& x) {
35 return vec_sqrt(x);
36}
37
38#if !EIGEN_COMP_CLANG
39template <>
40EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4f prsqrt<Packet4f>(const Packet4f& x) {
41 return pset1<Packet4f>(1.0f) / psqrt<Packet4f>(x);
42 // vec_rsqrt returns different results from the generic version
43 // return vec_rsqrt(x);
44}
45
46template <>
47EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet2d prsqrt<Packet2d>(const Packet2d& x) {
48 return pset1<Packet2d>(1.0) / psqrt<Packet2d>(x);
49 // vec_rsqrt returns different results from the generic version
50 // return vec_rsqrt(x);
51}
52
53#endif
54
55template <>
56EIGEN_STRONG_INLINE Packet8bf psqrt<Packet8bf>(const Packet8bf& a) {
57 BF16_TO_F32_UNARY_OP_WRAPPER(psqrt<Packet4f>, a);
58}
59
60#if !EIGEN_COMP_CLANG
61template <>
62EIGEN_STRONG_INLINE Packet8bf prsqrt<Packet8bf>(const Packet8bf& a) {
63 BF16_TO_F32_UNARY_OP_WRAPPER(prsqrt<Packet4f>, a);
64}
65#endif
66#else
67template <>
68EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4f psqrt<Packet4f>(const Packet4f& x) {
69 Packet4f a;
70 for (Index i = 0; i < packet_traits<float>::size; i++) {
71 a[i] = numext::sqrt(x[i]);
72 }
73 return a;
74}
75#endif
76
77} // end namespace internal
78
79} // end namespace Eigen
80
81#endif // EIGEN_MATH_FUNCTIONS_ALTIVEC_H
Namespace containing all symbols from the Eigen library.
Definition Core:137