mirror of
https://github.com/apple/swift-numerics
synced 2026-11-26 04:57:53 +00:00
Define Complex.zeroTangentVectorInitializer.
The `Differentiable.zeroTangentVectorInitializer` protocol requirement is a closure producing a zero tangent vector, capturing minimal information from `self`. Fixes the `Complex: Differentiable` conformance for master toolchains.
This commit is contained in:
1 parent
593946d4aa
commit
86f0b33c65
2 files changed
+9
No files matched your search
@@ -15,6 +15,11 @@ import _Differentiation
|
||||
extension Complex: Differentiable
|
||||
where RealType: Differentiable, RealType.TangentVector == RealType {
|
||||
public typealias TangentVector = Self
|
||||
|
||||
@inlinable
|
||||
public var zeroTangentVectorInitializer: () -> Self {
|
||||
{ Complex.zero }
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex
|
||||
|
||||
@@ -57,6 +57,10 @@ final class DifferentiableTests: XCTestCase {
|
||||
XCTAssertEqual(φDivide(Complex(1, 0)), Complex(0.25, -0.25))
|
||||
XCTAssertEqual(φDivide(Complex(0, 1)), Complex(0.25, 0.25))
|
||||
}
|
||||
|
||||
func testZeroTangentVectorInitializer() {
|
||||
XCTAssertEqual(Complex<Float>(-5, 5).zeroTangentVector, Complex(0, 0))
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user