Add missing complex tests and rules#216
Conversation
|
The one failure on Julia 1.4.2 is odd. |
|
Hmm yeah, that is very strange... checking for approximate equality is fine though imho. |
| @inline _realconjtimes(x, y) = real(conj(x) * y) | ||
| @inline _realconjtimes(x::Complex, y::Complex) = real(x) * real(y) + imag(x) * imag(y) | ||
| @inline _realconjtimes(x::Real, y::Complex) = x * real(y) | ||
| @inline _realconjtimes(x::Complex, y::Real) = real(x) * y | ||
| @inline _realconjtimes(x::Real, y::Real) = x * y | ||
|
|
||
| # imag(conj(x) * y) avoiding computing the real part if possible | ||
| @inline _imagconjtimes(x, y) = imag(conj(x) * y) | ||
| @inline _imagconjtimes(x::Complex, y::Complex) = -imag(x) * real(y) + real(x) * imag(y) | ||
| @inline _imagconjtimes(x::Real, y::Complex) = x * imag(y) | ||
| @inline _imagconjtimes(x::Complex, y::Real) = -imag(x) * y | ||
| @inline _imagconjtimes(x::Real, y::Real) = Zero() |
There was a problem hiding this comment.
should these all be AbstractComplex ?
There was a problem hiding this comment.
I don't think there is an AbstractComplex in base.
|
Okay this should be ready for review. @MasonProtter I ended up simplifying the rules for |
|
Looks good to me! |
willtebbutt
left a comment
There was a problem hiding this comment.
Minor style thing. Otherwise LGTM
Co-authored-by: willtebbutt <wt0881@my.bristol.ac.uk>
This PR fixes #215 by adding missing complex tests and where necessary generalizing rules and adding missing rules. New rules are
adjoint(::Number)real(::Number)imag(::Complex)Complex(::Number)Complex(::Number, ::Number)hypot(::Complex)hypot(::T, ::T) where T<:Union{Real,Complex}exp(::Number)It also simplifies the rules for
abs,angle, andsignwith shared utility functions.I believe as of this PR, all scalar functions in Base for which we have complex rules should be tested on complex inputs.