Skip to content

Commit 1316f57

Browse files
authored
Merge pull request #28739 from dan-zheng/∂p-manifesto
2 parents 87aac59 + 25bb2ca commit 1316f57

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

docs/DifferentiableProgramming.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,48 +1696,49 @@ public protocol ElementaryFunctions {
16961696
...
16971697
}
16981698

1699-
public extension ElementaryFunctions where Self: Differentiable, Self == Self.TangentVector {
1699+
public extension ElementaryFunctions
1700+
where Self: Differentiable & FloatingPoint, Self == Self.TangentVector {
17001701
@inlinable
17011702
@derivative(of: sqrt)
1702-
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
1703+
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
17031704
(sqrt(x), { dx in (1 / 2) * (1 / sqrt(x)) * dx })
17041705
}
17051706

17061707
@inlinable
17071708
@derivative(of: cos)
1708-
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
1709+
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
17091710
(cos(x), { dx in -sin(x) * dx })
17101711
}
17111712

17121713
@inlinable
17131714
@derivative(of: asinh)
1714-
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
1715+
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
17151716
(asinh(x), { dx in 1 / (1 + x * x) * dx })
17161717
}
17171718

17181719
@inlinable
17191720
@derivative(of: exp)
1720-
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
1721+
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
17211722
let ret = exp(x)
17221723
return (ret, { dx in ret * dx })
17231724
}
17241725

17251726
@inlinable
17261727
@derivative(of: exp10)
1727-
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) {
1728+
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) {
17281729
let ret = exp10(x)
17291730
return (ret, { dx in exp(10) * ret * dx })
17301731
}
17311732

17321733
@inlinable
17331734
@derivative(of: log)
1734-
func _(_ x: Self) -> (value: Self, differential: @differential(linear) (Self) -> Self) { dx in
1735+
static func _(_ x: Self) -> (value: Self, differential: @differentiable(linear) (Self) -> Self) { dx in
17351736
(log(x), { 1 / x * dx })
17361737
}
17371738

17381739
@inlinable
17391740
@derivative(of: pow)
1740-
func _(_ x: Self, _ y: Self) -> (value: Self, differential: @differential(linear) (Self, Self) -> Self) {
1741+
static func _(_ x: Self, _ y: Self) -> (value: Self, differential: @differentiable(linear) (Self, Self) -> Self) {
17411742
(pow(x, y), { (dx, dy) in
17421743
let l = y * pow(x, y-1) * dx
17431744
let r = pow(x, y) * log(x) * dy

0 commit comments

Comments
 (0)