Skip to content

Commit 323542c

Browse files
committed
Add short notes to README docs on AlgebraicField.
1 parent 98f3d25 commit 323542c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Sources/Complex/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This module provides a `Complex` number type generic over an underlying `RealTyp
77
```
88
This module provides approximate feature parity and memory layout compatibility with C, Fortran, and C++ complex types (although the importer cannot map the types for you, buffers may be reinterpreted to shim API defined in other languages).
99

10-
The usual arithmetic operators are provided for Complex numbers, as well as conversion to and from polar coordinates and many useful properties, plus conformances to the obvious usual protocols: `Equatable`, `Hashable`, `Codable` (if the underlying `RealType` is), and `Numeric` (hence also `AdditiveArithmetic`).
10+
The usual arithmetic operators are provided for Complex numbers, as well as conversion to and from polar coordinates and many useful properties, plus conformances to the obvious usual protocols: `Equatable`, `Hashable`, `Codable` (if the underlying `RealType` is), and `AlgebraicField` (hence also `AdditiveArithmetic` and `Numeric`).
1111

1212
### Dependencies:
1313
- The `Real` module.

Sources/Real/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The `Real` module provides that API as a separate module so that you can use it
66

77
## Protocols and Methods
88

9-
The module defines three protocols. The most general is `ElementaryFunctions`, which makes the following functions available:
9+
The module defines four protocols. The most general is `ElementaryFunctions`, which makes the following functions available:
1010
- Exponential functions: `exp`, `expMinusOne`
1111
- Logarithmic functions: `log`, `log(onePlus:)`
1212
- Trigonometric functions: `cos`, `sin`, `tan`
@@ -28,6 +28,9 @@ The `RealFunctions` protocol refines `ElementaryFunctions`, and adds operations
2828
The protocol that you will use most often is `Real`, which describes a floating-point type equipped with the full set of basic math functions.
2929
This is a great protocol to use in writing generic code, because it has all the basics that you need to implement most numeric functions.
3030

31+
The fourth protocol is `AlgebraicField`, which `Real` also refines. This protocol is a very small refinement of `Numeric`, adding the `/` and `/=` operators and a `reciprocal` property.
32+
The primary use of this protocol is for writing code that is generic over real and complex types.
33+
3134
## Using Real
3235

3336
First, either import `Real` directly or import the `Numerics` umbrella module.
@@ -70,3 +73,4 @@ Not having this protocol is a significant missing feature for numerical computin
7073
[ErrorFunction]: https://en.wikipedia.org/wiki/Error_function
7174
[GammaFunction]: https://en.wikipedia.org/wiki/Gamma_function
7275
[SE-0246]: https://github.com/apple/swift-evolution/blob/master/proposals/0246-mathable.md
76+
[Sigmoid]: https://en.wikipedia.org/wiki/Sigmoid_function

0 commit comments

Comments
 (0)