Skip to content

matrix exponential: M^0

1 message · Federico Calboli

#
Dear All,

Thanks for all the help. I tried to implement Stephane Dray's suggestion
and Erin Hodgess function with the following matrices:
[,1] [,2]
[1,]    2    1
[2,]    1    3
[,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    2    3    4
[,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

But I run in a number of troubles, probably my fault. I also tried
MatrixExp from the library msm, but I failed to understand how to use
it. 

anyway, as my linear algebra is too poor for any intelligent
decomposition and whatnot, and I wanted a function, I went for the brute
force approach.


mtx.exp<-function(X,n){
if (n==0) {
phi<-diag(rep(1,length(X[1,])))
return(phi)
}
if (n==1) {
phi<-X
return(phi)
}
X1<-X
for (i in 2:n) {
X<-X%*%X1
}
phi<-X
return(phi)
}

I would imagine this approach would be memory inefficient; would it
incurr in other problems? 

Again, many thanks to all for the invaluable help.

Regards,

Federico Calboli