Eigen  5.0.1
 
Loading...
Searching...
No Matches
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_MATH_FUNCTIONS_GPU_H
12#define EIGEN_MATH_FUNCTIONS_GPU_H
13
14// IWYU pragma: private
15#include "../../InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20
21// Make sure this is only available when targeting a GPU: we don't want to
22// introduce conflicts between these packet_traits definitions and the ones
23// we'll use on the host side (SSE, AVX, ...)
24#if defined(EIGEN_GPUCC) && defined(EIGEN_USE_GPU)
25template <>
26EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plog<float4>(const float4& a) {
27 return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w));
28}
29
30template <>
31EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 plog<double2>(const double2& a) {
32 using ::log;
33 return make_double2(log(a.x), log(a.y));
34}
35
36template <>
37EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 plog1p<float4>(const float4& a) {
38 return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w));
39}
40
41template <>
42EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 plog1p<double2>(const double2& a) {
43 return make_double2(log1p(a.x), log1p(a.y));
44}
45
46template <>
47EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pexp<float4>(const float4& a) {
48 return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w));
49}
50
51template <>
52EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pexp<double2>(const double2& a) {
53 using ::exp;
54 return make_double2(exp(a.x), exp(a.y));
55}
56
57template <>
58EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pexp2<float4>(const float4& a) {
59 return make_float4(exp2f(a.x), exp2f(a.y), exp2f(a.z), exp2f(a.w));
60}
61
62template <>
63EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pexp2<double2>(const double2& a) {
64 using ::exp2;
65 return make_double2(exp2(a.x), exp2(a.y));
66}
67
68template <>
69EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pexpm1<float4>(const float4& a) {
70 return make_float4(expm1f(a.x), expm1f(a.y), expm1f(a.z), expm1f(a.w));
71}
72
73template <>
74EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 pexpm1<double2>(const double2& a) {
75 return make_double2(expm1(a.x), expm1(a.y));
76}
77
78template <>
79EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 psqrt<float4>(const float4& a) {
80 return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w));
81}
82
83template <>
84EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 psqrt<double2>(const double2& a) {
85 using ::sqrt;
86 return make_double2(sqrt(a.x), sqrt(a.y));
87}
88
89template <>
90EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 prsqrt<float4>(const float4& a) {
91 return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w));
92}
93
94template <>
95EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double2 prsqrt<double2>(const double2& a) {
96 return make_double2(rsqrt(a.x), rsqrt(a.y));
97}
98
99#endif
100
101} // end namespace internal
102
103} // end namespace Eigen
104
105#endif // EIGEN_MATH_FUNCTIONS_GPU_H