Eigen  3.2.92
arch/CUDA/MathFunctions.h
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_CUDA_H
11 #define EIGEN_MATH_FUNCTIONS_CUDA_H
12 
13 namespace Eigen {
14 
15 namespace internal {
16 
17 // Make sure this is only available when targeting a GPU: we don't want to
18 // introduce conflicts between these packet_traits definitions and the ones
19 // we'll use on the host side (SSE, AVX, ...)
20 #if defined(__CUDACC__) && defined(EIGEN_USE_GPU)
21 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
22 float4 plog<float4>(const float4& a)
23 {
24  return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w));
25 }
26 
27 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
28 double2 plog<double2>(const double2& a)
29 {
30  return make_double2(log(a.x), log(a.y));
31 }
32 
33 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
34 float4 pexp<float4>(const float4& a)
35 {
36  return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w));
37 }
38 
39 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
40 double2 pexp<double2>(const double2& a)
41 {
42  return make_double2(exp(a.x), exp(a.y));
43 }
44 
45 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
46 float4 psqrt<float4>(const float4& a)
47 {
48  return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w));
49 }
50 
51 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
52 double2 psqrt<double2>(const double2& a)
53 {
54  return make_double2(sqrt(a.x), sqrt(a.y));
55 }
56 
57 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
58 float4 prsqrt<float4>(const float4& a)
59 {
60  return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w));
61 }
62 
63 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
64 double2 prsqrt<double2>(const double2& a)
65 {
66  return make_double2(rsqrt(a.x), rsqrt(a.y));
67 }
68 
69 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
70 float4 plgamma<float4>(const float4& a)
71 {
72  return make_float4(lgammaf(a.x), lgammaf(a.y), lgammaf(a.z), lgammaf(a.w));
73 }
74 
75 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
76 double2 plgamma<double2>(const double2& a)
77 {
78  return make_double2(lgamma(a.x), lgamma(a.y));
79 }
80 
81 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
82 float4 perf<float4>(const float4& a)
83 {
84  return make_float4(erf(a.x), erf(a.y), erf(a.z), erf(a.w));
85 }
86 
87 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
88 double2 perf<double2>(const double2& a)
89 {
90  return make_double2(erf(a.x), erf(a.y));
91 }
92 
93 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
94 float4 perfc<float4>(const float4& a)
95 {
96  return make_float4(erfc(a.x), erfc(a.y), erfc(a.z), erfc(a.w));
97 }
98 
99 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
100 double2 perfc<double2>(const double2& a)
101 {
102  return make_double2(erfc(a.x), erfc(a.y));
103 }
104 
105 
106 #endif
107 
108 } // end namespace internal
109 
110 } // end namespace Eigen
111 
112 #endif // EIGEN_MATH_FUNCTIONS_CUDA_H
Definition: LDLT.h:16
Definition: Eigen_Colamd.h:54