See mtx.exp  in the Malmig package  which is more
efficient than a simple recurvsive routine or alternatively,
%^%             in Lindsey's rmutil package

HTH

ken

> Hi,
>
> Is there a function for raising a matrix to a power? For example if  
> you like to compute A%*%A%*%A, is there an abbreviation similar to  
> A^3?
>
> Atte Tenkanen
>
> > A=rbind(c(1,1),c(-1,-2))
> > A
>      [,1] [,2]
> [1,]    1    1
> [2,]   -1   -2
> > A^3
>      [,1] [,2]
> [1,]    1    1
> [2,]   -1   -8
>
> But:
>
> > A%*%A%*%A
>      [,1] [,2]
> [1,]    1    2
> [2,]   -2   -5

--
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
Département Neurosciences Intégratives
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.pizzerialesgemeaux.com/u846/

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to