File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
dpctl/tensor/libtensor/include/kernels/elementwise_functions Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 28
28
#include < cmath>
29
29
#include < cstddef>
30
30
#include < cstdint>
31
+ #include < limits>
31
32
#include < type_traits>
32
33
33
34
#include " kernels/elementwise_functions/common.hpp"
@@ -73,6 +74,45 @@ template <typename argT, typename resT> struct Expm1Functor
73
74
const realT x = std::real (in);
74
75
const realT y = std::imag (in);
75
76
77
+ // special cases
78
+ if (std::isinf (x)) {
79
+ if (x > realT (0 )) {
80
+ // positive infinity cases
81
+ if (!std::isfinite (y)) {
82
+ return resT{x, std::numeric_limits<realT>::quiet_NaN ()};
83
+ }
84
+ else if (y == realT (0 )) {
85
+ return in;
86
+ }
87
+ else {
88
+ return (std::numeric_limits<realT>::infinity () *
89
+ resT{std::cos (y), std::sin (y)} -
90
+ realT (1 ));
91
+ }
92
+ }
93
+ else {
94
+ // negative infinity cases
95
+ if (!std::isfinite (y)) {
96
+ return resT{-1 , 0 };
97
+ }
98
+ else {
99
+ return (realT (0 ) * resT{std::cos (y), std::sin (y)} -
100
+ realT (1 ));
101
+ }
102
+ }
103
+ }
104
+
105
+ if (std::isnan (x)) {
106
+ if (y == realT (0 )) {
107
+ return in;
108
+ }
109
+ else {
110
+ return resT{std::numeric_limits<realT>::quiet_NaN (),
111
+ std::numeric_limits<realT>::quiet_NaN ()};
112
+ }
113
+ }
114
+
115
+ // x, y finite numbers
76
116
realT cosY_val;
77
117
const realT sinY_val = sycl::sincos (y, &cosY_val);
78
118
const realT sinhalfY_val = std::sin (y / 2 );
You can’t perform that action at this time.
0 commit comments