[R] Multiplication of Matrices

John Fox jfox at mcmaster.ca
Wed Oct 9 13:39:08 CEST 2002


Dear Jason and Kevin,

At 08:51 AM 10/9/2002 +1300, Jason Turner wrote:
>On Wed, Oct 09, 2002 at 08:23:27PM +1300, Ko-Kang Kevin Wang wrote:
> > Suppose I have a matrix, A.  Is there an easy way to find A^{n}?
>
>Jim Lindsey's package rmutil (Repeated Measures Utilities) has
>the matrix exponential function mexp - very nice.
>
>http://alpha.luc.ac.be/~jlindsey/rcode.html

I haven't seen Jim Lindsey's function, but how about the following?

         mp <- function (X, p) if (p == 1) return(X) else X %*% Recall(X, p-1)

Regards,
  John

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list