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.
1.6 KiB
ElementaryFunctions
A type that has elementary functions (sin, cos, etc.) available.
Overview
An "elementary function" is a function built up from powers, roots, exponentials, logarithms, trigonometric functions (sin, cos, tan) and their inverses, and the hyperbolic functions (sinh, cosh, tanh) and their inverses.
Conformance to this protocol means that all of these building blocks are available as static functions on the type.
let x: Float = 1
let y = Float.sin(x) // 0.84147096
ElementaryFunctions conformance implies AdditiveArithmetic, so addition
and subtraction and the zero property are also available.
RealFunctions refines this protocol and adds additional functions that
are primarily used with real numbers, such as RealFunctions/atan2(y:x:)
and RealFunctions/exp10(_:).
Real conforms to RealFunctions and FloatingPoint, and is the
protocol that you will use most often for generic code.
Topics
There are a few families of functions defined by ElementaryFunctions:
Exponential functions
exp(_:)expMinusOne(_:)
Logarithmetic functions
log(_:)log(onePlus:)
Power and root functions:
pow(_:_:)-9imp6pow(_:_:)-2qmulsqrt(_:)root(_:_:)
Trigonometric functions
cos(_:)sin(_:)tan(_:)
Inverse trigonometric functions
acos(_:)asin(_:)atan(_:)
Hyperbolic functions
cosh(_:)sinh(_:)tanh(_:)
Inverse hyperbolic functions
acosh(_:)asinh(_:)atanh(_:)