Commit Graph
445 Commits
Author SHA1 Message Date
Stephen Canon e30276bff2 Merge pull request #297 from stephentyrone/floating-point-rounding
Make all (IntegerUtilities) rounding rules available to FloatingPoint
2024-08-15 12:06:06 -04:00
Stephen Canon ddc8ce302b Make all rounding rules (from IntegerUtilities) available on FloatingPoint
IntegerUtilities has RoundingRule that is a superset of FloatingPointRoundingRule; many of these are also useful when working with floating-point. This change provides a `rounding(_:)` function similar to the standard libraries `rounded(_:)` that makes all of them available. It has a different name instead of being a shadow because otherwise existing use sites like `rounded(.down)` would become ambiguous.
2024-08-15 11:58:38 -04:00
Stephen Canon b5adc8c39b Merge pull request #296 from stephentyrone/round-out-rounding
Add new rounding modes: toNearestOr[Down,Up,Zero,Away]
2024-07-20 08:10:52 -04:00
Stephen Canon 683c8f210a Cleanup and bug fix for wide stochastic rounding path. 2024-07-19 21:42:54 -04:00
Stephen Canon c69fea9be8 Remove Int128 tests for now
Most people are not yet using a toolchain with support for Int128; we'll re-enable these when we bump the baseline to Swift 6.0
2024-07-19 16:15:50 -04:00
Stephen Canon 3ee07816b2 Add new rounding modes: toNearestOr[Down,Up,Zero,Away]
These were omitted in the first pass over integer rounding rules, but are generally useful and make good sense to have available. In particular, toNearestOrUp is the natural mode for a lot of fixed-point arithmetic, and frequently has HW support on SIMD units, so it makes good sense to have a name for that. Once you add that, having nearestOrDown also makes sense, and then nearestOrZero should exist by analogy to nearestOrAway. Also beefed up testing and refactored the division rounding code somewhat.
2024-07-19 16:12:55 -04:00
Stephen Canon 53afff107a Merge pull request #295 from stephentyrone/double-width-improvements
Improvements and bugfixes for DoubleWidth
2024-07-12 14:00:55 -04:00
Stephen Canon 1043e9ed38 Improvements and bugfixes for DoubleWidth prototype
These are used only in TestSupport, but it's still nice to get them right. Signed types had a long-standing bug in how overflow was computed for multiplication, and masking shifts would do the wrong thing when the bitwdith was not a power of two and the shift count was negative. I also added implementations of &*, &+, and &-.
2024-07-12 13:30:13 -04:00
Stephen Canon e7af7dffbc Merge pull request #294 from stephentyrone/fixup-file-headers
Some file headers have the Swift.org text instead of Swift Numerics
2024-07-01 12:51:51 -04:00
Stephen Canon da661919b9 Fixup some file headers that had the Swift.org text instead of Swift Numerics
These are a copy-pasto from introduced when I originally imported approximate equality (which was originally proposed for the standard library).
2024-07-01 12:46:42 -04:00
Stephen Canon 6deae1b98f Merge pull request #292 from futurejones/add-riscv64-support
add support for riscv64
2024-07-01 09:40:22 -04:00
Neil Jones 155cfc306c add support for riscv64 2024-06-17 14:48:24 +09:00
Stephen Canon 877fd0aa9a Merge pull request #289 from stephentyrone/rework-complex-division
Replaces the rescaling algorithm for Complex division to one inspired by Doug Priest's "Efficient Scaling for Complex Division," with some further tweaks to:

- allow it to work for arbitrary FloatingPoint types, including Float16
- get exactly the same rounding behavior as the un-rescaled path, so that z/w = tz/tw when tz and tw are computed exactly.
- allow future optimizations to hoist a rescaled reciprocal for more speedups.

