Skip to content

Commit e77a36a

Browse files
committed
Further documentation work for Complex.
1 parent 3dbee65 commit e77a36a

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed
Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# ``Complex``
22

3-
## Topics
4-
5-
### Real and imaginary parts
3+
## Real and imaginary parts
64

75
A `Complex` value is represented with two `RealType` values, corresponding to
86
the real and imaginary parts of the number:
@@ -13,7 +11,7 @@ let re = z.real // 1
1311
let im = z.imaginary // -1
1412
```
1513

16-
All `Complex` numbers with a non-finite component is treated as a single
14+
All `Complex` numbers with a non-finite component are treated as a single
1715
"point at infinity," with infinite magnitude and indeterminant phase. Thus,
1816
the real and imaginary parts of an infinity are nan.
1917

@@ -26,30 +24,9 @@ let im = w.imag // .nan
2624

2725
See <doc:Infinity> for more details.
2826

29-
- ``init(_:_:)``
30-
- ``init(_:)-5aesj``
31-
- ``init(imaginary:)``
32-
- ``real``
33-
- ``imaginary``
34-
35-
### Magnitude and norms
36-
37-
See the article <doc:Magnitude> for more details.
38-
39-
- ``magnitude``
40-
- ``length``
41-
- ``lengthSquared``
42-
- ``normalized``
43-
44-
### Polar representations
45-
46-
- ``init(length:phase:)``
47-
- ``phase``
48-
- ``length``
49-
- ``polar``
50-
51-
### Conversions from other types
27+
### Length and magnitude
5228

53-
- ``init(_:)-4csd3``
54-
- ``init(_:)-80jml``
55-
- ``init(exactly:)-767k9``
29+
The ``magnitude`` property of a complex number is the infinity norm of the
30+
value (a.k.a. “maximum norm” or “Чебышёв norm”). To get the two norm (a.k.a
31+
"Euclidean norm"), use the ``length`` property. See <doc:Magnitude> for more
32+
details.

Sources/ComplexModule/Documentation.docc/ComplexModule.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,15 @@ let b = 2*a
7272
operation, `2*a` would either be ambiguous (if there were no type context),
7373
or be inferred to have type `Complex<Double>` (if the expression appeared
7474
in the context of an extension defined on `Complex`).
75+
76+
Note that we _do_ provide heterogeneous multiplication and division by a real
77+
value, spelled as ``Complex/divided(by:)`` and ``Complex/multiplied(by:)``
78+
to avoid ambiguity.
79+
80+
```swift
81+
let z = Complex<Double>(1,3)
82+
let w = z.multiplied(by: 2)
83+
```
84+
85+
These operations are generally more efficient than converting the scale to
86+
a complex number and then using `*` or `/`.

0 commit comments

Comments
 (0)