mirror of
https://github.com/apple/swift-numerics
synced 2026-11-24 04:38:11 +00:00
1.1 KiB
1.1 KiB
Complex
Topics
Real and imaginary parts
A Complex value is represented with two RealType values, corresponding to
the real and imaginary parts of the number:
let z = Complex(1,-1) // 1 - i
let re = z.real // 1
let im = z.imaginary // -1
All Complex numbers with a non-finite component is treated as a single
"point at infinity," with infinite magnitude and indeterminant phase. Thus,
the real and imaginary parts of an infinity are nan.
let w = Complex<Double>.infinity
w == -w // true
let re = w.real // .nan
let im = w.imag // .nan
See doc:Infinity for more details.
init(_:_:)init(_:)-5aesjinit(imaginary:)realimaginary
Magnitude and norms
See the article doc:Magnitude for more details.
magnitudelengthlengthSquarednormalized
Polar representations
init(length:phase:)phaselengthpolar
Conversions from other types
init(_:)-4csd3init(_:)-80jmlinit(exactly:)-767k9