Eigen  3.2.93
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  using ::log;
31  return make_double2(log(a.x), log(a.y));
32 }
33 
34 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
35 float4 pexp<float4>(const float4& a)
36 {
37  return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w));
38 }
39 
40 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
41 double2 pexp<double2>(const double2& a)
42 {
43  using ::exp;
44  return make_double2(exp(a.x), exp(a.y));
45 }
46 
47 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
48 float4 psqrt<float4>(const float4& a)
49 {
50  return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w));
51 }
52 
53 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
54 double2 psqrt<double2>(const double2& a)
55 {
56  using ::sqrt;
57  return make_double2(sqrt(a.x), sqrt(a.y));
58 }
59 
60 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
61 float4 prsqrt<float4>(const float4& a)
62 {
63  return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w));
64 }
65 
66 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
67 double2 prsqrt<double2>(const double2& a)
68 {
69  return make_double2(rsqrt(a.x), rsqrt(a.y));
70 }
71 
72 
73 #endif
74 
75 } // end namespace internal
76 
77 } // end namespace Eigen
78 
79 #endif // EIGEN_MATH_FUNCTIONS_CUDA_H
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
Namespace containing all symbols from the Eigen library.
Definition: Core:271
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_rsqrt_op< typename Derived::Scalar >, const Derived > rsqrt(const Eigen::ArrayBase< Derived > &x)
Definition: Eigen_Colamd.h:50
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_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)