Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Calculus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ isdefined(Base, :__precompile__) && __precompile__()

module Calculus
import Compat
import Base.ctranspose
export check_derivative,
check_gradient,
check_hessian,
Expand Down
6 changes: 5 additions & 1 deletion src/derivative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function Base.gradient(f, dtype::Symbol = :central)
Calculus.gradient(f,dtype)
end

ctranspose(f::Function) = derivative(f)
if isdefined(Base, :adjoint)
Base.adjoint(f::Function) = derivative(f)
else
Base.ctranspose(f::Function) = derivative(f)
end

function jacobian{T <: Number}(f, x::Vector{T}, dtype::Symbol)
finite_difference_jacobian(f, x, dtype)
Expand Down
2 changes: 1 addition & 1 deletion test/derivative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ f2(x::Vector) = sin(x[1])
@test norm(derivative(f2, :vector, :central)([0.0]) .- cos(0.0)) < 10e-4

#
# ctranspose overloading
# adjoint overloading
#

f3(x::Real) = sin(x)
Expand Down