Learn R Programming

fastmatrix (version 0.6-2)

matrix.fun: Evaluate a matrix function

Description

This function computes the matrix function \(\bold{F} =f(\bold{A})\) where \(\bold{A}\) is upper triangular by applying a Parlett recurrence.

Usage

matrix.fun(a, FUN = "log")

Arguments

a

an upper triangular matrix.

FUN

the function to be applied, by default "log".

Details

The used-defined function FUN is evaluated at the triangular matrix argument. This function can be used in conjunction with Schur decomposition to evaluate the function of a matrix.

References

Higham, N.J. (1986). Functions of Matrices: Theory and Computation. Society for Industrial and Applied Mathematics, Philadelphia.

Examples

Run this code
a <- matrix(c(1,2,3,0,3,4,0,0,5), ncol = 3, byrow = TRUE)
fnc <- function(x) (1 + x) / x
f <- matrix.fun(a, FUN = fnc)
f

a <- matrix(c(-49,24,-64,31), ncol = 2, byrow = TRUE)
z <- schur(a)
m <- z$m
u <- z$vectors
m <- matrix.fun(m, FUN = exp)
u %*% m %*% t(u) # exp(a)

Run the code above in your browser using DataLab