This may lead to problems with nans. For example, 1.0/(0.0, 0.0) is (inf, nan), 
and 1.0/(inf,nan) is (0.0, nan); multiply by (1, im) yields (nan, nan), and all 
information is lost. With a proper treatment, this would be (0.0, 0.0) instead.

-erik

> On Jan 10, 2015, at 18:07 , Jiahao Chen <[email protected]> wrote:
> 
> Another possibility that occurs to me is to redefine the == equality 
> comparison. Currently this is defined as
> 
> ==(z::Complex, w::Complex) = (real(z) == real(w)) & (imag(z) == imag(w))
> 
> but for some purposes it may be sufficient to redefine this as
> 
> ==(z::Complex, w::Complex) = if isinf(z) && isinf(w)
>     return true
> else
>     return (real(z) == real(w)) & (imag(z) == imag(w))
> end
> 
> to model the topology of the Riemann sphere.
> 
> With this redefinition:
> 
> julia> Complex(Inf, 0.0) == Complex(Inf, NaN)
> true
> 
> julia> Complex(Inf, 0.0) == Complex(Inf, 2.0)
> true

--
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/

My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu/.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to