ComplexValues

This package provides two additional types for representing complex values in Julia: a Polar type for representation in polar coordinates, and a Spherical type for representation on the Riemann sphere.

Prior to version 0.3, this package also provided some facility for making plots on the Riemann sphere. That capability (plus much more) now lies in the ComplexPlots package.

Usage notes

  • Either of the two new types can be converted to a built-in complex floating number via Complex.
  • Promotion of any number along with a Spherical value results in Spherical.
  • Promotion of any built-in number type with a Polar results in Polar.
  • Standard unary and binary functions in Base are extended to work with the new types.
  • The type AnyComplex{T<:AbstractFloat} is defined (but not exported) as the union of the built-in Complex{T} together with Polar{T} and Spherical{T}.

Examples

julia> using ComplexValues
julia> Polar(1im)Complex Polar: (modulus = 1.0, angle = 0.5⋅π)
julia> Polar.(exp.(1im*LinRange(0,2π,6)))6-element Vector{ComplexValues.Polar{Float64}}: Complex Polar: (modulus = 1.0, angle = 0.0⋅π) Complex Polar: (modulus = 1.0, angle = 0.4⋅π) Complex Polar: (modulus = 1.0, angle = 0.8⋅π) Complex Polar: (modulus = 1.0, angle = -0.8⋅π) Complex Polar: (modulus = 1.0, angle = -0.4⋅π) Complex Polar: (modulus = 1.0, angle = -1.4135798584282297e-16⋅π)
julia> Spherical(Inf)Complex Spherical: (latitude = 0.5⋅π, angle = 0.0⋅π)

A Spherical value can be converted to a 3-vector of coordinates on the unit sphere $S^2$.

julia> Spherical(0)Complex Spherical: (latitude = -0.5⋅π, angle = 0.0⋅π)
julia> S2coord(ans)3-element Vector{Float64}: 6.123233995736766e-17 0.0 -1.0