Skip to content

Commit 5ce378a

Browse files
authored
[stdlib] Add a negation for 'VectorProtocol' when scalar is signed (#25494)
1 parent 5db4a88 commit 5ce378a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

stdlib/public/core/AutoDiff.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public extension VectorProtocol {
5151
}
5252
}
5353

54+
public extension VectorProtocol where VectorSpaceScalar: SignedNumeric {
55+
static prefix func - (x: Self) -> Self {
56+
.zero - x
57+
}
58+
}
59+
5460
/// A type that mathematically represents a differentiable manifold whose
5561
/// tangent spaces are finite-dimensional.
5662
public protocol Differentiable {

0 commit comments

Comments
 (0)