Commit Graph
161 Commits
Author SHA1 Message Date
Gwynne Raskind 349fdf1e01 Add preliminary version of BigUInt 2023-12-26 11:12:49 -06:00
Gwynne Raskind 1c90bdc9a9 Merge branch 'main' into biginteger 2023-12-25 22:31:33 -06: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 d59ec36291 Only run benchmarks in Release, they're meaningless in Debug. 2023-04-28 14:36:40 -04:00
Stephen Canon fe151134b0 Further saturating arithmetic test and implementation cleanups 2023-04-27 16:19:40 -04:00
Stephen Canon f00824e9fa More tests for saturating arithmetic -- exhaustive sampling of [U]Int8 arguments. 2023-04-26 21:50:23 -04:00
Stephen Canon 4779aef990 Test coverage for saturating shift + fix the bug that it turned up. 2023-04-26 21:20:57 -04:00
Stephen Canon 740cc5012f Some cleanups to relaxed arithmetic. 2023-04-26 09:05:28 -04:00
Stephen Canon 9a23fdf1c9 Fewer iterations for debug; more for release. 2023-04-26 08:56:43 -04:00
Stephen Canon 79390164f5 CMake support for newer tests. 2023-04-26 08:56:43 -04:00
Stephen Canon 9c0332d570 Initial pass at "relaxed" multiply and add operations.
This commit adds the following to the RealFunctions protocol:

    static func _relaxedAdd(_:Self, _:Self) -> Self
    static func _relaxedMul(_:Self, _:Self) -> Self

These are equivalent to + and *, but have "relaxed semantics"; specifically, they license the compiler to reassociate them and to form FMA nodes, which are both significant optimizations that can easily make many common loops 8-10x faster. These transformation perturb results slightly, so they should not be enabled without care, but the results with the relaxed operations are--for most purposes--"just as good as" (and often better than) what strict operations produce. The main thing to beware of is that they are no longer portable; different compiler versions and different targets and optimization flags will result in different results.

