Minor documentation formatting cleanup.

This commit is contained in:
Stephen Canon committed 2022-04-06 11:50:25 -04:00
1 parent b6018fa8a9
commit 270972dd8a
10 files changed
+75 -258

No files matched your search

@@ -111,7 +111,7 @@ extension Complex: AlgebraicField {
/// ```
///
/// Error Bounds:
/// -
///
/// Unlike real types, when working with complex types, multiplying by the
/// reciprocal instead of dividing cannot change the result. If the
/// reciprocal is non-nil, the two computations are always equivalent.
+1 -3
View File
@@ -47,9 +47,7 @@ extension Complex: Numeric {
/// - If `z` is zero, `z.magnitude` is `0`.
/// - Otherwise, `z.magnitude` is finite and non-zero.
///
/// See also:
/// - `.length`
/// - `.lengthSquared`
/// See also `.length` and `.lengthSquared`.
@_transparent
public var magnitude: RealType {
guard isFinite else { return .infinity }
+7 -29
View File
@@ -16,7 +16,7 @@ import RealModule
/// TODO: introductory text on complex numbers
///
/// Implementation notes:
/// -
///
/// This type does not provide heterogeneous real/complex arithmetic,
/// not even the natural vector-space operations like real * complex.
/// There are two reasons for this choice: first, Swift broadly avoids
@@ -105,11 +105,7 @@ extension Complex {
extension Complex {
/// The imaginary unit.
///
/// See also:
/// -
/// - .zero
/// - .one
/// - .infinity
/// See also `.zero`, `.one` and `.infinity`.
@_transparent
public static var i: Complex {
Complex(0, 1)
@@ -117,11 +113,7 @@ extension Complex {
/// The point at infinity.
///
/// See also:
/// -
/// - .zero
/// - .one
/// - .i
/// See also `.zero`, `.one` and `.i`.
@_transparent
public static var infinity: Complex {
Complex(.infinity, 0)
@@ -131,11 +123,7 @@ extension Complex {
///
/// A complex value is finite if neither component is an infinity or nan.
///
/// See also:
/// -
/// - `.isNormal`
/// - `.isSubnormal`
/// - `.isZero`
/// See also `.isNormal`, `.isSubnormal` and `.isZero`.
@_transparent
public var isFinite: Bool {
x.isFinite && y.isFinite
@@ -148,10 +136,7 @@ extension Complex {
/// one of the components is normal if its exponent allows a full-precision
/// representation.
///
/// See also:
/// - `.isFinite`
/// - `.isSubnormal`
/// - `.isZero`
/// See also `.isFinite`, `.isSubnormal` and `.isZero`.
@_transparent
public var isNormal: Bool {
isFinite && (x.isNormal || y.isNormal)
@@ -163,10 +148,7 @@ extension Complex {
/// When the result of a computation is subnormal, underflow has occurred and
/// the result generally does not have full precision.
///
/// See also:
/// - `.isFinite`
/// - `.isNormal`
/// - `.isZero`
/// See also `.isFinite`, `.isNormal` and `.isZero`.
@_transparent
public var isSubnormal: Bool {
isFinite && !isNormal && !isZero
@@ -177,11 +159,7 @@ extension Complex {
/// A complex number is zero if *both* the real and imaginary components
/// are zero.
///
/// See also:
/// -
/// - `.isFinite`
/// - `.isNormal`
/// - `.isSubnormal`
/// See also `.isFinite`, `.isNormal` and `isSubnormal`.
@_transparent
public var isZero: Bool {
x == 0 && y == 0
+10 -34
View File
@@ -31,16 +31,10 @@ extension Complex {
/// a representable result.
///
/// Edge cases:
/// -
/// If a complex value is not finite, its `.length` is `infinity`.
/// - If a complex value is not finite, its `.length` is `infinity`.
///
/// See also:
/// -
/// - `.magnitude`
/// - `.lengthSquared`
/// - `.phase`
/// - `.polar`
/// - `init(r:θ:)`
/// See also `.magnitude`, `.lengthSquared`, `.phase`, `.polar`
/// and `init(r:θ:)`.
@_transparent
public var length: RealType {
let naive = lengthSquared
@@ -69,10 +63,7 @@ extension Complex {
/// For many cases, `.magnitude` can be used instead, which is similarly
/// cheap to compute and always returns a representable value.
///
/// See also:
/// -
/// - `.length`
/// - `.magnitude`
/// See also `.length` and `.magnitude`.
@_transparent
public var lengthSquared: RealType {
x*x + y*y
@@ -88,14 +79,9 @@ extension Complex {
/// and `nan` is returned.
///
/// Edge cases:
/// -
/// If the complex value is zero or non-finite, phase is `nan`.
/// - If the complex value is zero or non-finite, phase is `nan`.
///
/// See also:
/// -
/// - `.length`
/// - `.polar`
/// - `init(r:θ:)`
/// See also `.length`, `.polar` and `init(r:θ:)`.
@inlinable
public var phase: RealType {
guard isFinite && !isZero else { return .nan }
@@ -105,15 +91,10 @@ extension Complex {
/// The length and phase (or polar coordinates) of this value.
///
/// Edge cases:
/// -
/// If the complex value is zero or non-finite, phase is `.nan`.
/// If the complex value is non-finite, length is `.infinity`.
/// - If the complex value is zero or non-finite, phase is `.nan`.
/// - If the complex value is non-finite, length is `.infinity`.
///
/// See also:
/// -
/// - `.length`
/// - `.phase`
/// - `init(r:θ:)`
/// See also: `.length`, `.phase` and `init(r:θ:)`.
public var polar: (length: RealType, phase: RealType) {
(length, phase)
}
@@ -121,7 +102,6 @@ extension Complex {
/// Creates a complex value specified with polar coordinates.
///
/// Edge cases:
/// -
/// - Negative lengths are interpreted as reflecting the point through the
/// origin, i.e.:
/// ```
@@ -137,11 +117,7 @@ extension Complex {
/// ```
/// - Otherwise, `θ` must be finite, or a precondition failure occurs.
///
/// See also:
/// -
/// - `.length`
/// - `.phase`
/// - `.polar`
/// See also `.length`, `.phase` and `.polar`.
@inlinable
public init(length: RealType, phase: RealType) {
if phase.isFinite {