Wrapper functions for API of ForwardDiff.jl at http://www.juliadiff.org/ForwardDiff.jl/stable/user/api.html. These functions can help you calculate derivative, gradient, jacobian and hessian for your functions using forward mode automatic differentiation. For more details, see http://www.juliadiff.org/ForwardDiff.jl/stable/user/api.html.

forward_deriv(f, x)

forward_grad_config(f, x, chunk_size = NULL, diffresult = NULL)

forward_jacobian_config(f, x, chunk_size = NULL, diffresult = NULL)

forward_hessian_config(f, x, chunk_size = NULL, diffresult = NULL)

forward_grad(f, x, cfg = NULL, check = TRUE, diffresult = NULL,
  debug = TRUE)

forward_jacobian(f, x, cfg = NULL, check = TRUE, diffresult = NULL,
  debug = TRUE)

forward_hessian(f, x, cfg = NULL, check = TRUE, diffresult = NULL,
  debug = TRUE)

Arguments

f

the function you want to calulate the derivative, gradient and etc. Note that f(x) should be a scalar for grad and hessian, a vector of length greater than 1 for jacobian, and could be either a scalar or a vector for deriv.

x

the point where you take the derivative, gradient and etc. Note that it should be a scalar for deriv and a vector of length greater than 1 for grad, jacobian and hessian.

chunk_size

the size of the chunk to construct the Config objects for ForwardDiff. It may be explicitly provided, or omitted, in which case ForwardDiff will automatically select a chunk size for you. However, it is highly recommended to specify the chunk size manually when possible. See http://www.juliadiff.org/ForwardDiff.jl/stable/user/advanced.html#Configuring-Chunk-Size-1 for more details.

diffresult

Optional DiffResult object to store the derivative information.

cfg

Config object which have information useful to do automatic differentiation for f. It allows the user to easily feed several different parameters to ForwardDiff's API, such as chunk size, work buffers, and perturbation seed configurations. ForwardDiff's basic API methods will allocate these types automatically by default, but you can drastically reduce memory usage if you preallocate them yourself.

check

whether to allow tag checking. Set check to FALSE to disable tag checking for ForwardDiff. This can lead to perturbation confusion, so should be used with care.

debug

Whether to use the wrapper functions under debug mode. With the debug mode, users can have more informative error messages. Without the debug mode, the wrapper functions will be more performant.

Value

forward_deriv, forward_grad, forward_jacobian and forward_hessian return the derivative, gradient, jacobian and hessian of f correspondingly evaluated at x. forward_grad_config, forward_jacobian_config and forward_hessian_config return Config instances based on f`` and x`, which contain all the work buffers required to carry out the forward mode automatic differentiation.