矩陣指數

(1)
$$e^{A} = I + A + A^2/2! + A^3/3! + ...$$
> example(expm)
expm> (m1 <- Matrix(c(1,0,1,1), nc = 2))
2 x 2 Matrix of class "dtrMatrix"
[,1] [,2]
[1,] 1 1
[2,] . 1
expm> (e1 <- expm(m1)) ; e <- exp(1)
2 x 2 Matrix of class "dtrMatrix"
[,1] [,2]
[1,] 2.718282 2.718282
[2,] . 2.718282
expm> stopifnot(all.equal(e1@x, c(e,0,e,e), tol = 1e-15))
expm> (m2 <- Matrix(c(-49, -64, 24, 31), nc = 2))
2 x 2 Matrix of class "dgeMatrix"
[,1] [,2]
[1,] -49 24
[2,] -64 31
expm> (e2 <- expm(m2))
2 x 2 Matrix of class "dgeMatrix"
[,1] [,2]
[1,] -0.7357588 0.5518191
[2,] -1.4715176 1.1036382
expm> (m3 <- Matrix(cbind(0,rbind(6*diag(3),0))))# sparse!
4 x 4 sparse Matrix of class "dtCMatrix"
[1,] . 6 . .
[2,] . . 6 .
[3,] . . . 6
[4,] . . . .
expm> (e3 <- expm(m3)) # upper triangular
4 x 4 Matrix of class "dtrMatrix"
[,1] [,2] [,3] [,4]
[1,] 1 6 18 36
[2,] . 1 6 18
[3,] . . 1 6
[4,] . . . 1
> str(e1)
Formal class 'dtrMatrix' [package "Matrix"] with 5 slots
..@ x : num [1:4] 2.72 0 2.72 2.72
..@ Dim : int [1:2] 2 2
..@ Dimnames:List of 2
.. ..$: NULL .. ..$ : NULL
..@ uplo : chr "U"
..@ diag : chr "N"


page revision: 0, last edited: 26 Oct 2011 04:53