Re: R-alpha: matrix exponentiation

Thomas Lumley (thomas@biostat.washington.edu)
Wed, 20 Nov 1996 09:14:33 -0800 (PST)


Date: Wed, 20 Nov 1996 09:14:33 -0800 (PST)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: Jim Lindsey <jlindsey@luc.ac.be>
Subject: Re: R-alpha: matrix exponentiation
In-Reply-To: <9611200831.AA00309@alpha.luc.ac.be>

On Wed, 20 Nov 1996, Jim Lindsey wrote:

> 3.Here is a matrix exponentiation function for anyone working on
>   stochastic processes. If anyone knows a better algorithm than brute
>   force, please let me know. Jim

There is a *much* better algorithm, at least for symmetric matrices.  Get 
the eigendecomposition and work with that 
(this function needs argument checking, of course)
 mexp2<-function (mat, n) 
{
        ei <- eigen(mat)
        t(ei$vectors) %*% diag(exp(ei$values)) %*% ei$vectors
}

I think that you can do something similar with the singular value 
decomposition for general square matrices but I would have to look it up.


thomas lumley
UW biostatistics
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-