ADmatrix | R Documentation |
Matrices (base package) and sparse matrices (Matrix package) can be used inside the RTMB
objective function as part of the calculations. Behind the scenes these R objects are converted to AD representations when needed. AD objects have a temporary lifetime, so you probably won't see them / need to know them. The only important thing is which methods work for the objects.
## S3 method for class 'advector'
chol(x, ...)
## S3 method for class 'advector'
determinant(x, logarithm = TRUE, ...)
## S4 method for signature 'adcomplex'
eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE)
## S4 method for signature 'advector'
eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE)
## S4 method for signature 'advector'
svd(x, nu, nv, LINPACK = FALSE)
## S3 method for class 'adsparse'
t(x)
## S3 method for class 'adsparse'
x[...]
## S3 replacement method for class 'adsparse'
x[...] <- value
## S4 method for signature 'adsparse,missing,missing'
diag(x)
## S4 method for signature 'advector'
expm(x)
## S4 method for signature 'adsparse'
expm(x)
## S4 method for signature 'adsparse'
dim(x)
## S4 method for signature 'anysparse,ad'
x %*% y
## S4 method for signature 'ad,anysparse'
x %*% y
## S4 method for signature 'adsparse,adsparse'
x %*% y
## S4 method for signature 'ad,ad'
x %*% y
## S4 method for signature 'ad,ad.'
tcrossprod(x, y)
## S4 method for signature 'ad,ad.'
crossprod(x, y)
## S4 method for signature 'advector'
cov2cor(V)
## S4 method for signature 'ad,ad.'
solve(a, b)
## S4 method for signature 'num,num.'
solve(a, b)
## S4 method for signature 'anysparse,ad.'
solve(a, b)
## S4 method for signature 'advector'
colSums(x, na.rm, dims)
## S4 method for signature 'advector'
rowSums(x, na.rm, dims)
## S3 method for class 'advector'
cbind(...)
## S3 method for class 'advector'
rbind(...)
x |
matrix (sparse or dense) |
... |
As cbind |
logarithm |
Not used |
symmetric |
Logical; Is input matrix symmetric (Hermitian) ? |
only.values |
Ignored |
EISPACK |
Ignored |
nu |
Ignored |
nv |
Ignored |
LINPACK |
Ignored |
value |
Replacement value |
y |
matrix (sparse or dense) |
V |
Covariance matrix |
a |
matrix |
b |
matrix, vector or missing |
na.rm |
Logical; Remove NAs while taping. |
dims |
Same as colSums and rowSums. |
List (vectors/values) with adcomplex
components.
List (vectors/values) with advector
components in symmetric case and adcomplex
components otherwise.
Object of class advector
with a dimension attribute for dense matrix operations; Object of class adsparse
for sparse matrix operations.
chol(advector)
: AD matrix cholesky
determinant(advector)
: AD log determinant
eigen(adcomplex)
: General AD eigen decomposition for complex matrices. Note that argument symmetric
is not auto-detected so must be specified.
eigen(advector)
: AD eigen decomposition for real matrices. The non-symmetric case is redirected to the adcomplex
method. Note that argument symmetric
is not auto-detected so must be specified.
svd(advector)
: AD svd decomposition for real matrices.
t(adsparse)
: AD sparse matrix transpose. Re-directs to t,CsparseMatrix-method.
[
: AD sparse matrix subsetting. Re-directs to [-methods.
`[`(adsparse) <- value
: AD sparse matrix subset assignment. Re-directs to [<–methods.
diag(x = adsparse, nrow = missing, ncol = missing)
: AD sparse matrix diagonal extract. Re-directs to diag,CsparseMatrix-method.
expm(advector)
: AD matrix exponential
expm(adsparse)
: AD matrix exponential
dim(adsparse)
: AD sparse matrix dimension
x %*% y
: AD matrix multiply
x %*% y
: AD matrix multiply
x %*% y
: AD matrix multiply
x %*% y
: AD matrix multiply
tcrossprod(x = ad, y = ad.)
: AD matrix multiply
crossprod(x = ad, y = ad.)
: AD matrix multiply
cov2cor(advector)
: AD matrix cov2cor
solve(a = ad, b = ad.)
: AD matrix inversion and solve
solve(a = num, b = num.)
: AD matrix inversion and solve
solve(a = anysparse, b = ad.)
: Sparse AD matrix solve (not yet implemented)
colSums(advector)
: AD matrix (or array) colsums
rowSums(advector)
: AD matrix (or array) rowsums
cbind(advector)
: AD matrix column bind
rbind(advector)
: AD matrix row bind
F <- MakeTape(function(x) matrix(1:9,3,3) %*% x, numeric(3))
F$jacobian(1:3)
F <- MakeTape(function(x) Matrix::expm(matrix(x,2,2)), numeric(4))
F$jacobian(1:4)
F <- MakeTape(det, diag(2)) ## Indirectly available via 'determinant'
F$jacobian(matrix(1:4,2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.