| rcpp_matrix_ops | R Documentation |
Performs matrix operations using Rcpp and RcppEigen, and some custom C++ to handle symmetric and positive-definite Toeplitz matrices.
rcppeigen_invert_matrix(A)
rcppeigen_get_det(A)
rcppeigen_get_chol(A)
tinv(A)
tdet(A)
rcpp_distance(A, nrow, ncol)
A |
Matrix to perform operation on. |
nrow |
Number of rows in A. |
ncol |
Number of columns in A. |
Functions with "rcppeigen" directly call RcppEigen implementations of the associated functions, specifically for inverse, determinant, and lower triangular Cholesky factor. The function tinv computes an inverse and tdet returns the log-determinant of a symmetric and positive-definite Toeplitz matrix using methods from Trench and Durbin from "Matrix Computations" by Golub and Van Loan. Rcpp_distance computes the pairwise distances
between rows of input matrix.
gopalan88@gmail.com
# See demo/FastGPdemo.R
N <- 5
sigma <- 1 #variance parameter in the covariance function
phi <- 5 #decay parameter for the squared-exponential kernel
x_seq <- seq(N)
Sig <- as.matrix(sigma*exp(-as.matrix(dist(x_seq))^2/phi)) + .001*diag(N) #test covariance function
rcppeigen_invert_matrix(Sig)
rcppeigen_get_det(Sig)
rcppeigen_get_chol(Sig)
tinv(Sig)
#NOTE: tdet returns the log of determinant
tdet(Sig)
rcpp_distance(matrix(seq(1,N^2),nrow=N), N, N)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.