28#define SYCL_EXT_ONEAPI_COMPLEX
29#if __has_include(<sycl/ext/oneapi/experimental/sycl_complex.hpp>)
30#include <sycl/ext/oneapi/experimental/sycl_complex.hpp>
32#include <sycl/ext/oneapi/experimental/complex/complex.hpp>
35#include <sycl/sycl.hpp>
38#include "utils/type_utils.hpp"
40namespace dpnp::kernels::sinc
42namespace tu_ns = dpctl::tensor::type_utils;
46namespace exprm_ns = sycl::ext::oneapi::experimental;
49inline Tp sin(
const Tp &in)
51 if constexpr (tu_ns::is_complex<Tp>::value) {
52 using realTp =
typename Tp::value_type;
54 constexpr realTp q_nan = std::numeric_limits<realTp>::quiet_NaN();
56 realTp
const &in_re = std::real(in);
57 realTp
const &in_im = std::imag(in);
59 const bool in_re_finite = sycl::isfinite(in_re);
60 const bool in_im_finite = sycl::isfinite(in_im);
65 if (in_re_finite && in_im_finite) {
66 Tp res = exprm_ns::sin(exprm_ns::complex<realTp>(in));
67 if (in_re == realTp(0)) {
68 res.real(sycl::copysign(realTp(0), in_re));
78 const realTp x = -in_im;
79 const realTp y = in_re;
80 const bool xfinite = in_im_finite;
81 const bool yfinite = in_re_finite;
91 if (x == realTp(0) && !yfinite) {
92 const realTp sinh_im = q_nan;
93 const realTp sinh_re = sycl::copysign(realTp(0), x * sinh_im);
94 return Tp{sinh_im, -sinh_re};
102 if (y == realTp(0) && !xfinite) {
104 const realTp sinh_re = x;
105 const realTp sinh_im = y;
106 return Tp{sinh_im, -sinh_re};
108 const realTp sinh_re = x;
109 const realTp sinh_im = sycl::copysign(realTp(0), y);
110 return Tp{sinh_im, -sinh_re};
118 if (xfinite && !yfinite) {
119 const realTp sinh_re = q_nan;
120 const realTp sinh_im = x * sinh_re;
121 return Tp{sinh_im, -sinh_re};
138 const realTp sinh_re = -x * x;
139 const realTp sinh_im = x * (y - y);
140 return Tp{sinh_im, -sinh_re};
142 const realTp sinh_re = x * sycl::cos(y);
143 const realTp sinh_im =
144 std::numeric_limits<realTp>::infinity() * sycl::sin(y);
145 return Tp{sinh_im, -sinh_re};
155 const realTp y_m_y = (y - y);
156 const realTp sinh_re = (x * x) * y_m_y;
157 const realTp sinh_im = (x + x) * y_m_y;
158 return Tp{sinh_im, -sinh_re};
164 return sycl::sin(in);
169template <
typename argT,
typename Tp>
173 using is_constant =
typename std::false_type;
177 using supports_vec =
typename std::false_type;
179 using supports_sg_loadstore =
typename std::negation<
180 std::disjunction<tu_ns::is_complex<Tp>, tu_ns::is_complex<argT>>>;
182 Tp operator()(
const argT &x)
const
185 static_cast<argT
>(3.1415926535897932384626433832795029L);
186 const argT y = pi * x;
192 if constexpr (tu_ns::is_complex<argT>::value) {
193 return impl::sin(y) / y;
196 return sycl::sinpi(x) / y;