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 1
1
# `` Complex ``
2
2
3
- ## Topics
4
-
5
- ### Real and imaginary parts
3
+ ## Real and imaginary parts
6
4
7
5
A ` Complex ` value is represented with two ` RealType ` values, corresponding to
8
6
the real and imaginary parts of the number:
@@ -13,7 +11,7 @@ let re = z.real // 1
13
11
let im = z.imaginary // -1
14
12
```
15
13
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
17
15
"point at infinity," with infinite magnitude and indeterminant phase. Thus,
18
16
the real and imaginary parts of an infinity are nan.
19
17
@@ -26,30 +24,9 @@ let im = w.imag // .nan
26
24
27
25
See < doc:Infinity > for more details.
28
26
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
52
28
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
72
72
operation, ` 2*a ` would either be ambiguous (if there were no type context),
73
73
or be inferred to have type ` Complex<Double> ` (if the expression appeared
74
74
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 ` / ` .
You can’t perform that action at this time.
0 commit comments