Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:52:55

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 #ifndef EIGEN_GPU_SPECIALFUNCTIONS_H
0011 #define EIGEN_GPU_SPECIALFUNCTIONS_H
0012 
0013 namespace Eigen {
0014 
0015 namespace internal {
0016 
0017 // Make sure this is only available when targeting a GPU: we don't want to
0018 // introduce conflicts between these packet_traits definitions and the ones
0019 // we'll use on the host side (SSE, AVX, ...)
0020 #if defined(EIGEN_GPUCC) && defined(EIGEN_USE_GPU)
0021 
0022 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0023 float4 plgamma<float4>(const float4& a)
0024 {
0025   return make_float4(lgammaf(a.x), lgammaf(a.y), lgammaf(a.z), lgammaf(a.w));
0026 }
0027 
0028 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0029 double2 plgamma<double2>(const double2& a)
0030 {
0031   using numext::lgamma;
0032   return make_double2(lgamma(a.x), lgamma(a.y));
0033 }
0034 
0035 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0036 float4 pdigamma<float4>(const float4& a)
0037 {
0038   using numext::digamma;
0039   return make_float4(digamma(a.x), digamma(a.y), digamma(a.z), digamma(a.w));
0040 }
0041 
0042 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0043 double2 pdigamma<double2>(const double2& a)
0044 {
0045   using numext::digamma;
0046   return make_double2(digamma(a.x), digamma(a.y));
0047 }
0048 
0049 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0050 float4 pzeta<float4>(const float4& x, const float4& q)
0051 {
0052     using numext::zeta;
0053     return make_float4(zeta(x.x, q.x), zeta(x.y, q.y), zeta(x.z, q.z), zeta(x.w, q.w));
0054 }
0055 
0056 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0057 double2 pzeta<double2>(const double2& x, const double2& q)
0058 {
0059     using numext::zeta;
0060     return make_double2(zeta(x.x, q.x), zeta(x.y, q.y));
0061 }
0062 
0063 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0064 float4 ppolygamma<float4>(const float4& n, const float4& x)
0065 {
0066     using numext::polygamma;
0067     return make_float4(polygamma(n.x, x.x), polygamma(n.y, x.y), polygamma(n.z, x.z), polygamma(n.w, x.w));
0068 }
0069 
0070 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0071 double2 ppolygamma<double2>(const double2& n, const double2& x)
0072 {
0073     using numext::polygamma;
0074     return make_double2(polygamma(n.x, x.x), polygamma(n.y, x.y));
0075 }
0076 
0077 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0078 float4 perf<float4>(const float4& a)
0079 {
0080   return make_float4(erff(a.x), erff(a.y), erff(a.z), erff(a.w));
0081 }
0082 
0083 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0084 double2 perf<double2>(const double2& a)
0085 {
0086   using numext::erf;
0087   return make_double2(erf(a.x), erf(a.y));
0088 }
0089 
0090 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0091 float4 perfc<float4>(const float4& a)
0092 {
0093   using numext::erfc;
0094   return make_float4(erfc(a.x), erfc(a.y), erfc(a.z), erfc(a.w));
0095 }
0096 
0097 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0098 double2 perfc<double2>(const double2& a)
0099 {
0100   using numext::erfc;
0101   return make_double2(erfc(a.x), erfc(a.y));
0102 }
0103 
0104 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0105 float4 pndtri<float4>(const float4& a)
0106 {
0107   using numext::ndtri;
0108   return make_float4(ndtri(a.x), ndtri(a.y), ndtri(a.z), ndtri(a.w));
0109 }
0110 
0111 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0112 double2 pndtri<double2>(const double2& a)
0113 {
0114   using numext::ndtri;
0115   return make_double2(ndtri(a.x), ndtri(a.y));
0116 }
0117 
0118 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0119 float4 pigamma<float4>(const float4& a, const float4& x)
0120 {
0121   using numext::igamma;
0122   return make_float4(
0123       igamma(a.x, x.x),
0124       igamma(a.y, x.y),
0125       igamma(a.z, x.z),
0126       igamma(a.w, x.w));
0127 }
0128 
0129 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0130 double2 pigamma<double2>(const double2& a, const double2& x)
0131 {
0132   using numext::igamma;
0133   return make_double2(igamma(a.x, x.x), igamma(a.y, x.y));
0134 }
0135 
0136 template <>
0137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pigamma_der_a<float4>(
0138     const float4& a, const float4& x) {
0139   using numext::igamma_der_a;
0140   return make_float4(igamma_der_a(a.x, x.x), igamma_der_a(a.y, x.y),
0141                      igamma_der_a(a.z, x.z), igamma_der_a(a.w, x.w));
0142 }
0143 
0144 template <>
0145 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0146 pigamma_der_a<double2>(const double2& a, const double2& x) {
0147   using numext::igamma_der_a;
0148   return make_double2(igamma_der_a(a.x, x.x), igamma_der_a(a.y, x.y));
0149 }
0150 
0151 template <>
0152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pgamma_sample_der_alpha<float4>(
0153     const float4& alpha, const float4& sample) {
0154   using numext::gamma_sample_der_alpha;
0155   return make_float4(
0156       gamma_sample_der_alpha(alpha.x, sample.x),
0157       gamma_sample_der_alpha(alpha.y, sample.y),
0158       gamma_sample_der_alpha(alpha.z, sample.z),
0159       gamma_sample_der_alpha(alpha.w, sample.w));
0160 }
0161 
0162 template <>
0163 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0164 pgamma_sample_der_alpha<double2>(const double2& alpha, const double2& sample) {
0165   using numext::gamma_sample_der_alpha;
0166   return make_double2(
0167       gamma_sample_der_alpha(alpha.x, sample.x),
0168       gamma_sample_der_alpha(alpha.y, sample.y));
0169 }
0170 
0171 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0172 float4 pigammac<float4>(const float4& a, const float4& x)
0173 {
0174   using numext::igammac;
0175   return make_float4(
0176       igammac(a.x, x.x),
0177       igammac(a.y, x.y),
0178       igammac(a.z, x.z),
0179       igammac(a.w, x.w));
0180 }
0181 
0182 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0183 double2 pigammac<double2>(const double2& a, const double2& x)
0184 {
0185   using numext::igammac;
0186   return make_double2(igammac(a.x, x.x), igammac(a.y, x.y));
0187 }
0188 
0189 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0190 float4 pbetainc<float4>(const float4& a, const float4& b, const float4& x)
0191 {
0192   using numext::betainc;
0193   return make_float4(
0194       betainc(a.x, b.x, x.x),
0195       betainc(a.y, b.y, x.y),
0196       betainc(a.z, b.z, x.z),
0197       betainc(a.w, b.w, x.w));
0198 }
0199 
0200 template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0201 double2 pbetainc<double2>(const double2& a, const double2& b, const double2& x)
0202 {
0203   using numext::betainc;
0204   return make_double2(betainc(a.x, b.x, x.x), betainc(a.y, b.y, x.y));
0205 }
0206 
0207 template <>
0208 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i0e<float4>(const float4& x) {
0209   using numext::bessel_i0e;
0210   return make_float4(bessel_i0e(x.x), bessel_i0e(x.y), bessel_i0e(x.z), bessel_i0e(x.w));
0211 }
0212 
0213 template <>
0214 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0215 pbessel_i0e<double2>(const double2& x) {
0216   using numext::bessel_i0e;
0217   return make_double2(bessel_i0e(x.x), bessel_i0e(x.y));
0218 }
0219 
0220 template <>
0221 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i0<float4>(const float4& x) {
0222   using numext::bessel_i0;
0223   return make_float4(bessel_i0(x.x), bessel_i0(x.y), bessel_i0(x.z), bessel_i0(x.w));
0224 }
0225 
0226 template <>
0227 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0228 pbessel_i0<double2>(const double2& x) {
0229   using numext::bessel_i0;
0230   return make_double2(bessel_i0(x.x), bessel_i0(x.y));
0231 }
0232 
0233 template <>
0234 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i1e<float4>(const float4& x) {
0235   using numext::bessel_i1e;
0236   return make_float4(bessel_i1e(x.x), bessel_i1e(x.y), bessel_i1e(x.z), bessel_i1e(x.w));
0237 }
0238 
0239 template <>
0240 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0241 pbessel_i1e<double2>(const double2& x) {
0242   using numext::bessel_i1e;
0243   return make_double2(bessel_i1e(x.x), bessel_i1e(x.y));
0244 }
0245 
0246 template <>
0247 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i1<float4>(const float4& x) {
0248   using numext::bessel_i1;
0249   return make_float4(bessel_i1(x.x), bessel_i1(x.y), bessel_i1(x.z), bessel_i1(x.w));
0250 }
0251 
0252 template <>
0253 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0254 pbessel_i1<double2>(const double2& x) {
0255   using numext::bessel_i1;
0256   return make_double2(bessel_i1(x.x), bessel_i1(x.y));
0257 }
0258 
0259 template <>
0260 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k0e<float4>(const float4& x) {
0261   using numext::bessel_k0e;
0262   return make_float4(bessel_k0e(x.x), bessel_k0e(x.y), bessel_k0e(x.z), bessel_k0e(x.w));
0263 }
0264 
0265 template <>
0266 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0267 pbessel_k0e<double2>(const double2& x) {
0268   using numext::bessel_k0e;
0269   return make_double2(bessel_k0e(x.x), bessel_k0e(x.y));
0270 }
0271 
0272 template <>
0273 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k0<float4>(const float4& x) {
0274   using numext::bessel_k0;
0275   return make_float4(bessel_k0(x.x), bessel_k0(x.y), bessel_k0(x.z), bessel_k0(x.w));
0276 }
0277 
0278 template <>
0279 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0280 pbessel_k0<double2>(const double2& x) {
0281   using numext::bessel_k0;
0282   return make_double2(bessel_k0(x.x), bessel_k0(x.y));
0283 }
0284 
0285 template <>
0286 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k1e<float4>(const float4& x) {
0287   using numext::bessel_k1e;
0288   return make_float4(bessel_k1e(x.x), bessel_k1e(x.y), bessel_k1e(x.z), bessel_k1e(x.w));
0289 }
0290 
0291 template <>
0292 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0293 pbessel_k1e<double2>(const double2& x) {
0294   using numext::bessel_k1e;
0295   return make_double2(bessel_k1e(x.x), bessel_k1e(x.y));
0296 }
0297 
0298 template <>
0299 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k1<float4>(const float4& x) {
0300   using numext::bessel_k1;
0301   return make_float4(bessel_k1(x.x), bessel_k1(x.y), bessel_k1(x.z), bessel_k1(x.w));
0302 }
0303 
0304 template <>
0305 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0306 pbessel_k1<double2>(const double2& x) {
0307   using numext::bessel_k1;
0308   return make_double2(bessel_k1(x.x), bessel_k1(x.y));
0309 }
0310 
0311 template <>
0312 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_j0<float4>(const float4& x) {
0313   using numext::bessel_j0;
0314   return make_float4(bessel_j0(x.x), bessel_j0(x.y), bessel_j0(x.z), bessel_j0(x.w));
0315 }
0316 
0317 template <>
0318 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0319 pbessel_j0<double2>(const double2& x) {
0320   using numext::bessel_j0;
0321   return make_double2(bessel_j0(x.x), bessel_j0(x.y));
0322 }
0323 
0324 template <>
0325 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_j1<float4>(const float4& x) {
0326   using numext::bessel_j1;
0327   return make_float4(bessel_j1(x.x), bessel_j1(x.y), bessel_j1(x.z), bessel_j1(x.w));
0328 }
0329 
0330 template <>
0331 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0332 pbessel_j1<double2>(const double2& x) {
0333   using numext::bessel_j1;
0334   return make_double2(bessel_j1(x.x), bessel_j1(x.y));
0335 }
0336 
0337 template <>
0338 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_y0<float4>(const float4& x) {
0339   using numext::bessel_y0;
0340   return make_float4(bessel_y0(x.x), bessel_y0(x.y), bessel_y0(x.z), bessel_y0(x.w));
0341 }
0342 
0343 template <>
0344 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0345 pbessel_y0<double2>(const double2& x) {
0346   using numext::bessel_y0;
0347   return make_double2(bessel_y0(x.x), bessel_y0(x.y));
0348 }
0349 
0350 template <>
0351 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_y1<float4>(const float4& x) {
0352   using numext::bessel_y1;
0353   return make_float4(bessel_y1(x.x), bessel_y1(x.y), bessel_y1(x.z), bessel_y1(x.w));
0354 }
0355 
0356 template <>
0357 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2
0358 pbessel_y1<double2>(const double2& x) {
0359   using numext::bessel_y1;
0360   return make_double2(bessel_y1(x.x), bessel_y1(x.y));
0361 }
0362 
0363 #endif
0364 
0365 } // end namespace internal
0366 
0367 } // end namespace Eigen
0368 
0369 #endif // EIGEN_GPU_SPECIALFUNCTIONS_H