# HG changeset patch # User Tuomo Valkonen # Date 1613856362 18000 # Node ID 3b7fcc6515851cb726e24526c894cdd60a16d5c5 # Parent 8b80aa64adec9dc9b6b90597b5ea9a76182e9497 Add DifferentiableFN diff -r 8b80aa64adec -r 3b7fcc651585 src/AlgTools.jl --- a/src/AlgTools.jl Fri Jan 08 00:26:42 2021 -0500 +++ b/src/AlgTools.jl Sat Feb 20 16:26:02 2021 -0500 @@ -9,5 +9,6 @@ include("Util.jl") include("Comms.jl") include("LinOps.jl") +include("DifferentiableFN.jl") end diff -r 8b80aa64adec -r 3b7fcc651585 src/DifferentiableFN.jl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/DifferentiableFN.jl Sat Feb 20 16:26:02 2021 -0500 @@ -0,0 +1,32 @@ +module DifferentiableFN + +using ..LinOps + +export DiffF, + value, + differential, + adjoint_differential + +abstract type DiffF{X,Y,T} end + +function value(f :: D, x :: X) :: Y where {X, Y, T <: LinOp{X,Y}, D <: DiffF{X,Y,T}} + @error "`value` unimplemented" +end + +# function (f :: D)(x::X) where {X, Y, T <: LinOp{X, Y}, D <: DiffF{X, Y, T}} +# return value(x) +# end + +function differential(f :: DiffF{X,Y,T}, x :: X) :: T where {X, Y, T <: LinOp{X, Y}} + @error "`differential` unimplemented" +end + +function adjoint_differential(f :: DiffF{X,Y,T}, x :: X) :: T where {X, Y, T <: LinOp{X, Y}} + @error "`adjoint_differential` unimplemented" +end + +function adjoint_differential(f :: DiffF{X,Y, T}, x :: X) :: T where {X, Y, T <: AdjointableOp{X, Y}} + return AdjointOp(differential(f, x)) +end + +end