Learn R Programming

scorematchingad (version 0.1.1)

tape_Jacobian: Tape the Jacobian of CppAD Tape

Description

Creates a tape of the Jacobian of a function taped by CppAD. When the function returns a real value (as is the case for densities and the score matching objective) the Jacobian is equivalent to the gradient. The x vector is used as the value to conduct the taping.

Usage

tape_Jacobian(pfun)

Value

An Rcpp_ADFun object.

Arguments

pfun

An Rcpp_ADFun object.

Details

When the returned tape is evaluated (via say $eval(), the resultant vector contains the Jacobian in long format (see https://cppad.readthedocs.io/latest/Jacobian.html). Suppose the function represented by pfun maps from \(n\)-dimensional space to \(m\)-dimensional space, then the first \(n\) elements of vector is the gradient of the first component of function output. The next \(n\) elements of the vector is the gradient of the second component of the function output. The Jacobian as a matrix, could then be obtained by as.matrix() with byrow = TRUE and ncol = n.

For creating this tape, the values of pfun$xtape and pfun$dyntape are used.

See Also

Other tape builders: tape_Hessian(), tape_gradoffset(), tape_logJacdet(), tape_smd(), tape_swap(), tape_uld()