arch/GPU/MathFunctions.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_MATH_FUNCTIONS_GPU_H
11 #define EIGEN_MATH_FUNCTIONS_GPU_H
12 
13 #include "../../InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 namespace internal {
18 
19 // Make sure this is only available when targeting a GPU: we don't want to
20 // introduce conflicts between these packet_traits definitions and the ones
21 // we'll use on the host side (SSE, AVX, ...)
22 #if defined(EIGEN_GPUCC) && defined(EIGEN_USE_GPU)
23 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
24 float4 plog<float4>(const float4& a)
25 {
26  return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w));
27 }
28 
29 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
30 double2 plog<double2>(const double2& a)
31 {
33  return make_double2(log(a.x), log(a.y));
34 }
35 
36 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
37 float4 plog1p<float4>(const float4& a)
38 {
39  return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w));
40 }
41 
42 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
43 double2 plog1p<double2>(const double2& a)
44 {
45  return make_double2(log1p(a.x), log1p(a.y));
46 }
47 
48 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
49 float4 pexp<float4>(const float4& a)
50 {
51  return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w));
52 }
53 
54 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
55 double2 pexp<double2>(const double2& a)
56 {
58  return make_double2(exp(a.x), exp(a.y));
59 }
60 
61 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
62 float4 pexpm1<float4>(const float4& a)
63 {
64  return make_float4(expm1f(a.x), expm1f(a.y), expm1f(a.z), expm1f(a.w));
65 }
66 
67 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
68 double2 pexpm1<double2>(const double2& a)
69 {
70  return make_double2(expm1(a.x), expm1(a.y));
71 }
72 
73 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
74 float4 psqrt<float4>(const float4& a)
75 {
76  return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w));
77 }
78 
79 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
80 double2 psqrt<double2>(const double2& a)
81 {
83  return make_double2(sqrt(a.x), sqrt(a.y));
84 }
85 
86 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
87 float4 prsqrt<float4>(const float4& a)
88 {
89  return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w));
90 }
91 
92 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
93 double2 prsqrt<double2>(const double2& a)
94 {
95  return make_double2(rsqrt(a.x), rsqrt(a.y));
96 }
97 
98 
99 #endif
100 
101 } // end namespace internal
102 
103 } // end namespace Eigen
104 
105 #endif // EIGEN_MATH_FUNCTIONS_GPU_H
const ExpReturnType exp() const
const SqrtReturnType sqrt() const
const LogReturnType log() const
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
: InteropHeaders
Definition: Core:139
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_rsqrt_op< typename Derived::Scalar >, const Derived > rsqrt(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log1p_op< typename Derived::Scalar >, const Derived > log1p(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_expm1_op< typename Derived::Scalar >, const Derived > expm1(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log_op< typename Derived::Scalar >, const Derived > log(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)