Learn R Programming

spatstat (version 1.55-0)

matrixpower: Power of a Matrix

Description

Evaluate a specified power of a matrix.

Usage

matrixpower(x, power, complexOK = TRUE)
  matrixsqrt(x, complexOK = TRUE)
  matrixinvsqrt(x, complexOK = TRUE)

Arguments

x

A square matrix containing numeric or complex values.

power

A numeric value giving the power (exponent) to which x should be raised.

complexOK

Logical value indicating whether the result is allowed to be complex.

Value

A matrix of the same size as x containing numeric or complex values.

Details

These functions raise the matrix x to the desired power: matrixsqrt takes the square root, matrixinvsqrt takes the inverse square root, and matrixpower takes the specified power of x.

Up to numerical error, matrixpower(x, 2) should be equivalent to x %*% x, and matrixpower(x, -1) should be equivalent to solve(x), the inverse of x.

The square root y <- matrixsqrt(x) should satisfy y %*% y = x. The inverse square root z <- matrixinvsqrt(x) should satisfy z %*% z = solve(x).

Computations are performed using the eigen decomposition (eigen).

See Also

eigen, svd

Examples

Run this code
# NOT RUN {
  x <- matrix(c(10,2,2,1), 2, 2)
  y <- matrixsqrt(x)
  y
  y %*% y 
  z <- matrixinvsqrt(x)
  z %*% y
  matrixpower(x, 0.1)
# }

Run the code above in your browser using DataLab