cpowop: Square matrix power operator

%**%R Documentation

Square matrix power operator

Description

This operator computes an arbitrary power of a positive definite square matrix using an Eigen-decomposition: \mathbf{X}^p = \mathbf{UD}^{p}\mathbf{U}'

Usage

X %**% power

Arguments

X

Positive definite square matrix

power

numeric scalar - desired power of X

Value

Matrix X to the power p

Examples

# Inverse Square Root of a positive definite square matrix
X <- matrix(rnorm(100*500),100,500)

XX <- ccross(X)

XX_InvSqrt <- XX %**% -0.5

# check result: ((XX')^-0.5 (XX')^-0.5)^-1 = XX'
table(round(csolve(XX_InvSqrt %c% XX_InvSqrt),digits=2) == round(XX,digits=2) )

cheuerde/cpgen documentation built on July 27, 2023, 11:34 a.m.