@@ -208,7 +208,7 @@ extension Complex {
208208
209209 /// The ∞-norm of the value (`max(abs(real), abs(imaginary))`).
210210 ///
211- /// If you need the euclidean norm (a.k.a. 2-norm) use the `length` or `unsafeLengthSquared `
211+ /// If you need the euclidean norm (a.k.a. 2-norm) use the `length` or `lengthSquared `
212212 /// properties instead.
213213 ///
214214 /// Edge cases:
@@ -220,7 +220,7 @@ extension Complex {
220220 /// See also:
221221 /// -
222222 /// - `.length`
223- /// - `.unsafeLengthSquared `
223+ /// - `.lengthSquared `
224224 @_transparent
225225 public var magnitude : RealType {
226226 guard isFinite else { return . infinity }
@@ -394,13 +394,13 @@ extension Complex {
394394 /// See also:
395395 /// -
396396 /// - `.magnitude`
397- /// - `.unsafeLengthSquared `
397+ /// - `.lengthSquared `
398398 /// - `.phase`
399399 /// - `.polar`
400400 /// - `init(r:θ:)`
401401 @_transparent
402402 public var length : RealType {
403- let naive = unsafeLengthSquared
403+ let naive = lengthSquared
404404 guard naive. isNormal else { return carefulLength }
405405 return . sqrt( naive)
406406 }
@@ -419,7 +419,7 @@ extension Complex {
419419 ///
420420 /// This property is more efficient to compute than `length`, but is
421421 /// highly prone to overflow or underflow; for finite values that are
422- /// not well-scaled, `unsafeLengthSquared ` is often either zero or
422+ /// not well-scaled, `lengthSquared ` is often either zero or
423423 /// infinity, even when `length` is a finite number. Use this property
424424 /// only when you are certain that this value is well-scaled.
425425 ///
@@ -431,10 +431,13 @@ extension Complex {
431431 /// - `.length`
432432 /// - `.magnitude`
433433 @_transparent
434- public var unsafeLengthSquared : RealType {
434+ public var lengthSquared : RealType {
435435 x*x + y*y
436436 }
437437
438+ @available ( * , unavailable, renamed: " lengthSquared " )
439+ public var unsafeLengthSquared : RealType { lengthSquared }
440+
438441 /// The phase (angle, or "argument").
439442 ///
440443 /// Returns the angle (measured above the real axis) in radians. If
@@ -484,9 +487,9 @@ extension Complex {
484487 /// ```
485488 /// Complex(length: .zero, phase: θ) == .zero
486489 /// ```
487- /// - For any `θ`, even `.infinity` or `.nan`:
490+ /// - For any `θ`, even `.infinity` or `.nan`, if `r` is infinite then :
488491 /// ```
489- /// Complex(length: .infinity , phase: θ) == .infinity
492+ /// Complex(length: r , phase: θ) == .infinity
490493 /// ```
491494 /// - Otherwise, `θ` must be finite, or a precondition failure occurs.
492495 ///
@@ -501,8 +504,8 @@ extension Complex {
501504 self = Complex ( . cos( phase) , . sin( phase) ) . multiplied ( by: length)
502505 } else {
503506 precondition (
504- length == 0 || length == . infinity ,
505- " Either phase must be finite, or length must be zero or infinity . "
507+ length. isZero || length. isInfinite ,
508+ " Either phase must be finite, or length must be zero or infinite . "
506509 )
507510 self = Complex ( length)
508511 }
0 commit comments