Skip to content

Commit bc944e7

Browse files
markuswntrstephentyrone
authored andcommitted
Update trig tests
1 parent ff9f52f commit bc944e7

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

Sources/QuaternionModule/ElementaryFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ extension Quaternion/*: ElementaryFunctions */ {
334334
}
335335
}
336336

337-
extension SIMD3 where Scalar: Real {
337+
extension SIMD3 where Scalar: FloatingPoint {
338338

339339
/// Returns the normalized axis and the length of this vector.
340340
@usableFromInline @inline(__always)

Tests/QuaternionTests/ElementaryFunctionTests.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ final class ElementaryFunctionTests: XCTestCase {
115115
for _ in 0 ..< 100 {
116116
let q = Quaternion<T>(
117117
real: T.random(in: -small ... small, using: &g),
118-
imaginary: SIMD3(repeating: T.random(in: -small ... small, using: &g))
118+
imaginary:
119+
T.random(in: -small ... small, using: &g),
120+
T.random(in: -small ... small, using: &g),
121+
T.random(in: -small ... small, using: &g)
119122
)
120123
XCTAssert(q.isApproximatelyEqual(to: Quaternion.expMinusOne(q), relativeTolerance: 16 * .ulpOfOne))
121124
}
@@ -199,9 +202,9 @@ final class ElementaryFunctionTests: XCTestCase {
199202
Quaternion(
200203
real: T.random(in: -2 ... 2, using: &g),
201204
imaginary:
202-
T.random(in: -2 ... 2, using: &g) / 3,
203-
T.random(in: -2 ... 2, using: &g) / 3,
204-
T.random(in: -2 ... 2, using: &g) / 3
205+
T.random(in: -2 ... 2, using: &g),
206+
T.random(in: -2 ... 2, using: &g),
207+
T.random(in: -2 ... 2, using: &g)
205208
)
206209
}
207210
for q in values {
@@ -211,15 +214,15 @@ final class ElementaryFunctionTests: XCTestCase {
211214
}
212215
}
213216

214-
func testSin<T: Real & FixedWidthFloatingPoint & SIMDScalar>(_ type: T.Type) {
217+
func testCosSin<T: Real & FixedWidthFloatingPoint & SIMDScalar>(_ type: T.Type) {
215218
var g = SystemRandomNumberGenerator()
216219
let values: [Quaternion<T>] = (0..<1000).map { _ in
217220
Quaternion(
218221
real: T.random(in: -2 ... 2, using: &g),
219222
imaginary:
220-
T.random(in: -2 ... 2, using: &g) / 3,
221-
T.random(in: -2 ... 2, using: &g) / 3,
222-
T.random(in: -2 ... 2, using: &g) / 3
223+
T.random(in: -2 ... 2, using: &g),
224+
T.random(in: -2 ... 2, using: &g),
225+
T.random(in: -2 ... 2, using: &g)
223226
)
224227
}
225228
for q in values {
@@ -256,7 +259,7 @@ final class ElementaryFunctionTests: XCTestCase {
256259
testExpMinusOne(Float32.self)
257260
testCosh(Float32.self)
258261
testSinh(Float32.self)
259-
testSin(Float32.self)
262+
testCosSin(Float32.self)
260263

261264
testLog(Float32.self)
262265
}
@@ -266,7 +269,7 @@ final class ElementaryFunctionTests: XCTestCase {
266269
testExpMinusOne(Float64.self)
267270
testCosh(Float64.self)
268271
testSinh(Float64.self)
269-
testSin(Float64.self)
272+
testCosSin(Float64.self)
270273

271274
testLog(Float64.self)
272275
}

0 commit comments

Comments
 (0)