Now Calculus.gradient return an Array of Float64 instead of Array of PDFP
I have track down the problem to
URL https : //github.com/JuliaMath/Calculus.jl/blob/master/src/finite_difference.jl
the problem is in the line "g = Vector{Float64}(undef, length(x))"
function finite_difference(f,
x::AbstractVector{T},
dtype::Symbol = :central) where T <: Number
# Allocate memory for gradient
g = Vector{Float64}(undef, length(x))
# Mutate allocated gradient
finite_difference!(f, float(x), g, dtype)
# Return mutated gradient
return g
end
The calculus module is great for performing finite differences for derivative, jacobian and hessian
But when I tried to use it with my own type of floating point numbers, it fails and I track down why it fails.
Now Calculus.gradient return an Array of Float64 instead of Array of PDFP
I have track down the problem to URL https : //github.com/JuliaMath/Calculus.jl/blob/master/src/finite_difference.jl
the problem is in the line "g = Vector{Float64}(undef, length(x))"
I think it should have been
g = Vector{eltype(x)}(undef, length(x))