Unlike Priest, we do not try to avoid spurious overflow in the final computation when the result is very near the overflow boundary but cancellation brings us just inside it. We do not believe that this is a good tradeoff, as complex multiplication overflows in exactly the same way. We will investigate providing opt-in API to avoid this overflow case in a future PR.
2024-05-16 22:24:22 -04:00
Stephen Canon 262cbea1f2 review feedback. 2024-05-16 22:12:24 -04:00
Stephen CanonandGuillaume Lessard 84c41a0bef Update Sources/ComplexModule/Complex+AlgebraicField.swift
Co-authored-by: Guillaume Lessard <glessard@tffenterprises.com>
2024-05-16 19:46:17 -04:00
Stephen Canon a883d95a4d Fixup guard on Float16 Complex divide tests. 2024-05-16 15:50:32 -04:00
Stephen Canon 3d6de9f3ef Reworked complex divide scaling. 2024-05-16 15:44:11 -04:00
Stephen Canon 3fa18ae9b5 Test improvements
Improved how tolerance is applied close to infinity for complex division
(this still could use a more principled approach, but at least we're in
the right ballpark now). Tightened up the tolerance for semi-exhaustive
testing too, since that can be done now.
2024-05-16 08:39:12 -04:00
Stephen Canon 1ba2178227 Further progress on complex division 2024-05-14 17:22:50 -04:00
Steve Canon 97bab250eb WIP 2024-05-14 10:24:31 -04:00
Stephen Canon ab63ebd7b2 Merge pull request #286 from stephentyrone/drop-support-5.4
Drop support for Swift <= 5.4 on main
2024-04-19 21:27:05 -04:00
Stephen Canon 347f1e31fe Drop support for Swift < 5.4 on main
5.4 will continue to be supported on 1.0.x if needed.
2024-04-19 21:07:58 -04:00
Stephen Canon fa7db5761d Merge pull request #285 from stephentyrone/euclidean-gcd
Adopt the Euclidean algorithm for GCD.
2024-04-19 21:07:03 -04:00
Stephen Canon 907430bdad Adopt the Euclidean algorithm for GCD. 2024-04-19 20:54:57 -04:00
Stephen Canon 57ad9c588b Merge pull request #278 from compnerd/patch-1
Update CMakeLists.txt
2024-04-15 10:43:05 -04:00
Stephen Canon 05a3ee869f Merge pull request #280 from MaxDesiatov/patch-1
Remove unused `LinuxMain.swift` and `WindowsMain.swift`
2024-04-15 10:07:12 -04:00
Max Desiatov 4e905b38b7 Update CMakeLists.txt 2024-03-04 15:49:27 +00:00
Max Desiatov 43e0f5b026 Delete Tests/CMakeLists.txt 2024-03-04 15:49:07 +00:00
Max Desiatov 0599b610d9 Delete Tests/LinuxMain.swift 2024-03-04 14:24:44 +00:00
Max Desiatov 2fae6a86e3 Remove unused LinuxMain.swift and WindowsMain.swift
These files are no longer needed, as `swift test` enables test discovery by default.
2024-03-04 14:24:17 +00:00
Saleem Abdulrasool faa65e8842 Update CMakeLists.txt
Use `PROJECT_SOURCE_DIR` to allow embedding within larger projects. `CMAKE_SOURCE_DIR` is the root of the source tree, where as `PROJECT_SOURCE_DIR` is the directory of the current project.
2024-01-31 18:44:16 -08:00
Stephen Canon 0111e791a1 Merge pull request #274 from stephentyrone/link-real-libm-linux
Move the -lm link command to RealModule (from _NumericsShims).
2023-12-10 17:09:03 -05:00
Stephen Canon 1883189574 Merge pull request #273 from xwu/toil-and-trouble
[_TestSupport] Fix DoubleWidth think-o that trips an assert
2023-11-30 10:59:41 -05:00
Stephen Canon e8a3ddbb3e Move the -lm link command to RealModule (from _NumericsShims).
Hopefully this resolves some niche link errors that we've seen sporadically.
2023-11-30 09:27:03 -05:00
Xiaodi Wu a7e27e16e1 [_TestSupport] Fix DoubleWidth think-os harder 2023-11-13 15:42:07 -05:00
Xiaodi Wu a0d66e1537 [_TestSupport] Fix DoubleWidth think-os 2023-11-13 15:41:52 -05:00
Stephen Canon 182c9b246b Merge pull request #271 from stephentyrone/none-some
Replace `some BinaryInteger` with an explicit generic parameter.
2023-09-29 14:34:06 -04:00
Stephen Canon b3867a9155 Replace some BinaryInteger with an explicit generic parameter.
For compatibility with pre-Swift-5.7 language versions.
2023-09-28 15:31:25 -04:00
Stephen Canon 470e4236ff Merge pull request #269 from stephentyrone/enable-spi
Add .spi.yml file to build documentation for SPI.
2023-09-20 09:56:49 -04:00
Stephen Canon 3d13ebaf94 Add .spi.yml file to build documentation for SPI. 2023-09-20 09:55:35 -04:00
Stephen Canon 485c60c6c4 Merge pull request #268 from stephentyrone/fix-tvOS-availability
Correct tvOS availability for Float16 in _TestSupport.
2023-09-20 09:52:12 -04:00
Stephen Canon b38fcb77a6 Correct tvOS availability for Float16 in _TestSupport. 2023-09-20 09:44:53 -04:00
Stephen Canon 716e22fd64 Merge pull request #218 from stephentyrone/saturating-arithmetic
Implement saturating arithmetic on FixedWidthInteger
2023-04-29 10:02:32 -04:00
Stephen Canon 35e15a381f Additional comment fixes from Guillaume 2023-04-28 22:31:31 -04:00
Stephen CanonandGuillaume Lessard bc9f6e7368 Update Sources/IntegerUtilities/ShiftWithRounding.swift
Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>
2023-04-28 22:29:25 -04:00
Stephen CanonandGuillaume Lessard ef6dbc6e78 Update Sources/IntegerUtilities/ShiftWithRounding.swift
Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>
2023-04-28 22:29:13 -04:00
Stephen Canon 0bb0a9acff Only run benchmarks in Release, they're meaningless in Debug. 2023-04-28 14:36:57 -04:00
Stephen Canon d59ec36291 Only run benchmarks in Release, they're meaningless in Debug. 2023-04-28 14:36:40 -04:00
Stephen Canon a118de9878 Polish README.md 2023-04-28 13:58:37 -04:00
Stephen Canon 58f4e72d8a Documentation improvements. 2023-04-28 13:34:53 -04:00