Skip to content

Commit 119377c

Browse files
Merge pull request #99 from stephentyrone/algebraicField-should-be-signedNumeric
AlgebraicField should conform to SignedNumeric, not just Numeric.
2 parents a2aa24d + 016cd6a commit 119377c

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Sources/Complex/Arithmetic.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,3 @@ extension Complex: AlgebraicField {
165165
return nil
166166
}
167167
}
168-
169-
extension Complex: SignedNumeric {}

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 `AlgebraicField` (hence also `AdditiveArithmetic` and `Numeric`).
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 `SignedNumeric`).
1111

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

Sources/Real/AlgebraicField.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
/// A type modeling an algebraic [field]. Refines the `Numeric` protocol,
12+
/// A type modeling an algebraic [field]. Refines the `SignedNumeric` protocol,
1313
/// adding division.
1414
///
1515
/// A field is a set on which addition, subtraction, multiplication, and
@@ -40,11 +40,12 @@
4040
/// See Also:
4141
/// -
4242
/// - Real
43+
/// - SignedNumeric
4344
/// - Numeric
4445
/// - AdditiveArithmetic
4546
///
4647
/// [field]: https://en.wikipedia.org/wiki/Field_(mathematics)
47-
public protocol AlgebraicField: Numeric {
48+
public protocol AlgebraicField: SignedNumeric {
4849

4950
static func /=(a: inout Self, b: Self)
5051

Sources/Real/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ 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.
31+
The fourth protocol is `AlgebraicField`, which `Real` also refines.
32+
This protocol is a very small refinement of `SignedNumeric`, adding the `/` and `/=` operators and a `reciprocal` property.
3233
The primary use of this protocol is for writing code that is generic over real and complex types.
3334

3435
## Using Real

0 commit comments

Comments
 (0)