DerivableFunctionsBase
This is the documentation for DerivableFunctionsBase.jl.
This package provides the base functionality of DerivableFunctions.jl without loading all the backends, i.e. only for ForwardDiff.jl.
For in-depth examples and explanations, please see the Documentation of main package DerivableFunctions.jl.
DerivableFunctionsBase.DerivableFunctionDerivableFunctionsBase.BuilderDerivableFunctionsBase.GetArgLengthDerivableFunctionsBase.GetDerivDerivableFunctionsBase.GetDoubleJacDerivableFunctionsBase.GetGradDerivableFunctionsBase.GetGrad!DerivableFunctionsBase.GetHessDerivableFunctionsBase.GetHess!DerivableFunctionsBase.GetJacDerivableFunctionsBase.GetJac!DerivableFunctionsBase.GetMatrixJacDerivableFunctionsBase.GetMatrixJac!DerivableFunctionsBase.GetOutLengthDerivableFunctionsBase.GetSymbolicDerivativeDerivableFunctionsBase.KillAfterDerivableFunctionsBase.MaximalNumberOfArgumentsDerivableFunctionsBase.SymbolicPassthroughDerivableFunctionsBase._GetArgLengthDerivableFunctionsBase.diff_backendsDerivableFunctionsBase.suff
DerivableFunctionsBase.DerivableFunction — Type
DerivableFunction(F::Function; ADmode::Union{Val,Symbol}=Val(:Symbolic))
DerivableFunction(F::Function, testinput::Union{Number,AbstractVector{<:Number}}; ADmode::Union{Val,Symbol}=Val(:Symbolic))
DerivableFunction(F::Function, dF::Function; ADmode::Union{Val,Symbol}=Val(:Symbolic))
DerivableFunction(F::Function, dF::Function, ddF::Function)Stores derivatives of a given function (as well as input-output dimensions) for potentially faster computations when derivatives are known.
DerivableFunctionsBase.Builder — Method
Builder(Fexpr::Union{<:AbstractVector{<:Num},<:Num}, args...; inplace::Bool=false, parallel::Bool=false, kwargs...)Builds RuntimeGeneratedFunctions from expressions via build_function().
DerivableFunctionsBase.GetArgLength — Method
GetArgLength(F::Function; max::Int=100) -> IntAttempts to determine input structure of F, i.e. whether it accepts Numbers or AbstractVectors and of what length. This is achieved by successively evaluating the function on rand(i) until the evaluation no longer throws errors. As a result, GetArgLength will be unable to determine the correct input structure if F errors on rand(i).
DerivableFunctionsBase.GetDeriv — Method
GetDeriv(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes the scalar derivative of F out-of-place via a backend specified by ADmode.
Example:
Derivative = GetDeriv(Val(:ForwardDiff), x->exp(-x^2))
Derivative(5.0)For available backends, see diff_backends().
DerivableFunctionsBase.GetDoubleJac — Function
GetDoubleJac(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes the Jacobian of the Jacobian for a vector-valued function F out-of-place via a backend specified by ADmode.
Example:
DoubleJacobian = GetDoubleJac(Val(:ForwardDiff), x->[x[1]^2, x[1]*x[2]^3])
DoubleJacobian(rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetGrad! — Method
GetGrad!(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes gradients in-place via a backend specified by ADmode. The function returned by GetGrad! has argument structure (Y::AbstractVector, X::AbstractVector) where the gradient of F evaluated at X is saved into Y.
Example:
Gradient! = GetGrad!(Val(:ForwardDiff), x->x[1]^2 - x[2]^3)
Y = Vector{Float64}(undef, 2)
Gradient!(Y, rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetGrad — Method
GetGrad(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes the gradient of F out-of-place via a backend specified by ADmode.
Example:
Gradient = GetGrad(Val(:ForwardDiff), x->x[1]^2 - x[2]^3)
Gradient(rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetHess! — Method
GetHess!(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes Hessians in-place via a backend specified by ADmode. The function returned by GetHess! has argument structure (Y::AbstractMatrix, X::AbstractVector) where the Hessian of F evaluated at X is saved into Y.
Example:
Hessian! = GetHess!(Val(:ForwardDiff), x->x[1]^2 -x[2]^3 + x[1]*x[2])
Y = Matrix{Float64}(undef, 2, 2)
Hessian!(Y, rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetHess — Method
GetHess(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes the Hessian of F out-of-place via a backend specified by ADmode.
Example:
Hessian = GetHess(Val(:ForwardDiff), x->x[1]^2 -x[2]^3 + x[1]*x[2])
Hessian(rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetJac! — Method
GetJac!(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes Jacobians in-place via a backend specified by ADmode. The function returned by GetJac! has argument structure (Y::AbstractMatrix, X::AbstractVector) where the Jacobian of F evaluated at X is saved into Y.
Example:
Jacobian! = GetJac!(Val(:ForwardDiff), x->[x[1]^2, -x[2]^3, x[1]*x[2]])
Y = Matrix{Float64}(undef, 3, 2)
Jacobian!(Y, rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetJac — Method
GetJac(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes the Jacobian of F out-of-place via a backend specified by ADmode.
Example:
Jacobian = GetJac(Val(:ForwardDiff), x->[x[1]^2, -x[2]^3, x[1]*x[2]])
Jacobian(rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetMatrixJac — Function
GetMatrixJac(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes the Jacobian of an array-valued function F out-of-place via a backend specified by ADmode.
Example:
Jacobian = GetMatrixJac(Val(:ForwardDiff), x->[x[1]^2 x[2]^3; x[1]*x[2] 2])
Jacobian(rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetMatrixJac! — Method
GetMatrixJac!(ADmode::Val, F::Function; kwargs...) -> FunctionReturns a function which computes Jacobians in-place for array-valued functions via a backend specified by ADmode. The function returned by GetMatrixJac! has argument structure (Y::AbstractArray, X::AbstractVector) where the Jacobian of F evaluated at X is saved into Y.
Example:
Jacobian! = GetMatrixJac!(Val(:ForwardDiff), x->[x[1]^2 x[2]^3; x[1]*x[2] 2])
Y = Array{Float64}(undef, 2, 2, 2)
Jacobian!(Y, rand(2))For available backends, see diff_backends().
DerivableFunctionsBase.GetOutLength — Method
GetOutLength(F::Function, input::Union{Number,AbstractVector{<:Number}})Returns output dimensions of given F. If it outputs arrays of more than one dimension, a tuple is returned. This can also be used to determine the approximate size of the input for mutating F which accept 2 arguments.
DerivableFunctionsBase.GetSymbolicDerivative — Function
GetSymbolicDerivative(F::Function, inputdim::Int=GetArgLength(F), deriv::Symbol=:jacobian; timeout::Real=5, inplace::Bool=false, parallel::Bool=false)Computes symbolic derivatives, including :jacobian, :gradient, :hessian and :derivative which are specified via deriv. Special care has to be taken that the correct inputdim is specified! Silent errors may occur otherwise.
DerivableFunctionsBase.KillAfter — Method
KillAfter(F::Function, args...; timeout::Real=5, verbose::Bool=false, kwargs...)Tries to evaluate a given function F before a set timeout limit is reached and interrupts the evaluation and returns nothing if necessary. NOTE: The given function is evaluated via F(args...; kwargs...).
DerivableFunctionsBase.MaximalNumberOfArguments — Method
MaximalNumberOfArguments(F::Function) -> IntInfers argument structure of given function, i.e. whether it is of the form F(x) or F(x,y) or F(x,y,z) etc. and returns maximal number of accepted arguments of all overloads of F as integer.
DerivableFunctionsBase.SymbolicPassthrough — Function
Executes symbolic derivative as specified by deriv::Symbol.
DerivableFunctionsBase._GetArgLength — Method
_GetArgLength(F::Function; max::Int=100) -> IntDerivableFunctionsBase.diff_backends — Method
Shows the currently loaded differentation backends available for use with DerivableFunctions.jl.
DerivableFunctionsBase.suff — Method
suff(x) -> TypeIf x stores BigFloats, suff returns BigFloat, else suff returns Float64.