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 Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, Suppose I have a matrix, A. Is there an easy way to find A^{n}? I mean, I can do something like: A %*% A %*% A %*% A for A^4, but if I want A^{10} it would be kind of annoying... Cheers, Kevin ------------------------------------------------------------------------------ Ko-Kang Kevin Wang Postgraduate PGDipSci Student Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 9 Oct 2002, Ko-Kang Kevin Wang wrote:> Suppose I have a matrix, A. Is there an easy way to find A^{n}? > > I mean, I can do something like: > A %*% A %*% A %*% A > for A^4, but if I want A^{10} it would be kind of annoying...Use the eigendecomposition. If A = V %*% diag(lam) %*% t(V), then A^n = V %*% diag(lam^n) %*% t(V). More care (including complex conjugates) is needed if the eigendecomposition is complex, but the method still works. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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.htmlI 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._