Skip to content

Commit

Permalink
[SYCL] Add missing special values to exp(complex)
Browse files Browse the repository at this point in the history
exp(x,NaN) (for any finite x) = (NaN,NaN)
exp(NaN,y) (for any nonzero y) = (NaN,NaN)
exp(x,+∞) (for any finite x) = (NaN,NaN)

https://en.cppreference.com/w/cpp/numeric/complex/exp
E2E: intel#15666
  • Loading branch information
KornevNikita committed Oct 11, 2024
1 parent 7997c3c commit 5d0ba23
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libdevice/fallback-complex-fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,14 @@ double __complex__ __devicelib_cexp(double __complex__ z) {
z_imag = NAN;
return CMPLX(z_real, z_imag);
}
} else if (__spirv_IsNan(z_real) && (z_imag == 0.0)) {
return z;
} else if (__spirv_IsNan(z_real)) {
if (z_imag == 0.0)
return z;
else /*z_imag != 0.0 */
return CMPLX(NAN, NAN);
} else if (__spirv_IsFinite(z_real)) {
if (__spirv_IsNan(z_imag) || __spirv_IsInf(z_imag))
return CMPLX(NAN, NAN);
}
double __e = __spirv_ocl_exp(z_real);
double ret_real = __e * __spirv_ocl_cos(z_imag);
Expand Down

0 comments on commit 5d0ba23

Please sign in to comment.