Skip to content

Commit 704db4a

Browse files
oscardssmithoxinabox
authored andcommitted
add interface v2
1 parent 8af6de2 commit 704db4a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/interface.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ function (::Type{∇})(f, x1, args...)
127127
unthunk.((f)(x1, args...))
128128
end
129129

130-
const gradient =
131-
132130
# Star Trek has their prime directive. We have the...
133131
abstract type AbstractPrimeDerivative{N, T}; end
134132

@@ -181,8 +179,8 @@ struct PrimeDerivative{N, T}
181179
end
182180

183181
function (f::PrimeDerivative{N, T})(x) where {N, T}
184-
# For now, this is backwards mode, since that's more fully implemented
185-
return PrimeDerivativeBack{N, T}(f.f)(x)
182+
# For now, this is forward mode, since that's more fully implemented
183+
return PrimeDerivativeFwd{N, T}(f.f)(x)
186184
end
187185

188186
"""
@@ -227,3 +225,7 @@ will compute the derivative `∂^3 f/∂x^2 ∂y` at `(x,y)`.
227225
macro (expr)
228226
error("Write me")
229227
end
228+
derivative(f, x) = Diffractor.PrimeDerivativeFwd(f)(x)
229+
const gradient =
230+
jacobian(f, x::AbstractArray) = reduce(hcat, vec.(gradient(f, x)))
231+
hessian(f, x::AbstractArray) = jacobian(y -> gradient(f, y), float(x))

0 commit comments

Comments
 (0)