mirror of
https://github.com/apple/swift-numerics
synced 2026-11-27 05:04:26 +00:00
Possible spelling: Relaxed.sum/product.
This commit is contained in:
1 parent
9a23fdf1c9
commit
30c01a9fc5
7 files changed
+126
-66
No files matched your search
@@ -123,4 +123,17 @@ extension Complex: AlgebraicField {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public static func _relaxedAdd(_ a: Self, _ b: Self) -> Self {
|
||||
Complex(Relaxed.sum(a.x, b.x), Relaxed.sum(a.y, b.y))
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public static func _relaxedMul(_ a: Self, _ b: Self) -> Self {
|
||||
Complex(
|
||||
Relaxed.sum(Relaxed.product(a.x, b.x), -Relaxed.product(a.y, b.y)),
|
||||
Relaxed.sum(Relaxed.product(a.x, b.y), Relaxed.product(a.y, b.x))
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ extension Complex: ElementaryFunctions {
|
||||
}
|
||||
// Special cases out of the way, evaluate as discussed above.
|
||||
return Complex(
|
||||
RealType._mulAdd(.cos(z.y), .expMinusOne(z.x), .cosMinusOne(z.y)),
|
||||
Relaxed.multiplyAdd(.cos(z.y), .expMinusOne(z.x), .cosMinusOne(z.y)),
|
||||
.exp(z.x) * .sin(z.y)
|
||||
)
|
||||
}
|
||||
@@ -300,7 +300,7 @@ extension Complex: ElementaryFunctions {
|
||||
// We are not trying for sub-ulp accuracy, just a good relative error
|
||||
// bound, so for our purposes it suffices to have log u dominate the
|
||||
// result:
|
||||
if u >= 1 || u >= RealType._mulAdd(u,u,v*v) {
|
||||
if u >= 1 || u >= Relaxed.multiplyAdd(u, u, v*v) {
|
||||
let r = v / u
|
||||
return Complex(.log(u) + .log(onePlus: r*r)/2, θ)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user