Description Usage Arguments Value References Examples

Constructs an R function that wraps a call to a C++ function and compiles the C++ code used to define the function. The code must define a function having arguments of the type const ADmat& and a return type of ADmat. The ADmat type is a type definition for a dynamically sized matrix from the Eigen linear algebra library. (Guennebaud G, Jacob B and others 2010). The function can employ methods from the Eigen library, such as all of the standard operators from linear algebra, and a wide range of functions for calculating inverses, decompositions and so on. See Guennebaud G, Jacob B and others (2010) for further details.

The returned function can then be used
as an argument to `J`

or `H`

which provide functions that apply algorithmic differentiation
to calculate the Jacobian or Hessian matrices. The functions produced by `J`

or `H`

evaluate
the partial derivatives with respect to the elements of the argument located at the position in the functions argument
list that is specified by the `wrt`

argument of sourceCppAD.

1 | ```
sourceCppAD(code=NULL,file=NULL,wrt=1,output="method")
``` |

`code` |
A character vector containing the C++ code to compile. |

`file` |
The filename of a file containing the C++ code to compile. |

`wrt` |
The position of the argument that |

`output` |
Specifies what is generated by sourceCppAD. If output="method" (the default) then a function which invokes the compiled code is returned. If output="code" then the source code that wraps the users function for use with the algorithmic differentiation libraries is returned. |

A function which invokes the compiled code or the c++ code that wraps the users function for use with the algorithmic differentiation libraries.

eigenwebRcppEigenAD

1 2 3 4 5 6 7 8 9 10 11 | ```
library(RcppEigenAD)
# define a function to calculate sin(cos(x)) where x is a matrix
f<-sourceCppAD('
ADmat f(const ADmat& X)
{
return X.array().cos().sin();
}
')
x<-matrix(c(1,2,3,4),2,2)
# call it
f(x)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.