They are underscored because they are not stable API. In particular:
- `RealFunctions` is not really the right protocol for these (and neither is `Real`). I need to do some thinking about where to attach them.
- Even if it were the right protocol, these are more like implementation hooks than the API I really want people to use (TBD).
- I like "relaxed" more than other commonly used idioms ("fast"), but I'm not sure it's the name I ultimately want.
2023-04-26 08:56:43 -04:00
Stephen Canon f11ce9b248 Merge branch 'biginteger' into BigInt 2022-10-28 15:39:47 -04:00
Stephen Canon 60a3edbaa9 Further improvement to Complex.pow(_:Self,_:Self) edge cases.
Bring pow(zero, w) in line with the behavior of pow for the underlying real type.
2022-09-17 14:56:29 -04:00
Stephen Canon 2baff8fc30 Also fixup real edge cases for pow(0,0). 2022-09-15 16:10:17 -04:00
Stephen Canon b9e8b970f2 Fixup indentation. 2022-09-15 15:39:34 -04:00
Stephen Canon d34f5636c4 Fix the edge-case handling of Complex.pow(.zero, <int>) 2022-09-15 15:07:06 -04:00
Stephen Canon 027bcc5b8e Remove conformance of Complex to Differentiable
The conformance was breaking CI testing, because the CI bots use a macOS version that predates availability of the _Differentiation module, and the compiler-generated differentation operations have neither availability attributes nor checks, so any reference to those operations simply crashes in dyld because the library is not present. We can add availability, but that's not really accurate either, because these operations are not actually binary-stable, so while we wouldn't crash in dyld, we also might not work correctly in the future. We could mark them unavailable on Apple platforms, but that's also not quite right (and further means that they're not going to get a lot of attention). The best solution seems to be to remove the conformance (which was never source-stable).
2022-04-06 14:41:04 -04:00
Stephen Canon 27f8192a63 Attempt to work around CI misconfiguration by removing Complex Differentiable conformance. 2022-04-06 09:58:40 -04:00
Stephen Canon c4f8886a11 Move baseline supported tools version to 5.4. 2022-03-05 10:18:13 -05:00
Stephen Canon 47a233758d Use DoubleWidth in stochastic rounding right-shift tests.
This lets us get rid of Double here, and get more meaningful test coverage for 64b values. Also test 128b to cover double-width itself somewhat.
2021-11-24 11:35:40 -05:00
Stephen Canon b501ca406c Merge pull request #197 from benrimmington/experimental
Add the `DoubleWidth` type
2021-10-27 15:48:29 -04:00
be0534a3e3 Add the DoubleWidth type
Co-authored-by: Nate Cook <natecook@apple.com>
Co-authored-by: Max Moiseev <moiseev@users.noreply.github.com>
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2021-10-27 18:14:10 +01:00
Stephen Canon c74d817e8d Merge pull request #208 from markuswntr/two-sum
Add `Augmented.sum(_:_:)` aka "twoSum"
2021-10-27 12:27:16 -04:00
Markus Winter d4a440fd05 Update range of random values in test cases 2021-10-26 16:27:04 +02:00
Markus Winter f6e5563514 Fix argument ordering in twoSum and add test cases 2021-10-26 15:57:30 +02:00
Stephen Canon 24d8f51bb3 Add tests for remainder(dividingBy: -1). 2021-10-14 10:39:39 -04:00
Stephen Canon 3eaa0b3b77 Additional documentation for division/shift with rounding
Also simplifies check logic for divide with rounding, which is a modest speedup for testing.
2021-10-13 16:44:52 -04:00
Stephen Canon 710ca088d5 Renamed shifted(right:) to shifted(rightBy:). 2021-10-13 11:08:09 -04:00
Stephen Canon 501f58252a Added division with rounding operations. 2021-10-12 17:16:57 -04:00
Stephen Canon dec7339db4 Renamed RoundingMode.trap to .requireExact
Also implemented some basic statistical tests for .stochastic and reorganized code a little bit. The statistical justification of the thresholds for these tests should be explained a bit more, and we should decide on a policy in general for statistical tests that may fail sporadically, but these shouldn't be very noisy for now.
2021-09-28 11:29:10 -04:00
Stephen Canon c124585c19 Skeleton of integer shift with rounding.
Fairly correct implementation of right-shift with rounding. Also fairly efficient, though I'm sure I'll find some cases where we're generating uncessary overflow checks upon further inspection. Nonetheless, a decent enough start.
2021-09-26 16:23:58 -04:00
Stephen Canon e22ff866a4 Add GCD files to CMake build. 2021-09-20 12:35:22 -04:00
Stephen Canon 9d84cefefa Merge pull request #189 from NevinBR/patch-6
GCD function for BinaryInteger
2021-09-10 11:04:07 -04:00
NevinBR f2cfa8d668 Fixed typo 2021-09-10 00:04:53 -04:00
NevinBR bd68569533 Commented out ExpectFailure tests for gcd 2021-09-10 00:03:31 -04:00
NevinBR 89c4e42e48 Added tests for gcd overflow on Int.min 2021-08-31 11:10:40 -04:00
NevinBR 83c378f2f4 Update GCDTests.swift 2021-08-30 17:29:05 -04:00
Stephen Canon 996cf7f5b9 CMake build support for the IntegerUtilities module. 2021-08-26 15:18:40 -04:00
NevinBR 632919ce2a Create GCDTests.swift 2021-08-26 14:56:04 -04:00
Stephen Canon 84474a3410 Initial setup of IntegerUtilities module.
Seeded with rotate(right:) and rotate(left:) on FixedWidthInteger. These implementations are basically sane, but need documentation written for users who are not already familiar with bitwise rotation.
2021-08-25 15:36:24 -04:00
Steve (Numerics) Canon 97852afaf5 Adjust Float16 availability for Swift 5.4 toolchains.
In older toolchains, Float16 is marked unavailable on all mac targets; starting with the 5.4 toolchain, it is available starting in macOS 11.0 when targeting Apple Silicon.
2021-02-19 15:53:15 -05:00
Steve (Numerics) Canon 0cf166da79 Remove zeroTangentVectorInitializer test, as the requirement has been removed from Swift main. 2021-02-19 15:11:21 -05:00
Stephen Canon 26c51aca1b Mark all complex elementary functions inlinable
This is kind of dubious, but necessary for performance reasons until we get dependable cross-module specialization. Also has a minor test fix for 32b platforms.
2020-11-09 16:41:45 -05:00
Stephen Canon 16837299c1 Added inverse trig and hyperbolics, some rough test coverage. 2020-11-09 11:25:08 -05:00
Stephen Canon 2b4c6701f2 log and log(onePlus:) implementations for Complex
These significantly improve on the state of the art for arguments close to the circle where the result vanishes, producing good componentwise relative accuracy as well as relative accuracy in the complex norm.

Also drops the argument parser dependency, which is desirable to avoid possible circular dependencies in the future with algorithms.
2020-11-05 15:14:25 -05:00
Stephen Canon 1cbb94ac71 First pass over hyperbolics and trig functions for Complex. 2020-10-01 16:39:11 -04:00
Stephen Canon 0b2dc469ed Moved sampling-based tests out of unit and into an exectuable target. 2020-10-01 16:39:11 -04:00
Stephen Canon efbe11a734 Fix typo expMinusOne/exp in near-overflow check. 2020-10-01 16:39:11 -04:00
Stephen Canon 4798b68203 Refactor test support to remove XCTest dependency. 2020-10-01 16:39:11 -04:00