apple / swift-numerics

Advanced mathematical types and functions for Swift
Apache License 2.0
1.67k stars 142 forks source link

Add `Augmented.sum(_:_:)` aka "twoSum" #208

Closed markuswntr closed 2 years ago

markuswntr commented 2 years ago

With augmented arithmetic in place, I was wondering if we might as well add "twoSum" alongside the existing "fast2sum". https://en.wikipedia.org/wiki/2Sum

As with "fast2sum", which is currently used for the elementary function of complex numbers, "twoSum" would be useful for the elementary function of quaternions where, due the additional pair of imaginary numbers, the magnitudes of the summands can not be guaranteed to be in any order.

stephentyrone commented 2 years ago

Mind adding a couple test cases?

stephentyrone commented 2 years ago

@swift-ci test

stephentyrone commented 2 years ago

@swift-ci test

stephentyrone commented 2 years ago

I'll probably write some additional documentation for this down the road, but LGTM as is for now.