Apply a function to a Hermitian matrix based on the representation
given by class spectral
.
Usage
# S3 method for spectral
act_eigfun(object, FUN, ...)
Arguments
- object
an instance of class
spectral
.- FUN
the function to be applied to the matrix.
- ...
further arguments passed on to
FUN
.
Value
The matrix resulting from the application of FUN
.
A Hermitian Matrix admits the spectral decomposition $$H = \sum_k \lambda_k E_k$$
where \(\lambda_k\) are its eigenvalues and \(E_k\) the orthogonal projector onto the \(\lambda_k\)-eigenspace.
If \(f\)=FUN
is defined on the eigenvalues of H
, then
act_eigfun
performs the following calculation
$$f(H) = \sum_k f(\lambda_k) E_k$$
Examples
H <- matrix(c(0,1,1,1,0,1,1,1,0), nrow=3)
decomp <- spectral(H)
# Calculates H^2.
act_eigfun(decomp, FUN = function(x) x^2)
#> [,1] [,2] [,3]
#> [1,] 2 1 1
#> [2,] 1 2 1
#> [3,] 1 1 2
# Calculates sin(H).
act_eigfun(decomp, FUN = function(x) sin(x))
#> [,1] [,2] [,3]
#> [1,] -0.2578815 0.5835895 0.5835895
#> [2,] 0.5835895 -0.2578815 0.5835895
#> [3,] 0.5835895 0.5835895 -0.2578815
# Calculates H^3.
act_eigfun(decomp, FUN = function(x, y) x^y, 3)
#> [,1] [,2] [,3]
#> [1,] 2 3 3
#> [2,] 3 2 3
#> [3,] 3 3 2