Skip to content

Commit e042c13

Browse files
Merge pull request #150 from markuswntr/master
Refactor README.md and include Approximate Equality as part of the RealModule.
2 parents 874c767 + 298ea7d commit e042c13

File tree

1 file changed

+57
-29
lines changed

1 file changed

+57
-29
lines changed

README.md

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,124 @@
11
# Swift Numerics
22

33
## Introduction
4+
45
Swift Numerics provides a set of modules that support numerical computing in Swift.
56
These modules fall broadly into two categories:
67

78
- API that is too specialized to go into the standard library, but which is sufficiently general to be centralized in a single common package.
89
- API that is under active development toward possible future inclusion in the standard library.
910

10-
There is some overlap between these two categories, and API that begins in the first category may migrate to the second as it matures and new uses are discovered.
11+
There is some overlap between these two categories, and an API that begins in the first category may migrate into the second as it matures and new uses are discovered.
12+
13+
Swift Numerics modules are fine-grained.
14+
For example, if you need support for Complex numbers, you can import ComplexModule¹ as a standalone module:
1115

12-
Swift Numerics modules are fine-grained; if you need support for Complex numbers, you can import ComplexModule¹ without pulling in everything else in the library as well:
1316
```swift
1417
import ComplexModule
1518

1619
let z = Complex<Double>.i
1720
```
18-
However, there is also a top-level `Numerics` module that simply re-exports the complete public interface of swift-numerics:
21+
22+
There is also a top-level `Numerics` module that re-exports the complete public interface of Swift Numerics:
23+
1924
```swift
2025
import Numerics
2126

22-
// All swift-numerics API is now available
27+
// The entire Swift Numerics API is now available
2328
```
2429

