Skip to content

Commit 6d7d3fe

Browse files
Use experimental::complex for in-place division
1 parent 5f56044 commit 6d7d3fe

File tree

1 file changed

+18
-1
lines changed
  • dpctl/tensor/libtensor/include/kernels/elementwise_functions

1 file changed

+18
-1
lines changed

Diff for: dpctl/tensor/libtensor/include/kernels/elementwise_functions/true_divide.hpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,24 @@ template <typename argT, typename resT> struct TrueDivideInplaceFunctor
407407

408408
void operator()(resT &res, const argT &in)
409409
{
410-
res /= in;
410+
if constexpr (tu_ns::is_complex<resT>::value) {
411+
using res_rT = typename resT::value_type;
412+
if constexpr (tu_ns::is_complex<argT>::value) {
413+
using arg_rT = typename argT::value_type;
414+
415+
auto res1 = exprm_ns::complex<res_rT>(res);
416+
res1 /= exprm_ns::complex<arg_rT>(in);
417+
res = res1;
418+
}
419+
else {
420+
auto res1 = exprm_ns::complex<res_rT>(res);
421+
res1 /= in;
422+
res = res1;
423+
}
424+
}
425+
else {
426+
res /= in;
427+
}
411428
}
412429

413430
template <int vec_sz>

0 commit comments

Comments
 (0)