mirror of
https://github.com/apple/swift-numerics
synced 2026-11-29 05:24:24 +00:00
80-column formatting for source doc comments
Tidying, plus a few small edits. This commit should not include any code changes.
This commit is contained in:
1 parent
3cad9b69a0
commit
5827f9a943
7 files changed
+125
-85
No files matched your search
@@ -126,8 +126,8 @@ extension Complex: AlgebraicField {
|
||||
|
||||
/// A normalized complex number with the same phase as this value.
|
||||
///
|
||||
/// If such a value cannot be produced (because the phase of zero and infinity is undefined),
|
||||
/// `nil` is returned.
|
||||
/// If such a value cannot be produced (because the phase of zero and
|
||||
/// infinity is undefined), `nil` is returned.
|
||||
@inlinable
|
||||
public var normalized: Complex? {
|
||||
if length.isNormal {
|
||||
@@ -139,10 +139,12 @@ extension Complex: AlgebraicField {
|
||||
return self.divided(by: magnitude).normalized
|
||||
}
|
||||
|
||||
/// The reciprocal of this value, if it can be computed without undue overflow or underflow.
|
||||
/// The reciprocal of this value, if it can be computed without undue
|
||||
/// overflow or underflow.
|
||||
///
|
||||
/// If z.reciprocal is non-nil, you can safely replace division by z with multiplication by this value. It is
|
||||
/// not advantageous to do this for an isolated division, but if you are dividing many values by a single
|
||||
/// If z.reciprocal is non-nil, you can safely replace division by z with
|
||||
/// multiplication by this value. It is not advantageous to do this for an
|
||||
/// isolated division, but if you are dividing many values by a single
|
||||
/// denominator, this will often be a significant performance win.
|
||||
///
|
||||
/// Typical use looks like this:
|
||||
|
||||
@@ -163,9 +163,10 @@ extension Complex {
|
||||
|
||||
/// True if this value is normal.
|
||||
///
|
||||
/// A complex number is normal if it is finite and *either* the real or imaginary component is normal.
|
||||
/// A floating-point number representing one of the components is normal if its exponent allows a full-
|
||||
/// precision representation.
|
||||
/// A complex number is normal if it is finite and *either* the real or
|
||||
/// imaginary component is normal. A floating-point number representing
|
||||
/// one of the components is normal if its exponent allows a full-precision
|
||||
/// representation.
|
||||
///
|
||||
/// See also:
|
||||
/// -
|
||||
@@ -179,9 +180,10 @@ extension Complex {
|
||||
|
||||
/// True if this value is subnormal.
|
||||
///
|
||||
/// A complex number is subnormal if it is finite, not normal, and not zero. When the result of a
|
||||
/// computation is subnormal, underflow has occurred and the result generally does not have full
|
||||
/// precision.
|
||||
/// A complex number is subnormal if it is finite, not normal, and not zero.
|
||||
/// When the result of a computation is subnormal, underflow has occurred and
|
||||
/// the result generally does not have full precision.
|
||||
///
|
||||
/// See also:
|
||||
/// -
|
||||
/// - `.isFinite`
|
||||
@@ -194,7 +196,8 @@ extension Complex {
|
||||
|
||||
/// True if this value is zero.
|
||||
///
|
||||
/// A complex number is zero if *both* the real and imaginary components are zero.
|
||||
/// A complex number is zero if *both* the real and imaginary components
|
||||
/// are zero.
|
||||
///
|
||||
/// See also:
|
||||
/// -
|
||||
@@ -208,8 +211,8 @@ extension Complex {
|
||||
|
||||
/// The ∞-norm of the value (`max(abs(real), abs(imaginary))`).
|
||||
///
|
||||
/// If you need the Euclidean norm (a.k.a. 2-norm) use the `length` or `lengthSquared`
|
||||
/// properties instead.
|
||||
/// If you need the Euclidean norm (a.k.a. 2-norm) use the `length` or
|
||||
/// `lengthSquared` properties instead.
|
||||
///
|
||||
/// Edge cases:
|
||||
/// -
|
||||
@@ -240,8 +243,8 @@ extension Complex {
|
||||
/// This is mainly useful for interoperation with other languages, where
|
||||
/// you may want to reduce each equivalence class to a single representative
|
||||
/// before passing across language boundaries, but it may also be useful
|
||||
/// for some serialization tasks. It's also a useful implementation detail for
|
||||
/// some primitive operations.
|
||||
/// for some serialization tasks. It's also a useful implementation detail
|
||||
/// for some primitive operations.
|
||||
@_transparent
|
||||
public var canonicalized: Self {
|
||||
if isZero { return .zero }
|
||||
@@ -491,7 +494,8 @@ extension Complex {
|
||||
///
|
||||
/// Edge cases:
|
||||
/// -
|
||||
/// - Negative lengths are interpreted as reflecting the point through the origin, i.e.:
|
||||
/// - Negative lengths are interpreted as reflecting the point through the
|
||||
/// origin, i.e.:
|
||||
/// ```
|
||||
/// Complex(length: -r, phase: θ) == -Complex(length: r, phase: θ)
|
||||
/// ```
|
||||
|
||||
@@ -39,17 +39,19 @@ extension Complex: ElementaryFunctions {
|
||||
|
||||
// MARK: - exp-like functions
|
||||
|
||||
/// The complex exponential function e^z whose base `e` is the base of the natural logarithm.
|
||||
/// The complex exponential function e^z whose base `e` is the base of the
|
||||
/// natural logarithm.
|
||||
///
|
||||
/// Mathematically, this operation can be expanded in terms of the `Real` operations `exp`,
|
||||
/// `cos` and `sin` as follows:
|
||||
/// Mathematically, this operation can be expanded in terms of the `Real`
|
||||
/// operations `exp`, `cos` and `sin` as follows:
|
||||
/// ```
|
||||
/// exp(x + iy) = exp(x) exp(iy)
|
||||
/// = exp(x) cos(y) + i exp(x) sin(y)
|
||||
/// ```
|
||||
/// Note that naive evaluation of this expression in floating-point would be prone to premature
|
||||
/// overflow, since `cos` and `sin` both have magnitude less than 1 for most inputs (i.e.
|
||||
/// `exp(x)` may be infinity when `exp(x) cos(y)` would not be.
|
||||
/// Note that naive evaluation of this expression in floating-point would be
|
||||
/// prone to premature overflow, since `cos` and `sin` both have magnitude
|
||||
/// less than 1 for most inputs (i.e. `exp(x)` may be infinity when
|
||||
/// `exp(x) cos(y)` would not be).
|
||||
@inlinable
|
||||
public static func exp(_ z: Complex) -> Complex {
|
||||
guard z.isFinite else { return z }
|
||||
|
||||
Reference in new issue
Block a user