Describe the bug
mx.expm1 returns wrong results for complex inputs: it operates on the real part and discards the imaginary part. The CPU backend uses std::expm1, which has no complex overload.
import mlx.core as mx
z = mx.array([0.5 + 0.7j])
print(mx.expm1(z)) # [0.6487+0j] == expm1(0.5), wrong
print(mx.exp(z) - 1) # [0.261+1.062j] correct
mx.log1p and mx.log2 already special-case complex; expm1 was missed.
Expected behavior
mx.expm1(z) == mx.exp(z) - 1 for complex z.
Desktop
- OS: macOS
- Version: main (0.32.0.dev)
Describe the bug
mx.expm1returns wrong results for complex inputs: it operates on the real part and discards the imaginary part. The CPU backend usesstd::expm1, which has no complex overload.mx.log1pandmx.log2already special-case complex;expm1was missed.Expected behavior
mx.expm1(z) == mx.exp(z) - 1for complexz.Desktop