diff --git a/Sources/QuaternionModule/ElementaryFunctions.swift b/Sources/QuaternionModule/ElementaryFunctions.swift index d8f992a..52e312c 100644 --- a/Sources/QuaternionModule/ElementaryFunctions.swift +++ b/Sources/QuaternionModule/ElementaryFunctions.swift @@ -334,7 +334,7 @@ extension Quaternion/*: ElementaryFunctions */ { } } -extension SIMD3 where Scalar: Real { +extension SIMD3 where Scalar: FloatingPoint { /// Returns the normalized axis and the length of this vector. @usableFromInline @inline(__always) diff --git a/Tests/QuaternionTests/ElementaryFunctionTests.swift b/Tests/QuaternionTests/ElementaryFunctionTests.swift index d6459a1..d2bf1ce 100644 --- a/Tests/QuaternionTests/ElementaryFunctionTests.swift +++ b/Tests/QuaternionTests/ElementaryFunctionTests.swift @@ -115,7 +115,10 @@ final class ElementaryFunctionTests: XCTestCase { for _ in 0 ..< 100 { let q = Quaternion( real: T.random(in: -small ... small, using: &g), - imaginary: SIMD3(repeating: T.random(in: -small ... small, using: &g)) + imaginary: + T.random(in: -small ... small, using: &g), + T.random(in: -small ... small, using: &g), + T.random(in: -small ... small, using: &g) ) XCTAssert(q.isApproximatelyEqual(to: Quaternion.expMinusOne(q), relativeTolerance: 16 * .ulpOfOne)) } @@ -199,9 +202,9 @@ final class ElementaryFunctionTests: XCTestCase { Quaternion( real: T.random(in: -2 ... 2, using: &g), imaginary: - T.random(in: -2 ... 2, using: &g) / 3, - T.random(in: -2 ... 2, using: &g) / 3, - T.random(in: -2 ... 2, using: &g) / 3 + T.random(in: -2 ... 2, using: &g), + T.random(in: -2 ... 2, using: &g), + T.random(in: -2 ... 2, using: &g) ) } for q in values { @@ -211,15 +214,15 @@ final class ElementaryFunctionTests: XCTestCase { } } - func testSin(_ type: T.Type) { + func testCosSin(_ type: T.Type) { var g = SystemRandomNumberGenerator() let values: [Quaternion] = (0..<1000).map { _ in Quaternion( real: T.random(in: -2 ... 2, using: &g), imaginary: - T.random(in: -2 ... 2, using: &g) / 3, - T.random(in: -2 ... 2, using: &g) / 3, - T.random(in: -2 ... 2, using: &g) / 3 + T.random(in: -2 ... 2, using: &g), + T.random(in: -2 ... 2, using: &g), + T.random(in: -2 ... 2, using: &g) ) } for q in values { @@ -256,7 +259,7 @@ final class ElementaryFunctionTests: XCTestCase { testExpMinusOne(Float32.self) testCosh(Float32.self) testSinh(Float32.self) - testSin(Float32.self) + testCosSin(Float32.self) testLog(Float32.self) } @@ -266,7 +269,7 @@ final class ElementaryFunctionTests: XCTestCase { testExpMinusOne(Float64.self) testCosh(Float64.self) testSinh(Float64.self) - testSin(Float64.self) + testCosSin(Float64.self) testLog(Float64.self) }