Eigen-unsupported  5.0.1-dev+7c7d8473
 
Loading...
Searching...
No Matches
SpecialFunctions.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_GPU_SPECIALFUNCTIONS_H
11#define EIGEN_GPU_SPECIALFUNCTIONS_H
12
13namespace Eigen {
14
15namespace 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(EIGEN_GPUCC) && defined(EIGEN_USE_GPU)
21
22template <>
23EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plgamma<float4>(const float4& a) {
24 return make_float4(lgammaf(a.x), lgammaf(a.y), lgammaf(a.z), lgammaf(a.w));
25}
26
27template <>
28EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 plgamma<double2>(const double2& a) {
29 using numext::lgamma;
30 return make_double2(lgamma(a.x), lgamma(a.y));
31}
32
33template <>
34EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pdigamma<float4>(const float4& a) {
35 using numext::digamma;
36 return make_float4(digamma(a.x), digamma(a.y), digamma(a.z), digamma(a.w));
37}
38
39template <>
40EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pdigamma<double2>(const double2& a) {
41 using numext::digamma;
42 return make_double2(digamma(a.x), digamma(a.y));
43}
44
45template <>
46EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pzeta<float4>(const float4& x, const float4& q) {
47 using numext::zeta;
48 return make_float4(zeta(x.x, q.x), zeta(x.y, q.y), zeta(x.z, q.z), zeta(x.w, q.w));
49}
50
51template <>
52EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pzeta<double2>(const double2& x, const double2& q) {
53 using numext::zeta;
54 return make_double2(zeta(x.x, q.x), zeta(x.y, q.y));
55}
56
57template <>
58EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 ppolygamma<float4>(const float4& n, const float4& x) {
59 using numext::polygamma;
60 return make_float4(polygamma(n.x, x.x), polygamma(n.y, x.y), polygamma(n.z, x.z), polygamma(n.w, x.w));
61}
62
63template <>
64EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 ppolygamma<double2>(const double2& n, const double2& x) {
65 using numext::polygamma;
66 return make_double2(polygamma(n.x, x.x), polygamma(n.y, x.y));
67}
68
69template <>
70EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 perf<float4>(const float4& a) {
71 return make_float4(erff(a.x), erff(a.y), erff(a.z), erff(a.w));
72}
73
74template <>
75EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 perf<double2>(const double2& a) {
76 using numext::erf;
77 return make_double2(erf(a.x), erf(a.y));
78}
79
80template <>
81EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 perfc<float4>(const float4& a) {
82 using numext::erfc;
83 return make_float4(erfc(a.x), erfc(a.y), erfc(a.z), erfc(a.w));
84}
85
86template <>
87EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 perfc<double2>(const double2& a) {
88 using numext::erfc;
89 return make_double2(erfc(a.x), erfc(a.y));
90}
91
92template <>
93EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pndtri<float4>(const float4& a) {
94 using numext::ndtri;
95 return make_float4(ndtri(a.x), ndtri(a.y), ndtri(a.z), ndtri(a.w));
96}
97
98template <>
99EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pndtri<double2>(const double2& a) {
100 using numext::ndtri;
101 return make_double2(ndtri(a.x), ndtri(a.y));
102}
103
104template <>
105EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pigamma<float4>(const float4& a, const float4& x) {
106 using numext::igamma;
107 return make_float4(igamma(a.x, x.x), igamma(a.y, x.y), igamma(a.z, x.z), igamma(a.w, x.w));
108}
109
110template <>
111EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pigamma<double2>(const double2& a, const double2& x) {
112 using numext::igamma;
113 return make_double2(igamma(a.x, x.x), igamma(a.y, x.y));
114}
115
116template <>
117EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pigamma_der_a<float4>(const float4& a, const float4& x) {
118 using numext::igamma_der_a;
119 return make_float4(igamma_der_a(a.x, x.x), igamma_der_a(a.y, x.y), igamma_der_a(a.z, x.z), igamma_der_a(a.w, x.w));
120}
121
122template <>
123EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pigamma_der_a<double2>(const double2& a, const double2& x) {
124 using numext::igamma_der_a;
125 return make_double2(igamma_der_a(a.x, x.x), igamma_der_a(a.y, x.y));
126}
127
128template <>
129EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pgamma_sample_der_alpha<float4>(const float4& alpha,
130 const float4& sample) {
131 using numext::gamma_sample_der_alpha;
132 return make_float4(gamma_sample_der_alpha(alpha.x, sample.x), gamma_sample_der_alpha(alpha.y, sample.y),
133 gamma_sample_der_alpha(alpha.z, sample.z), gamma_sample_der_alpha(alpha.w, sample.w));
134}
135
136template <>
137EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pgamma_sample_der_alpha<double2>(const double2& alpha,
138 const double2& sample) {
139 using numext::gamma_sample_der_alpha;
140 return make_double2(gamma_sample_der_alpha(alpha.x, sample.x), gamma_sample_der_alpha(alpha.y, sample.y));
141}
142
143template <>
144EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pigammac<float4>(const float4& a, const float4& x) {
145 using numext::igammac;
146 return make_float4(igammac(a.x, x.x), igammac(a.y, x.y), igammac(a.z, x.z), igammac(a.w, x.w));
147}
148
149template <>
150EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pigammac<double2>(const double2& a, const double2& x) {
151 using numext::igammac;
152 return make_double2(igammac(a.x, x.x), igammac(a.y, x.y));
153}
154
155template <>
156EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbetainc<float4>(const float4& a, const float4& b, const float4& x) {
157 using numext::betainc;
158 return make_float4(betainc(a.x, b.x, x.x), betainc(a.y, b.y, x.y), betainc(a.z, b.z, x.z), betainc(a.w, b.w, x.w));
159}
160
161template <>
162EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbetainc<double2>(const double2& a, const double2& b, const double2& x) {
163 using numext::betainc;
164 return make_double2(betainc(a.x, b.x, x.x), betainc(a.y, b.y, x.y));
165}
166
167template <>
168EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i0e<float4>(const float4& x) {
169 using numext::bessel_i0e;
170 return make_float4(bessel_i0e(x.x), bessel_i0e(x.y), bessel_i0e(x.z), bessel_i0e(x.w));
171}
172
173template <>
174EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_i0e<double2>(const double2& x) {
175 using numext::bessel_i0e;
176 return make_double2(bessel_i0e(x.x), bessel_i0e(x.y));
177}
178
179template <>
180EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i0<float4>(const float4& x) {
181 using numext::bessel_i0;
182 return make_float4(bessel_i0(x.x), bessel_i0(x.y), bessel_i0(x.z), bessel_i0(x.w));
183}
184
185template <>
186EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_i0<double2>(const double2& x) {
187 using numext::bessel_i0;
188 return make_double2(bessel_i0(x.x), bessel_i0(x.y));
189}
190
191template <>
192EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i1e<float4>(const float4& x) {
193 using numext::bessel_i1e;
194 return make_float4(bessel_i1e(x.x), bessel_i1e(x.y), bessel_i1e(x.z), bessel_i1e(x.w));
195}
196
197template <>
198EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_i1e<double2>(const double2& x) {
199 using numext::bessel_i1e;
200 return make_double2(bessel_i1e(x.x), bessel_i1e(x.y));
201}
202
203template <>
204EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_i1<float4>(const float4& x) {
205 using numext::bessel_i1;
206 return make_float4(bessel_i1(x.x), bessel_i1(x.y), bessel_i1(x.z), bessel_i1(x.w));
207}
208
209template <>
210EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_i1<double2>(const double2& x) {
211 using numext::bessel_i1;
212 return make_double2(bessel_i1(x.x), bessel_i1(x.y));
213}
214
215template <>
216EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k0e<float4>(const float4& x) {
217 using numext::bessel_k0e;
218 return make_float4(bessel_k0e(x.x), bessel_k0e(x.y), bessel_k0e(x.z), bessel_k0e(x.w));
219}
220
221template <>
222EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_k0e<double2>(const double2& x) {
223 using numext::bessel_k0e;
224 return make_double2(bessel_k0e(x.x), bessel_k0e(x.y));
225}
226
227template <>
228EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k0<float4>(const float4& x) {
229 using numext::bessel_k0;
230 return make_float4(bessel_k0(x.x), bessel_k0(x.y), bessel_k0(x.z), bessel_k0(x.w));
231}
232
233template <>
234EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_k0<double2>(const double2& x) {
235 using numext::bessel_k0;
236 return make_double2(bessel_k0(x.x), bessel_k0(x.y));
237}
238
239template <>
240EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k1e<float4>(const float4& x) {
241 using numext::bessel_k1e;
242 return make_float4(bessel_k1e(x.x), bessel_k1e(x.y), bessel_k1e(x.z), bessel_k1e(x.w));
243}
244
245template <>
246EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_k1e<double2>(const double2& x) {
247 using numext::bessel_k1e;
248 return make_double2(bessel_k1e(x.x), bessel_k1e(x.y));
249}
250
251template <>
252EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_k1<float4>(const float4& x) {
253 using numext::bessel_k1;
254 return make_float4(bessel_k1(x.x), bessel_k1(x.y), bessel_k1(x.z), bessel_k1(x.w));
255}
256
257template <>
258EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_k1<double2>(const double2& x) {
259 using numext::bessel_k1;
260 return make_double2(bessel_k1(x.x), bessel_k1(x.y));
261}
262
263template <>
264EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_j0<float4>(const float4& x) {
265 using numext::bessel_j0;
266 return make_float4(bessel_j0(x.x), bessel_j0(x.y), bessel_j0(x.z), bessel_j0(x.w));
267}
268
269template <>
270EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_j0<double2>(const double2& x) {
271 using numext::bessel_j0;
272 return make_double2(bessel_j0(x.x), bessel_j0(x.y));
273}
274
275template <>
276EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_j1<float4>(const float4& x) {
277 using numext::bessel_j1;
278 return make_float4(bessel_j1(x.x), bessel_j1(x.y), bessel_j1(x.z), bessel_j1(x.w));
279}
280
281template <>
282EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_j1<double2>(const double2& x) {
283 using numext::bessel_j1;
284 return make_double2(bessel_j1(x.x), bessel_j1(x.y));
285}
286
287template <>
288EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_y0<float4>(const float4& x) {
289 using numext::bessel_y0;
290 return make_float4(bessel_y0(x.x), bessel_y0(x.y), bessel_y0(x.z), bessel_y0(x.w));
291}
292
293template <>
294EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_y0<double2>(const double2& x) {
295 using numext::bessel_y0;
296 return make_double2(bessel_y0(x.x), bessel_y0(x.y));
297}
298
299template <>
300EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pbessel_y1<float4>(const float4& x) {
301 using numext::bessel_y1;
302 return make_float4(bessel_y1(x.x), bessel_y1(x.y), bessel_y1(x.z), bessel_y1(x.w));
303}
304
305template <>
306EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pbessel_y1<double2>(const double2& x) {
307 using numext::bessel_y1;
308 return make_double2(bessel_y1(x.x), bessel_y1(x.y));
309}
310
311#endif
312
313} // end namespace internal
314
315} // end namespace Eigen
316
317#endif // EIGEN_GPU_SPECIALFUNCTIONS_H
Namespace containing all symbols from the Eigen library.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_y1_op< typename Derived::Scalar >, const Derived > bessel_y1(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:269
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k0e_op< typename Derived::Scalar >, const Derived > bessel_k0e(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:142
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k0_op< typename Derived::Scalar >, const Derived > bessel_k0(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:120
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igammac_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igammac(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
Definition SpecialFunctionsArrayAPI.h:93
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igamma_der_a_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igamma_der_a(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
Definition SpecialFunctionsArrayAPI.h:52
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k1_op< typename Derived::Scalar >, const Derived > bessel_k1(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:163
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i1_op< typename Derived::Scalar >, const Derived > bessel_i1(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:77
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i0e_op< typename Derived::Scalar >, const Derived > bessel_i0e(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:56
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_lgamma_op< typename Derived::Scalar >, const Derived > lgamma(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i1e_op< typename Derived::Scalar >, const Derived > bessel_i1e(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:99
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_j1_op< typename Derived::Scalar >, const Derived > bessel_j1(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:248
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_y0_op< typename Derived::Scalar >, const Derived > bessel_y0(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:227
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_i0_op< typename Derived::Scalar >, const Derived > bessel_i0(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:34
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_erf_op< typename Derived::Scalar >, const Derived > erf(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_k1e_op< typename Derived::Scalar >, const Derived > bessel_k1e(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:185
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_gamma_sample_der_alpha_op< typename AlphaDerived::Scalar >, const AlphaDerived, const SampleDerived > gamma_sample_der_alpha(const Eigen::ArrayBase< AlphaDerived > &alpha, const Eigen::ArrayBase< SampleDerived > &sample)
Definition SpecialFunctionsArrayAPI.h:75
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_erfc_op< typename Derived::Scalar >, const Derived > erfc(const Eigen::ArrayBase< Derived > &x)
const TensorCwiseTernaryOp< internal::scalar_betainc_op< typename XDerived::Scalar >, const ADerived, const BDerived, const XDerived > betainc(const Eigen::TensorBase< ADerived, ReadOnlyAccessors > &a, const Eigen::TensorBase< BDerived, ReadOnlyAccessors > &b, const Eigen::TensorBase< XDerived, ReadOnlyAccessors > &x)
Definition TensorGlobalFunctions.h:26
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_ndtri_op< typename Derived::Scalar >, const Derived > ndtri(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_digamma_op< typename Derived::Scalar >, const Derived > digamma(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_polygamma_op< typename DerivedX::Scalar >, const DerivedN, const DerivedX > polygamma(const Eigen::ArrayBase< DerivedN > &n, const Eigen::ArrayBase< DerivedX > &x)
Definition SpecialFunctionsArrayAPI.h:113
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_bessel_j0_op< typename Derived::Scalar >, const Derived > bessel_j0(const Eigen::ArrayBase< Derived > &x)
Definition BesselFunctionsArrayAPI.h:206
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igamma_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igamma(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
Definition SpecialFunctionsArrayAPI.h:31
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
Definition SpecialFunctionsArrayAPI.h:152