2530
Swift Numerics modules have minimal dependencies on other projects.
31+
2632
The current modules assume only the availability of the Swift and C standard libraries and the runtime support provided by compiler-rt.
27-
Future expansion may assume the availability of other standard interfaces such as [BLAS (Basic Linear Algebra Subprograms)](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) and [LAPACK (Linear Algebra Package)](https://en.wikipedia.org/wiki/LAPACK), but modules with more specialized dependencies (or dependencies that are not available on all platforms supported by Swift) belong in a separate package.
33+
34+
Future expansion may assume the availability of other standard interfaces, such as [BLAS (Basic Linear Algebra Subprograms)](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) and [LAPACK (Linear Algebra Package)](https://en.wikipedia.org/wiki/LAPACK), but modules with more specialized dependencies (or dependencies that are not available on all platforms supported by Swift) belong in a separate package.
2835

2936
Because we intend to make it possible to adopt Swift Numerics modules in the standard library at some future point, Swift Numerics uses the same license and contribution guidelines as the Swift project.
3037

3138
## Using Swift Numerics in your project
32-
To use Swift Numerics in a SwiftPM project, add the following line to the dependencies in your `Package.swift` file:
39+
40+
To use Swift Numerics in a SwiftPM project:
41+
42+
1. Add the following line to the dependencies in your `Package.swift` file:
43+
3344
```swift
34-
.package(url: "https://github.com/apple/swift-numerics", from: "0.0.5"),
45+
.package(url: "https://github.com/apple/swift-numerics", from: "0.0.7"),
3546
```
36-
add `Numerics` as a dependency for your target:
47+
48+
2. Add `Numerics` as a dependency for your target:
49+
3750
```swift
3851
.target(name: "MyTarget", dependencies: [
3952
.product(name: "Numerics", package: "swift-numerics"),
4053
"AnotherModule"
4154
]),
4255
```
43-
and finally, add `import Numerics` in your source code.
44-
56+
57+
3. Add `import Numerics` in your source code.
58+
4559
## Contributing to Swift Numerics
46-
Swift Numerics is a standalone library separate from the core Swift project.
47-
In practice, it will act as a staging ground for some APIs that may eventually be incorporated into the Swift Standard Library, and when that happens such changes will be proposed to the Swift Standard Library using the established evolution process of the Swift project.
60+
61+
Swift Numerics is a standalone library that is separate from the core Swift project, but it will sometimes act as a staging ground for APIs that will later be incorporated into the Swift Standard Library.
62+
When that happens, such changes will be proposed to the Swift Standard Library using the established evolution process of the Swift project.
4863

4964
Swift Numerics uses GitHub issues to track bugs and features. We use pull requests for development.
5065

51-
To propose a new module:
66+
### How to propose a new module
67+
5268
1. Raise an issue with the [new module] tag.
5369
2. Raise a PR with an implementation sketch.
5470
3. Once you have some consensus, ask an admin to create a feature branch against which PRs can be raised.
5571
4. When the design has stabilized and is functional enough to be useful, raise a PR to merge the new module to master.
5672

57-
To propose a new feature for an existing module:
73+
### How to propose a new feature for an existing module
74+
5875
1. Raise an issue with the [enhancement] tag.
5976
2. Raise a PR with your implementation, and discuss the implementation there.
6077
3. Once there is a consensus that the new feature is desirable and the design is suitable, it can be merged.
6178

62-
To fix a bug, or make smaller improvements:
63-
1. Raise a PR with your change. Be sure to add test coverage for whatever changes you are making.
79+
### How to fix a bug, or make smaller improvements
6480

65-
Questions about how to use Swift Numerics modules, or issues that are not clearly bugs can be discussed in the ["Swift Numerics" section of the Swift forums.](https://forums.swift.org/c/related-projects/swift-numerics)
81+
1. Raise a PR with your change.
82+
2. Make sure to add test coverage for whatever changes you are making.
83+
84+
### Forums
85+
86+
Questions about how to use Swift Numerics modules, or issues that are not clearly bugs can be discussed in the ["Swift Numerics" section of the Swift forums](https://forums.swift.org/c/related-projects/swift-numerics).
6687

6788
## Modules
68-
1. [RealModule](Sources/RealModule/README.md)
69-
2. [ComplexModule](Sources/ComplexModule/README.md)
89+
90+
1. [`RealModule`](Sources/RealModule/README.md)
91+
2. [`ComplexModule`](Sources/ComplexModule/README.md)
7092

7193
## Future expansion
72-
1. [Approximate Equality](https://github.com/apple/swift-numerics/issues/3)
73-
2. [Large Fixed-Width Integers](https://github.com/apple/swift-numerics/issues/4)
74-
3. [Arbitrary-Precision Integers](https://github.com/apple/swift-numerics/issues/5)
75-
4. [Shaped Arrays](https://github.com/apple/swift-numerics/issues/6)
76-
5. [Decimal Floating-point](https://github.com/apple/swift-numerics/issues/7)
94+
95+
1. [Large Fixed-Width Integers](https://github.com/apple/swift-numerics/issues/4)
96+
2. [Arbitrary-Precision Integers](https://github.com/apple/swift-numerics/issues/5)
97+
3. [Shaped Arrays](https://github.com/apple/swift-numerics/issues/6)
98+
4. [Decimal Floating-point](https://github.com/apple/swift-numerics/issues/7)
7799

78100
## Notes
101+
79102
¹ Swift is currently unable to use the fully-qualified name for types when a type and module have the same name (discussion here: https://forums.swift.org/t/pitch-fully-qualified-name-syntax/28482).
80-
This would prevent users of Swift Numerics who don't need generic types from doing things like:
103+
This would prevent users of Swift Numerics who don't need generic types from doing things such as:
104+
81105
```swift
82106
import Complex
83107
// I know I only ever want Complex<Double>, so I shouldn't need the generic parameter.
84-
typealias Complex = Complex.Complex<Double> // doesn't work, because name lookup fails.
108+
typealias Complex = Complex.Complex<Double> // This doesn't work, because name lookup fails.
85109
```
110+
86111
For this reason, modules that would have this ambiguity are suffixed with `Module` within Swift Numerics:
112+
87113
```swift
88114
import ComplexModule
89115
// I know I only ever want Complex<Double>, so I shouldn't need the generic parameter.
90116
typealias Complex = ComplexModule.Complex<Double>
91117
// But I can still refer to the generic type by qualifying the name if I need it occasionally:
92118
let a = ComplexModule.Complex<Float>
93119
```
94-
The `Real` module does not contain a `Real` type, but does contain a `Real` protocol, and users may want to define their own `Real` type (and possibly re-export the `Real` module), so the suffix is also applied there.
95-
New modules have to evaluate this decision carefully, but can err on the side of adding the suffix.
96-
It's expected that most users will simply `import Numerics`, so this isn't an issue for them.
120+
121+
The `Real` module does not contain a `Real` type, but does contain a `Real` protocol.
122+
Users may want to define their own `Real` type (and possibly re-export the `Real` module)--that is why the suffix is also applied there.
123+
New modules have to evaluate this decision carefully, but can err on the side of adding the suffix.
124+
It's expected that most users will simply `import Numerics`, so this isn't an issue for them.

0 commit comments

Comments
 (0)