File tree Expand file tree Collapse file tree 2 files changed +19
-30
lines changed
Sources/ComplexModule/Documentation.docc Expand file tree Collapse file tree 2 files changed +19
-30
lines changed Original file line number Diff line number Diff line change 11# `` Complex ``
22
3- ## Topics
4-
5- ### Real and imaginary parts
3+ ## Real and imaginary parts
64
75A ` Complex ` value is represented with two ` RealType ` values, corresponding to
86the real and imaginary parts of the number:
@@ -13,7 +11,7 @@ let re = z.real // 1
1311let 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,
1816the real and imaginary parts of an infinity are nan.
1917
@@ -26,30 +24,9 @@ let im = w.imag // .nan
2624
2725See < 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.
Original file line number Diff line number Diff line change @@ -72,3 +72,15 @@ let b = 2*a
7272operation, ` 2*a ` would either be ambiguous (if there were no type context),
7373or be inferred to have type ` Complex<Double> ` (if the expression appeared
7474in 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 ` / ` .
You can’t perform that action at this time.
0 commit comments