`eps()` (epsilon) for Complex floats?

It is surprising to me that eps(Complex{Float32}) is unsupported currently, given that there are many applications involving complex data where one would like to specify the precision of some operation appropriately.

A single line addition to Base will address this:

eps(::Type{Complex{T}}) where T <: AbstractFloat = eps(T)

I realize that the docs for eps refer to “next largest value” and there is no ordering of complex numbers, but the principle applies adequately to the real and imaginary parts.

I can submit a PR to add this one line (and associated tests and docs) but I wanted to first get a sense of whether this addition seems appropriate to others.

BTW, in Matlab eps(1 + 1i) works and returns the same value as eps(1) so I think I’m not too far out on a limb here…

I’ve seen at least two package issues that arose due to this absence:

Yeah. This is kind of weird. On the balance, it sounds like we should support this. Want to make a PR?

1 Like

edit: so much for it being just one added line :slight_smile:

There is already a PR: Support complex numbers in eps by ChrisRackauckas · Pull Request #21858 · JuliaLang/julia · GitHub