rcpp_matrix_ops: Matrix Operations Using Rcpp and RcppEigen

rcpp_matrix_opsR Documentation

Matrix Operations Using Rcpp and RcppEigen

Description

Performs matrix operations using Rcpp and RcppEigen, and some custom C++ to handle symmetric and positive-definite Toeplitz matrices.

Usage

rcppeigen_invert_matrix(A)
rcppeigen_get_det(A)
rcppeigen_get_chol(A)
tinv(A)
tdet(A)
rcpp_distance(A, nrow, ncol)

Arguments

A

Matrix to perform operation on.

nrow

Number of rows in A.

ncol

Number of columns in A.

Details

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.

Author(s)

gopalan88@gmail.com

Examples

# 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)

FastGP documentation built on Oct. 18, 2026, 1:07 a.m.