Skip to content

Commit d7426a5

Browse files
call operator of ProjFunctor must be const
Also changed the implementation of ProjFunctor to make compiler's job eaiser.
1 parent 34523b1 commit d7426a5

File tree

1 file changed

+16
-5
lines changed
  • dpctl/tensor/libtensor/include/kernels/elementwise_functions

1 file changed

+16
-5
lines changed

dpctl/tensor/libtensor/include/kernels/elementwise_functions/proj.hpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,28 @@ template <typename argT, typename resT> struct ProjFunctor
6565
// do both argTy and resTy support sugroup store/load operation
6666
using supports_sg_loadstore = typename std::false_type;
6767

68-
resT operator()(const argT &in)
68+
resT operator()(const argT &in) const
6969
{
7070
using realT = typename argT::value_type;
7171
const realT x = std::real(in);
7272
const realT y = std::imag(in);
7373

74-
if (std::isinf(x) || std::isinf(y)) {
75-
const realT res_im = std::copysign(realT(0), y);
76-
return resT{std::numeric_limits<realT>::infinity(), res_im};
74+
if (std::isinf(x)) {
75+
return value_at_infinity(y);
7776
}
78-
return in;
77+
else if (std::isinf(y)) {
78+
return value_at_infinity(y);
79+
}
80+
else {
81+
return in;
82+
}
83+
}
84+
85+
private:
86+
template <typename T> std::complex<T> value_at_infinity(const T &y) const
87+
{
88+
const T res_im = std::copysign(T(0), y);
89+
return std::complex<T>{std::numeric_limits<T>::infinity(), res_im};
7990
}
8091
};
8192

0 commit comments

Comments
 (0)