Compute the power of a matrix in R (1) I am looking for a package for computing the power of a matrix. If you have some good recommendation please let me know.
(2) I searched on the internet and followed what some said to install a package called "Malmig" in R but after selecting the mirror site, it failed:

In install.packages("Malmig") : package ‘Malmig’ is not available

Some idea why?
Thanks!
 A: Package expm provides the matrix %^% number operator notation for its function matpow():
> library(expm)    
> mat <- matrix(1:9, nrow=3)
> mat %^% 2
     [,1] [,2] [,3]
[1,]   30   66  102
[2,]   36   81  126
[3,]   42   96  150

# check
> mat %*% mat
     [,1] [,2] [,3]
[1,]   30   66  102
[2,]   36   81  126
[3,]   42   96  150

There's also sqrtm() for taking roots and expm() for matrix exponential.
A: There is the following code you can write:

library(Biodem)
  png(filename="images/mtx.exp_%03d.png" ,width=480, height=480)
Name: mtx.exp
Title: Calculates the n-th power of a matrix
Aliases: mtx.exp
Keywords: array manip methods
** Examples
test<-matrix(c(1:16), 4,4)
  pow.test<-mtx.exp(test,10)
  pow.test

for more details:http://rgm2.lab.nig.ac.jp/RGM2/R_man-2.9.0/library/Biodem/man/mtx.exp.html
A: Or... you could use my own package, 'powerplus' (function 'Matpow'), that allows you to raise any diagonalizable matrix to any power (even complex). For non-diagonalizable matrices, you have the same capabilities as package expm (incidentally, I use it in Matpow's code). To the best of my knowledge, it currently is the most comprehensive R package that exists to deal with matrix exponentiation. Version 3.0 extends capabilities to (some) non-diagonalizable matrices too.
A: You can also use the matrixcalc package, which also provides other matrix operations:
> require(matrixcalc)
> mat <- matrix(1:9, nrow=3)
> matrix.power(mat,2)
     [,1] [,2] [,3]
[1,]   30   66  102
[2,]   36   81  126
[3,]   42   96  150
> mat%*%mat
     [,1] [,2] [,3]
[1,]   30   66  102
[2,]   36   81  126
[3,]   42   96  150

