Julia's support for complex arithmetic is written purely in Julia, so I
don't see how my suggestion to implement a new type is necessarily slower
than hard-coding in special values indicating complex infinity. The code
branches that one would need would simply be put in different places. Are
there LLVM intrinsics and/or hardware support for complex arithmetic? The
story would be different if there are (and I don't think we use them
currently).

The normalization of all complex infinities is essentially provided by the
C9X proposal's cproj function (which uses Inf + 0.0im as the representation
of ComplexInf). However, the C9X proposal acknowledges that there are use
cases for both topologies and thus avoids recommending one or the other. To
quote:

"Two topologies are commonly used in complex mathematics: the complex plane
with its continuum of infinities and the Riemann sphere with its single
infinity. The complex plane is better suited for transcendental functions,
the Riemann sphere for algebraic functions. The complex types with their
multiplicity of infinities provide a useful (though imperfect) model for
the complex plane. The cproj function helps model the Riemann sphere by
mapping all infinities to one, and should be used just before any
operation, especially comparisons, that might give spurious results for any
of the other infinities."

In this proposal, the complex plane is clearly the more fundamental space.
The Riemann sphere cannot be worked with directly; one can only work with
the shadow of the Riemann sphere projected back onto the complex plane, one
particular projection of which is provided by cproj.

In contrast, it would be very Julian to represent the working topology with
types rather than explicitly forcing users to choose between the ordinary
complex plane and the Riemann sphere. The Riemann sphere would be a
first-class working algebra instead of being accessible indirectly via
cproj. The type model is also more composable, should there ever be a need
to intermix the two topologies.

The situation for zeros is less dire since they compare equal with ==,
whereas the various representations of complex infinity do not.

Thanks,

Jiahao Chen
Staff Research Scientist
MIT Computer Science and Artificial Intelligence Laboratory

Reply via email to