Releases: apple/swift-numerics
We have the power
In earlier releases, Real.pow(Self, Int)
simply called through to libm_pow
. This is generally acceptable on platforms with a decent math library, but gets some cases wrong for Float
and Double
when the exponent is so large that it would be rounded in conversion to Self
.
For example, consider Float.pow(-1, 0x1000001)
. Since the exponent is odd, the result should be -1
, but when we simply called libm_pow(-1, Float(0x1000001))
, the exponent was rounded to an even number, and the result was 1
.
This behavior is fixed in this release; in particular the parity of integer exponents is always preserved, so that we will not have sign errors like above. There is still additional work to be done on the Real.pow
implementations--especially to provide better support for platforms with suspect math libraries--but this is a significant improvement to these operations.
Complex API cleanup
There are two significant API changes to the Complex module in this release:
-
The
unsafeLengthSquared
property has been renamedlengthSquared
, because--while it can overflow or underflow--the result is always well-defined, and therefore does not lead to memory unsafety. The old property is still present, marked unavailable, so you should get a useful renaming message from the compiler or your IDE. The old property will be removed after a period of time. -
The
Complex(length:phase:)
initializer has been made non-optional. Instead it is now a precondition that the length must be either zero or infinite if phase is not finite. Updating code to account for this change should be quite straightforward, because you are unlikely to have been using the paths that could return nil previously. If you have any questions, please ask for assistance on the forums.
Linux testing improvements
Adds an empty Tests/LinuxMain.swift to fix building on Linux, and directs users to --enable-test-discovery for testing on Linux.
Initial tag
I haven't yet formally defined the release policy for this repo, but it's useful for SPM workflows to have a tag exist, so I'm cutting 0.0.0 with the first few rounds of bug fixes and cleanups from open source contributors.
Thanks to everyone who has jumped to contribute!