Skip to content

Commit 1ac1786

Browse files
author
Vahid Tavanashad
committed
address reviewer's comments
1 parent b989d36 commit 1ac1786

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

dpctl/tensor/_elementwise_funcs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,12 @@
14291429
First input array, expected to have a real-valued data type.
14301430
x2 (usm_ndarray):
14311431
Second input array, also expected to have a real-valued data type.
1432+
out ({None, usm_ndarray}, optional):
1433+
Output array to populate.
1434+
Array have the correct shape and the expected data type.
1435+
order ("C","F","A","K", optional):
1436+
Memory layout of the newly output array, if parameter `out` is `None`.
1437+
Default: "K".
14321438
Returns:
14331439
usm_ndarray:
14341440
an array containing the element-wise remainders. The data type of

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ template <typename argT1, typename argT2, typename resT> struct MaximumFunctor
7171
realT imag1 = std::imag(in1);
7272
realT imag2 = std::imag(in2);
7373

74-
if (std::isnan(real1) || std::isnan(imag1))
75-
return in1;
76-
else if (std::isnan(real2) || std::isnan(imag2))
77-
return in2;
78-
else if (real1 == real2)
79-
return imag1 > imag2 ? in1 : in2;
80-
else
81-
return real1 > real2 ? in1 : in2;
74+
bool gt = (real1 == real2) ? (imag1 > imag2)
75+
: (real1 > real2 && !std::isnan(imag1) &&
76+
!std::isnan(imag2));
77+
return (std::isnan(real1) || std::isnan(imag1) || gt) ? in1 : in2;
8278
}
8379
else {
8480
return (in1 != in1 || in1 > in2) ? in1 : in2;

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ template <typename argT1, typename argT2, typename resT> struct MinimumFunctor
7171
realT imag1 = std::imag(in1);
7272
realT imag2 = std::imag(in2);
7373

74-
if (std::isnan(real1) || std::isnan(imag1))
75-
return in1;
76-
else if (std::isnan(real2) || std::isnan(imag2))
77-
return in2;
78-
else if (real1 == real2)
79-
return imag1 < imag2 ? in1 : in2;
80-
else
81-
return real1 < real2 ? in1 : in2;
74+
bool gt = (real1 == real2) ? (imag1 < imag2)
75+
: (real1 < real2 && !std::isnan(imag1) &&
76+
!std::isnan(imag2));
77+
return (std::isnan(real1) || std::isnan(imag1) || gt) ? in1 : in2;
8278
}
8379
else {
8480
return (in1 != in1 || in1 < in2) ? in1 : in2;

0 commit comments

Comments
 (0)