Learn R Programming

L0TFinv (version 0.1.0)

solMat: Generate the inverse of the crossprod matrix

Description

Generate the inverse matrix of \((\boldsymbol{X}^{(q+1)}_A)^T \boldsymbol{X}^{(q+1)}_A\) for the cases where \(q=0\) or \(q=1\), commonly employed in splicing algorithms. Note that an explicit solution exists for the inverse when \(q=0\), but not when \(q=1\).

Usage

solMat(n, q, A)

Value

The inverse matrix of \((\boldsymbol{X}^{(q+1)}_A)^T \boldsymbol{X}^{(q+1)}_A\) for the cases where \(q=\) 0 or 1.

Arguments

n

The number of data points

q

The order of the difference, 0 or 1

A

The set of indicators, a subset of \(\{1,2,3,\dots,n\}\)

Examples

Run this code
Mat1 <- XMat(n = 10, q = 0)
A1 = c(1,2,5,8)
mat1 = as.matrix(Mat1[,A1])
S1 <- solMat(n = 10, q = 0, A = A1)
print(S1)
print(round(S1%*%t(mat1)%*%mat1,10))

Mat2 <- XMat(n = 15, q = 1)
A2 = c(1,3,8,10,15)
mat2 = as.matrix(Mat2[,A2])
S2 <- solMat(n = 15, q = 1, A = A2)
print(S2)
print(round(S2%*%t(mat2)%*%mat2,10))

Run the code above in your browser using DataLab