![]() |
Eigen
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com> 00005 // 00006 // This Source Code Form is subject to the terms of the Mozilla 00007 // Public License v. 2.0. If a copy of the MPL was not distributed 00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00009 00010 #ifndef EIGEN_MATH_FUNCTIONS_CUDA_H 00011 #define EIGEN_MATH_FUNCTIONS_CUDA_H 00012 00013 namespace Eigen { 00014 00015 namespace internal { 00016 00017 // Make sure this is only available when targeting a GPU: we don't want to 00018 // introduce conflicts between these packet_traits definitions and the ones 00019 // we'll use on the host side (SSE, AVX, ...) 00020 #if defined(__CUDACC__) && defined(EIGEN_USE_GPU) 00021 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00022 float4 plog<float4>(const float4& a) 00023 { 00024 return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w)); 00025 } 00026 00027 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00028 double2 plog<double2>(const double2& a) 00029 { 00030 using ::log; 00031 return make_double2(log(a.x), log(a.y)); 00032 } 00033 00034 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00035 float4 plog1p<float4>(const float4& a) 00036 { 00037 return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w)); 00038 } 00039 00040 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00041 double2 plog1p<double2>(const double2& a) 00042 { 00043 return make_double2(log1p(a.x), log1p(a.y)); 00044 } 00045 00046 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00047 float4 pexp<float4>(const float4& a) 00048 { 00049 return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w)); 00050 } 00051 00052 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00053 double2 pexp<double2>(const double2& a) 00054 { 00055 using ::exp; 00056 return make_double2(exp(a.x), exp(a.y)); 00057 } 00058 00059 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00060 float4 psqrt<float4>(const float4& a) 00061 { 00062 return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w)); 00063 } 00064 00065 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00066 double2 psqrt<double2>(const double2& a) 00067 { 00068 using ::sqrt; 00069 return make_double2(sqrt(a.x), sqrt(a.y)); 00070 } 00071 00072 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00073 float4 prsqrt<float4>(const float4& a) 00074 { 00075 return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w)); 00076 } 00077 00078 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00079 double2 prsqrt<double2>(const double2& a) 00080 { 00081 return make_double2(rsqrt(a.x), rsqrt(a.y)); 00082 } 00083 00084 00085 #endif 00086 00087 } // end namespace internal 00088 00089 } // end namespace Eigen 00090 00091 #endif // EIGEN_MATH_FUNCTIONS_CUDA_H