1- function derivative (f:: Function , ftype:: Symbol , dtype:: Symbol )
1+ function derivative (f, ftype:: Symbol , dtype:: Symbol )
22 if ftype == :scalar
33 return x:: Number -> finite_difference (f, float (x), dtype)
44 elseif ftype == :vector
@@ -7,34 +7,34 @@ function derivative(f::Function, ftype::Symbol, dtype::Symbol)
77 error (" ftype must :scalar or :vector" )
88 end
99end
10- Compat. @compat derivative {T <: Number} (f:: Function , x:: Union{T, Vector{T}} , dtype:: Symbol = :central ) = finite_difference (f, float (x), dtype)
11- derivative (f:: Function , dtype:: Symbol = :central ) = derivative (f, :scalar , dtype)
10+ Compat. @compat derivative {T <: Number} (f, x:: Union{T, Vector{T}} , dtype:: Symbol = :central ) = finite_difference (f, float (x), dtype)
11+ derivative (f, dtype:: Symbol = :central ) = derivative (f, :scalar , dtype)
1212
13- Compat. @compat gradient {T <: Number} (f:: Function , x:: Union{T, Vector{T}} , dtype:: Symbol = :central ) = finite_difference (f, float (x), dtype)
14- gradient (f:: Function , dtype:: Symbol = :central ) = derivative (f, :vector , dtype)
13+ Compat. @compat gradient {T <: Number} (f, x:: Union{T, Vector{T}} , dtype:: Symbol = :central ) = finite_difference (f, float (x), dtype)
14+ gradient (f, dtype:: Symbol = :central ) = derivative (f, :vector , dtype)
1515
16- Compat. @compat function Base. gradient {T <: Number} (f:: Function , x:: Union{T, Vector{T}} , dtype:: Symbol = :central )
16+ Compat. @compat function Base. gradient {T <: Number} (f, x:: Union{T, Vector{T}} , dtype:: Symbol = :central )
1717 Base. warn_once (" The finite difference methods from Calculus.jl no longer extend Base.gradient and should be called as Calculus.gradient instead. This usage is deprecated." )
1818 Calculus. gradient (f,x,dtype)
1919end
2020
21- function Base. gradient (f:: Function , dtype:: Symbol = :central )
21+ function Base. gradient (f, dtype:: Symbol = :central )
2222 Base. warn_once (" The finite difference methods from Calculus.jl no longer extend Base.gradient and should be called as Calculus.gradient instead. This usage is deprecated." )
2323 Calculus. gradient (f,dtype)
2424end
2525
2626ctranspose (f:: Function ) = derivative (f)
2727
28- function jacobian {T <: Number} (f:: Function , x:: Vector{T} , dtype:: Symbol )
28+ function jacobian {T <: Number} (f, x:: Vector{T} , dtype:: Symbol )
2929 finite_difference_jacobian (f, x, dtype)
3030end
31- function jacobian (f:: Function , dtype:: Symbol )
31+ function jacobian (f, dtype:: Symbol )
3232 g (x:: Vector ) = finite_difference_jacobian (f, x, dtype)
3333 return g
3434end
35- jacobian (f:: Function ) = jacobian (f, :central )
35+ jacobian (f) = jacobian (f, :central )
3636
37- function second_derivative (f:: Function , g:: Function , ftype:: Symbol , dtype:: Symbol )
37+ function second_derivative (f, g, ftype:: Symbol , dtype:: Symbol )
3838 if ftype == :scalar
3939 return x:: Number -> finite_difference_hessian (f, g, x, dtype)
4040 elseif ftype == :vector
@@ -43,45 +43,45 @@ function second_derivative(f::Function, g::Function, ftype::Symbol, dtype::Symbo
4343 error (" ftype must :scalar or :vector" )
4444 end
4545end
46- Compat. @compat function second_derivative {T <: Number} (f:: Function , g:: Function , x:: Union{T, Vector{T}} , dtype:: Symbol )
46+ Compat. @compat function second_derivative {T <: Number} (f, g, x:: Union{T, Vector{T}} , dtype:: Symbol )
4747 finite_difference_hessian (f, g, x, dtype)
4848end
49- Compat. @compat function hessian {T <: Number} (f:: Function , g:: Function , x:: Union{T, Vector{T}} , dtype:: Symbol )
49+ Compat. @compat function hessian {T <: Number} (f, g, x:: Union{T, Vector{T}} , dtype:: Symbol )
5050 finite_difference_hessian (f, g, x, dtype)
5151end
52- Compat. @compat function second_derivative {T <: Number} (f:: Function , g:: Function , x:: Union{T, Vector{T}} )
52+ Compat. @compat function second_derivative {T <: Number} (f, g, x:: Union{T, Vector{T}} )
5353 finite_difference_hessian (f, g, x, :central )
5454end
55- Compat. @compat function hessian {T <: Number} (f:: Function , g:: Function , x:: Union{T, Vector{T}} )
55+ Compat. @compat function hessian {T <: Number} (f, g, x:: Union{T, Vector{T}} )
5656 finite_difference_hessian (f, g, x, :central )
5757end
58- function second_derivative (f:: Function , x:: Number , dtype:: Symbol )
58+ function second_derivative (f, x:: Number , dtype:: Symbol )
5959 finite_difference_hessian (f, derivative (f), x, dtype)
6060end
61- function hessian (f:: Function , x:: Number , dtype:: Symbol )
61+ function hessian (f, x:: Number , dtype:: Symbol )
6262 finite_difference_hessian (f, derivative (f), x, dtype)
6363end
64- function second_derivative {T <: Number} (f:: Function , x:: Vector{T} , dtype:: Symbol )
64+ function second_derivative {T <: Number} (f, x:: Vector{T} , dtype:: Symbol )
6565 finite_difference_hessian (f, gradient (f), x, dtype)
6666end
67- function hessian {T <: Number} (f:: Function , x:: Vector{T} , dtype:: Symbol )
67+ function hessian {T <: Number} (f, x:: Vector{T} , dtype:: Symbol )
6868 finite_difference_hessian (f, gradient (f), x, dtype)
6969end
70- function second_derivative (f:: Function , x:: Number )
70+ function second_derivative (f, x:: Number )
7171 finite_difference_hessian (f, derivative (f), x, :central )
7272end
73- function hessian (f:: Function , x:: Number )
73+ function hessian (f, x:: Number )
7474 finite_difference_hessian (f, derivative (f), x, :central )
7575end
76- function second_derivative {T <: Number} (f:: Function , x:: Vector{T} )
76+ function second_derivative {T <: Number} (f, x:: Vector{T} )
7777 finite_difference_hessian (f, gradient (f), x, :central )
7878end
79- function hessian {T <: Number} (f:: Function , x:: Vector{T} )
79+ function hessian {T <: Number} (f, x:: Vector{T} )
8080 finite_difference_hessian (f, gradient (f), x, :central )
8181end
82- second_derivative (f:: Function , g:: Function , dtype:: Symbol ) = second_derivative (f, g, :scalar , dtype)
83- second_derivative (f:: Function , g:: Function ) = second_derivative (f, g, :scalar , :central )
84- second_derivative (f:: Function ) = second_derivative (f, derivative (f), :scalar , :central )
85- hessian (f:: Function , g:: Function , dtype:: Symbol ) = second_derivative (f, g, :vector , dtype)
86- hessian (f:: Function , g:: Function ) = second_derivative (f, g, :vector , :central )
87- hessian (f:: Function ) = second_derivative (f, gradient (f), :vector , :central )
82+ second_derivative (f, g, dtype:: Symbol ) = second_derivative (f, g, :scalar , dtype)
83+ second_derivative (f, g) = second_derivative (f, g, :scalar , :central )
84+ second_derivative (f) = second_derivative (f, derivative (f), :scalar , :central )
85+ hessian (f, g, dtype:: Symbol ) = second_derivative (f, g, :vector , dtype)
86+ hessian (f, g) = second_derivative (f, g, :vector , :central )
87+ hessian (f) = second_derivative (f, gradient (f), :vector , :central )
0 commit comments