Instead of being failable, adopt the following policy:
- If length is zero or infinity, the phase does not matter.
- Otherwise, the phase must be finite or a precondition failure occurs.
Discussion here: https://github.com/apple/swift-numerics/issues/51
No change to the protocols involved, purely a change so that the module that users import shares the name of the feature they are most likely to be using, rather than a somewhat-esoteric implementation detail.
Added some performance tests for multiply/divide, and some transparent annotations to the source where necessary for performance reasons. Additionally removed the Linux test information, since that's no longer necessary with test discovery in swiftpm.
Also added a new `var reciprocal: Self?` for Complex that allows for more efficient divisions when a divisor is used repeatedly, while avoiding the accuracy hazard of using `1/self` when a value is poorly scaled.
Previously we simply checked if the result of the naive divide was normal; this isn't quite right, because it could miss unsafeLengthSquared underflowing without going all the way to zero, resulting in significant loss of intermediate precision. Instead check if unsafeLengthSquared itself is non-normal. This is actually a cheaper check, and gets us everything we need, so it's a win-win.
Proof: if w.unsafeLengthSquared is normal, then so is w.conjugate.divided(by: unsafeLengthSquared), which means that we're left only with the multiply. Our goal is to be only as good as multiply is, so that's good enough.
Two modules to begin with:
- ElementaryFunctions
- Complex
Added README.md files describing each module very roughly, and a project
README to describe goals and process.