File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -750,24 +750,27 @@ inline
750
750
complex<_Tp>
751
751
reciprocal(const complex<_Tp>& __x)
752
752
{
753
+ // Handle extreme cases for numpy compatibility
753
754
auto both_inf = [](T real, T imag) {
754
- return :: isinf(real) && :: isinf(imag);
755
+ return isinf(real) && isinf(imag);
755
756
}
756
757
757
758
auto either_inf = [](T real, T imag) {
758
- return :: isinf(real) || :: isinf(imag);
759
+ return isinf(real) || isinf(imag);
759
760
}
760
761
761
762
auto either_nan = [](T real, T imag) {
762
- return :: isnan(real) || :: isnan(imag);
763
+ return isnan(real) || isnan(imag);
763
764
}
764
765
765
766
if (either_nan(__x.real(), __x.imag()) || both_inf(__x.real(), __x.imag())) {
767
+ // If either is Nan or both are infinite, return {nan, nan}
766
768
return {std::numeric_limits<T>::quiet_NaN(), std::numeric_limits<T>::quiet_NaN()};
767
769
} else if (either_inf(__x.real(), __x.imag())) {
770
+ // If either is Inf, return {0, 0}
768
771
return {0, 0};
769
772
}
770
- const c10:: complex<T> one = c10:: complex<T>(1.0, 0);
773
+ const complex<T> one = complex<T>(1.0, 0);
771
774
return one/__x;
772
775
}
773
776
You can’t perform that action at this time.
0 commit comments