mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Remainder negative numerator bug fixed (#641)
Co-authored-by: Angelos Katharopoulos <a_katharopoulos@apple.com>
This commit is contained in:
committed by
GitHub
parent
b57bd0488d
commit
b670485185
@@ -35,6 +35,16 @@ inline bool operator>(const complex64_t& a, const complex64_t& b) {
|
||||
return (a.real() > b.real()) || (a.real() == b.real() && a.imag() > b.imag());
|
||||
}
|
||||
|
||||
inline complex64_t operator%(complex64_t a, complex64_t b) {
|
||||
auto real = a.real() - (b.real() * static_cast<int64_t>(a.real() / b.real()));
|
||||
auto imag = a.imag() - (b.imag() * static_cast<int64_t>(a.imag() / b.imag()));
|
||||
if (real != 0 && (real < 0 != b.real() < 0))
|
||||
real += b.real();
|
||||
if (imag != 0 && (imag < 0 != b.imag() < 0))
|
||||
imag += b.imag();
|
||||
return {real, imag};
|
||||
}
|
||||
|
||||
inline bool operator<=(const complex64_t& a, const complex64_t& b) {
|
||||
return operator>=(b, a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user