100 Commits
Author SHA1 Message Date
Stephen Canon eb58826429 Merge pull request #362 from charles-zablit/cz/cmake/cmp0157
[CMake] Require CMake 3.29 to enable CMP0157
2026-11-18 11:01:42 -05:00
Stephen Canon 669f618518 Merge pull request #360 from stephentyrone/use-builtin-module-for-builtins
Enable and include Builtin module to pickup fadd/fmul_relaxed.
2026-10-11 17:05:59 -04:00
Stephen Canon 20fe3d7d8e Merge pull request #358 from stephentyrone/adopt-builtin-relaxed-ops
Use BuiltinRelaxedFP ops instead of C shims when they're available.
2026-10-09 15:31:22 -04:00
Stephen Canon 69890e3639 Use BuiltinRelaxedFP ops instead of C shims when they're available.
There used to not be any way to attach reassociate or contract flags to fadd/fmul from Swift, which meant that we had to use inline C shims to accomplish this. But I added some Builtins to Swift, so now we don't need C to do this any longer.
2026-10-08 11:24:58 -04:00
Stephen Canon 8a65bea94b Merge pull request #336 from kkebo/fix-freebsd-tests
Skip Float80 overflow/underflow tests on FreeBSD
2026-10-08 11:15:15 -04:00
Stephen Canon 9f745b7c9b Merge pull request #355 from reginaldalfret/docs/approximate-equality
docs: add dedicated documentation for ApproximateEquality
2026-10-08 10:44:08 -04:00
Stephen Canon a7d826ead0 Merge pull request #352 from stephentyrone/fix-cosh-sinh-signs
Fix signs of cosh and sinh near the overflow boundary.
2026-09-10 10:53:41 -04:00
Stephen Canon 20a774f1a6 Merge pull request #351 from stephentyrone/recip-documentation
Relax documented behavior of Complex.reciprocal
2026-09-10 10:30:39 -04:00
Stephen Canon c2d05532d3 Fix signs of cosh and sinh near the overflow boundary.
Resovles https://github.com/apple/swift-numerics/issues/347
2026-09-10 10:27:51 -04:00
Stephen Canon 3b272b08af a word. 2026-09-10 10:09:49 -04:00
Stephen Canon bb7b69501f Relax documented behavior of Complex.reciprocal
In cases of underflow, multiplication by reciprocal may not be the same as division. Document this, rather than tightening the behavior, because it's still about as good as multiplication by reciprocal would be for a Real type.
2026-09-10 10:07:01 -04:00
Stephen Canon 738b0cdb23 Merge pull request #345 from kadyrbekovhamit-cyber/fix-rounding-documentation-examples
Replace nonexistent stochastic-rounding examples
2026-09-10 09:45:04 -04:00
Stephen Canon ee167adfea Merge pull request #350 from pkubaj/add-freebsd-ppc64
cmake: recognize FreeBSD powerpc64le/powerpc64 in get_swift_host_arch
2026-09-10 09:44:45 -04:00
Stephen Canon a6c13f7de8 Merge pull request #348 from kadyrbekovhamit-cyber/patch-2
Correct toNearestOrZero shift example
2026-09-10 09:44:24 -04:00
Stephen Canon 899af71c02 Merge pull request #328 from stephentyrone/complex-divide-docs
Added some notes on complex division.
2026-01-28 20:58:00 -05:00
Stephen Canon 178f513ce6 Merge pull request #316 from stephentyrone/enable-macos-github
Enable macos checks via github workflows.
2025-11-13 18:34:22 -05:00
Stephen Canon 3403d50630 Merge branch 'main' into enable-macos-github 2025-11-13 16:09:08 -05:00
Stephen Canon 167fe9b22a Merge pull request #332 from incertum/chore/workflow-permissions
chore: restrict GitHub workflow permissions - future-proof
2025-10-27 17:08:09 -04:00
Stephen Canon 18274b1caa Merge pull request #330 from ebariaux/main
Support Embedded Swift
2025-09-25 11:15:42 -04:00
Stephen Canon cbdb286797 Added some notes on complex division. 2025-08-20 19:18:41 -04:00
Stephen Canon be0d7c65d1 Merge pull request #325 from stephentyrone/enable-wasm-testing
Enable workflows testing for wasm.
2025-08-14 12:57:32 -04:00
Stephen Canon 5bfe9e16ce Remove relaxed add/mul for Float16 on wasm, as they cannot be defined. 2025-08-14 09:45:04 -04:00
Stephen Canon 46619b49ec Attempt to turn on workflows testing for wasm. 2025-08-14 09:40:35 -04:00
Stephen Canon 231815ea4b Merge pull request #324 from stephentyrone/disable-windows-5.9
Disable Swift 5.9 testing on Windows for now
2025-08-14 09:36:21 -04:00
Stephen Canon e74905c6d5 Disable Swift 5.9 testing on Windows for now
That docker image seems to be broken, so it's all false positives.
2025-08-14 09:08:40 -04:00
Stephen Canon a50d9575fe Merge pull request #265 from stephentyrone/docc-stuff
Documentation overhaul, including broad .docc adoption and organization.
2025-08-13 23:02:13 -04:00
Stephen Canon 1e94d23860 Cleanup further doc comment typos. 2025-08-13 14:37:51 -04:00
Stephen Canon b3fe4357f8 Fix typo. 2025-08-13 13:50:49 -04:00
Stephen Canon aa901641d1 Further docc improvements for RealModule.
This commit _also_ relaxes the constraint on Augmented algorithms from Real to FloatingPoint. It's worth calling out that fastTwoSum does not work with decimal floating-point types, so the unordered `Augemented.sum(_:_:)` now has a radix check and calls into the ordered twoSum function instead for Decimal. This makes more sense that a `BinaryFloatingPoint` constraint, as otherwise generic code written against Real or FloatingPoint would have to do the check at every call site.
2025-08-13 12:38:56 -04:00
Stephen Canon 2c19b7b8cd Last few review notes on complex. 2025-08-12 15:13:07 -04:00
Stephen Canon 221387985a Further review edits from Nate. 2025-08-12 15:04:11 -04:00
Stephen Canon 8b2fd7bbde Provide transliteration of Чебышёв. 2025-08-12 14:52:42 -04:00
Stephen Canon b43c10c1e3 Merge branch 'main' into docc-stuff 2025-08-12 13:23:02 -04:00
Stephen Canon 61a8b91b3e Some formatting cleanup around code blocks. 2025-08-12 13:20:29 -04:00
Stephen Canon 8c4747f116 Merge pull request #321 from stephentyrone/remove-2sum-assert
Remove precondition assert from Augmented.sum(large:small:)
2025-08-11 19:34:53 -04:00
Stephen Canon c3757dc266 Fix typo. (Thanks, Guillaume) 2025-08-11 19:33:27 -04:00
Stephen Canon d86286fc8b Remove precondition assert from Augmented.sum(large:small:)
This is potentially useful to identify some bugs, but there are also algorithms (notably Kahan summation) that can be written in terms of fast2sum but would fail this check. Rework documentation to account for the change.
2025-08-11 18:14:41 -04:00
Stephen Canon 9c548804c8 Massage docc files to make the Documentation check happier 2025-08-11 18:11:44 -04:00
Stephen Canon acbf4257ca Remove precondition assert from Augmented.sum(large:small:)
This is potentially useful to identify some bugs, but there are also algorithms (notably Kahan summation) that can be written in terms of fast2sum but would fail this check. Rework documentation to account for the change.
2025-08-11 18:09:22 -04:00
Stephen Canon 6ff93f255e Merge pull request #319 from lamtrinhdev/Fix_Typo_Issue
Correct typo issue at ApproximateEquality.swift
2025-08-09 20:18:34 -04:00
Stephen Canon af0352e8b1 Some additional organization for Complex docc. 2025-08-09 14:29:05 -04:00
Stephen Canon c1e6972eeb Merge pull request #315 from stephentyrone/algebraic-field-magnitude
Constrain AlgebraicField to required Magnitude:AlgebraicField
2025-08-08 17:17:28 -04:00
Stephen Canon 30074a3846 Enable macos checks via github workflows. 2025-08-08 13:55:13 -04:00
Stephen Canon da6c765795 Constrain AlgebraicField to required Magnitude:AlgebraicField
This is formally a source-breaking change. However it is expected to not be source-breaking in practice, because any conforming type either has a real magnitude (in the case of real or complex types), which would necessarily have to support all the AF operations to implement the type, or is perhaps a finite field with a bogus stand-in Magnitude.
2025-08-08 13:45:33 -04:00
Stephen Canon 2361b4959b Add overview for RealModule documentation. 2025-08-08 13:43:30 -04:00
Stephen Canon 264b17140b Merge pull request #314 from stephentyrone/relax-f16-x86
Restore relaxed mul/add bindings for Float16 on x86
2025-08-08 10:07:29 -04:00
Stephen Canon 5cc83cc00a WIP 2025-08-08 09:56:01 -04:00
Stephen Canon 5b34639450 Further documentation work for Complex. 2025-08-08 09:55:59 -04:00
Stephen Canon 450691764d typo. 2025-08-08 09:55:56 -04:00
Stephen Canon 95e9441f8c Changes from review feedback. 2025-08-08 09:55:54 -04:00
Stephen Canon d2f6811b87 More docc changes. 2025-08-08 09:55:47 -04:00
Stephen Canon 129e496ef1 Further docc work. 2025-08-08 09:55:46 -04:00
Stephen Canon 5d8425644a Initial work on docc setup. 2025-08-08 09:55:42 -04:00
Stephen Canon cd967fa90f Restore relaxed mul/add bindings for Float16 on x86
The ABI is stable, so these operations can be turned on.
2025-08-08 09:52:30 -04:00
Stephen Canon 6356eb395b Merge pull request #307 from j-hui/add-extern-c
Add extern "C" to shim header file
2025-05-28 15:27:45 -04:00
Stephen Canon 2b458e8aeb Merge pull request #305 from stephentyrone/remove-stochastic-rounding
Remove stochastic rounding mode
2025-04-10 11:51:13 -04:00
Stephen Canon 31fe14d084 Remove stochastic rounding mode
It's a useful operation, but it deserves its own API to allow the use of a custom random source.
Also, the existing API blocks some constant-folding operations because the call to the system random source is an opaque optimization barrier, so removing it allows us to produce better codegen for the other rounding modes.

We're also bumping required Swift version to 5.9, and removing the executable test targets for log/log1p, as they're really only useful for development of those algorithms.
2025-04-10 10:39:51 -04:00
Stephen Canon c327d04b01 Merge pull request #304 from stephentyrone/language-cleanup
s/sanity check/basic check/
2025-03-11 11:41:53 -04:00
Stephen Canon 9b36b1ce46 s/sanity check/basic check/ 2025-03-11 10:08:58 -04:00
Stephen Canon c4cc31ea95 Merge pull request #300 from stephentyrone/more-availability-fixes
Fix-up availability for Float16 in tests for tvOS and watchOS.
2025-03-04 14:21:48 -05:00
Stephen Canon 7b1e0db437 Fix-up availability for Float16 in tests for tvOS and watchOS. 2025-03-04 10:18:08 -05:00
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
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 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
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
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 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