Skip to content

Commit cdf9b03

Browse files
committed
[AutoDiff] Remove 'valueWithDerivative(of:)' and 'valueWithGradient(of:)'.
`valueWithDerivative(of:)` and `valueWithGradient(of:)` are the curried version of `valueWithDerivative(at:in:)` and `valueWithGradient(at:in:)`, respectively. They are not included the proposal and are not being used by any client that I know of. This patch removes them.
1 parent d121d7d commit cdf9b03

File tree

2 files changed

+0
-65
lines changed

2 files changed

+0
-65
lines changed

stdlib/public/Differentiation/DifferentialOperators.swift

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -297,61 +297,3 @@ public func gradient<T, U, V, R>(
297297
where R : FloatingPoint, R.TangentVector == R {
298298
return { x, y, z in gradient(at: x, y, z, in: f) }
299299
}
300-
301-
// Value with derivative (curried)
302-
303-
@inlinable
304-
public func valueWithDerivative<T: FloatingPoint, R>(
305-
of f: @escaping @differentiable (T) -> R
306-
) -> (T) -> (value: R, derivative: R.TangentVector)
307-
where T.TangentVector == T {
308-
return { x in valueWithDerivative(at: x, in: f) }
309-
}
310-
311-
@inlinable
312-
public func valueWithDerivative<T: FloatingPoint, U: FloatingPoint, R>(
313-
of f: @escaping @differentiable (T, U) -> R
314-
) -> (T, U) -> (value: R, derivative: R.TangentVector)
315-
where T.TangentVector == T,
316-
U.TangentVector == U {
317-
return { (x, y) in valueWithDerivative(at: x, y, in: f) }
318-
}
319-
320-
@inlinable
321-
public func valueWithDerivative<
322-
T: FloatingPoint, U: FloatingPoint, V: FloatingPoint, R>(
323-
of f: @escaping @differentiable (T, U, V) -> R
324-
) -> (T, U, V) -> (value: R, derivative: R.TangentVector)
325-
where T.TangentVector == T,
326-
U.TangentVector == U,
327-
V.TangentVector == V {
328-
return { (x, y, z) in valueWithDerivative(at: x, y, z, in: f) }
329-
}
330-
331-
// Value with gradient (curried)
332-
333-
@inlinable
334-
public func valueWithGradient<T, R>(
335-
of f: @escaping @differentiable (T) -> R
336-
) -> (T) -> (value: R, gradient: T.TangentVector)
337-
where R : FloatingPoint, R.TangentVector == R {
338-
return { x in valueWithGradient(at: x, in: f) }
339-
}
340-
341-
@inlinable
342-
public func valueWithGradient<T, U, R>(
343-
of f: @escaping @differentiable (T, U) -> R
344-
) -> (T, U) -> (value: R, gradient: (T.TangentVector, U.TangentVector))
345-
where R : FloatingPoint, R.TangentVector == R {
346-
return { x, y in valueWithGradient(at: x, y, in: f) }
347-
}
348-
349-
@inlinable
350-
public func valueWithGradient<T, U, V, R>(
351-
of f: @escaping @differentiable (T, U, V) -> R
352-
) -> (T, U, V)
353-
-> (value: R,
354-
gradient: (T.TangentVector, U.TangentVector, V.TangentVector))
355-
where R : FloatingPoint, R.TangentVector == R {
356-
return { x, y, z in valueWithGradient(at: x, y, z, in: f) }
357-
}

test/AutoDiff/stdlib/differential_operators.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ DifferentialOperatorTestSuite.test("gradient_curried_${arity}") {
5959
expectEqual(${expectedGradients}, gradF(${args}))
6060
}
6161

62-
DifferentialOperatorTestSuite.test("valueWithGradient_curried_${arity}") {
63-
let valueWithGradF = valueWithGradient(of: exampleDiffFunc_${arity})
64-
let (value, grad) = valueWithGradF(${args})
65-
expectEqual(${expectedValue}, value)
66-
expectEqual(${expectedGradients}, grad)
67-
}
68-
6962
% end
7063

7164
runAllTests()

0 commit comments

Comments
 (0)