adiff: Automatic Differentiation Using Madness

Description Usage Arguments Value References See Also Examples

View source: R/adiff.R

Description

A wrapper function to the functionality of the madness package. Converts a given x to a madness object and then applies func to it, returning the result and the Jacobian for the transformation func. adiff is used by the rjmcmcpost function.

Usage

1
adiff(func, x, ...)

Arguments

func

The function to be differentiated (usually user-defined).

x

The values at which to evaluate the function func.

...

Further arguments to be passed to func.

Value

A numeric vector or matrix containing the result of the function evaluation func(x, ...). The "gradient" attribute of this object contains the Jacobian matrix of the transformation func.

References

Pav, S. E. (2016) Madness: Automatic Differentiation of Multivariate Operations.

See Also

madness

Examples

1
2
3
4
5
6
x2x3 = function(x){
return(c(x^2, x^3))
}

y = adiff(x2x3, c(5,6))
attr(y, "gradient")

rjmcmc documentation built on July 9, 2019, 5:03 p.m.