![]() |
Eigen-unsupported
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_CUDA_SPECIALFUNCTIONS_H 00011 #define EIGEN_CUDA_SPECIALFUNCTIONS_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 00022 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00023 float4 plgamma<float4>(const float4& a) 00024 { 00025 return make_float4(lgammaf(a.x), lgammaf(a.y), lgammaf(a.z), lgammaf(a.w)); 00026 } 00027 00028 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00029 double2 plgamma<double2>(const double2& a) 00030 { 00031 using numext::lgamma; 00032 return make_double2(lgamma(a.x), lgamma(a.y)); 00033 } 00034 00035 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00036 float4 pdigamma<float4>(const float4& a) 00037 { 00038 using numext::digamma; 00039 return make_float4(digamma(a.x), digamma(a.y), digamma(a.z), digamma(a.w)); 00040 } 00041 00042 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00043 double2 pdigamma<double2>(const double2& a) 00044 { 00045 using numext::digamma; 00046 return make_double2(digamma(a.x), digamma(a.y)); 00047 } 00048 00049 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00050 float4 pzeta<float4>(const float4& x, const float4& q) 00051 { 00052 using numext::zeta; 00053 return make_float4(zeta(x.x, q.x), zeta(x.y, q.y), zeta(x.z, q.z), zeta(x.w, q.w)); 00054 } 00055 00056 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00057 double2 pzeta<double2>(const double2& x, const double2& q) 00058 { 00059 using numext::zeta; 00060 return make_double2(zeta(x.x, q.x), zeta(x.y, q.y)); 00061 } 00062 00063 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00064 float4 ppolygamma<float4>(const float4& n, const float4& x) 00065 { 00066 using numext::polygamma; 00067 return make_float4(polygamma(n.x, x.x), polygamma(n.y, x.y), polygamma(n.z, x.z), polygamma(n.w, x.w)); 00068 } 00069 00070 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00071 double2 ppolygamma<double2>(const double2& n, const double2& x) 00072 { 00073 using numext::polygamma; 00074 return make_double2(polygamma(n.x, x.x), polygamma(n.y, x.y)); 00075 } 00076 00077 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00078 float4 perf<float4>(const float4& a) 00079 { 00080 return make_float4(erff(a.x), erff(a.y), erff(a.z), erff(a.w)); 00081 } 00082 00083 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00084 double2 perf<double2>(const double2& a) 00085 { 00086 using numext::erf; 00087 return make_double2(erf(a.x), erf(a.y)); 00088 } 00089 00090 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00091 float4 perfc<float4>(const float4& a) 00092 { 00093 using numext::erfc; 00094 return make_float4(erfc(a.x), erfc(a.y), erfc(a.z), erfc(a.w)); 00095 } 00096 00097 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00098 double2 perfc<double2>(const double2& a) 00099 { 00100 using numext::erfc; 00101 return make_double2(erfc(a.x), erfc(a.y)); 00102 } 00103 00104 00105 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00106 float4 pigamma<float4>(const float4& a, const float4& x) 00107 { 00108 using numext::igamma; 00109 return make_float4( 00110 igamma(a.x, x.x), 00111 igamma(a.y, x.y), 00112 igamma(a.z, x.z), 00113 igamma(a.w, x.w)); 00114 } 00115 00116 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00117 double2 pigamma<double2>(const double2& a, const double2& x) 00118 { 00119 using numext::igamma; 00120 return make_double2(igamma(a.x, x.x), igamma(a.y, x.y)); 00121 } 00122 00123 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00124 float4 pigammac<float4>(const float4& a, const float4& x) 00125 { 00126 using numext::igammac; 00127 return make_float4( 00128 igammac(a.x, x.x), 00129 igammac(a.y, x.y), 00130 igammac(a.z, x.z), 00131 igammac(a.w, x.w)); 00132 } 00133 00134 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00135 double2 pigammac<double2>(const double2& a, const double2& x) 00136 { 00137 using numext::igammac; 00138 return make_double2(igammac(a.x, x.x), igammac(a.y, x.y)); 00139 } 00140 00141 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00142 float4 pbetainc<float4>(const float4& a, const float4& b, const float4& x) 00143 { 00144 using numext::betainc; 00145 return make_float4( 00146 betainc(a.x, b.x, x.x), 00147 betainc(a.y, b.y, x.y), 00148 betainc(a.z, b.z, x.z), 00149 betainc(a.w, b.w, x.w)); 00150 } 00151 00152 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 00153 double2 pbetainc<double2>(const double2& a, const double2& b, const double2& x) 00154 { 00155 using numext::betainc; 00156 return make_double2(betainc(a.x, b.x, x.x), betainc(a.y, b.y, x.y)); 00157 } 00158 00159 #endif 00160 00161 } // end namespace internal 00162 00163 } // end namespace Eigen 00164 00165 #endif // EIGEN_CUDA_SPECIALFUNCTIONS_H