9 Commits
Author SHA1 Message Date
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 f6b0aeb607 Remove _mulAdd in favor of Relaxed.multiplyAdd. 2023-04-26 08:56:43 -04:00
Steve (Numerics) Canon 30c01a9fc5 Possible spelling: Relaxed.sum/product. 2023-04-26 08:56:43 -04:00
Stephen Canon b750c890b7 Don't use reassociate(on) on older clang toolchains. 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 270972dd8a Minor documentation formatting cleanup. 2022-04-06 11:50:25 -04:00
Steve (Numerics) Canon 5827f9a943 80-column formatting for source doc comments
Tidying, plus a few small edits. This commit should not include any code changes.
2021-03-03 14:01:09 -05:00
Stephen Canon cda1b5e6f4 Added mulAdd and cosMinusOne operations for Real.
These are _mostly_ implementation hooks for Complex, but are generally useful, so I've made them public. Experimental, subject to renaming, especially mulAdd.
2020-08-24 18:52:58 -04:00
Stephen Canon 76954c06a7 Back to trailing 'Module' 2020-02-21 09:22:40 -05:00