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.
This commit is contained in:
Stephen Canon committed 2020-11-05 15:14:25 -05:00
1 parent 754cbd9e2e
commit 2b4c6701f2
8 files changed
+417 -159

No files matched your search

@@ -0,0 +1,29 @@
//===--- AugmentedArithmetic.swift ----------------------------*- swift -*-===//
//
// This source file is part of the Swift Numerics open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Numerics project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
public enum Augmented { }
extension Augmented {
@_transparent
public static func twoProdFMA<T:Real>(_ a: T, _ b: T) -> (head: T, tail: T) {
let head = a*b
let tail = (-head).addingProduct(a, b)
return (head, tail)
}
@_transparent
public static func fastTwoSum<T:Real>(_ a: T, _ b: T) -> (head: T, tail: T) {
assert(!(b.magnitude > a.magnitude))
let head = a + b
let tail = a - head + b
return (head, tail)
}
}