Re: R-alpha: matrix exponentiation

Thomas Lumley (
Wed, 20 Nov 1996 09:14:33 -0800 (PST)

Date: Wed, 20 Nov 1996 09:14:33 -0800 (PST)
From: Thomas Lumley <>
To: Jim Lindsey <>
Subject: Re: R-alpha: matrix exponentiation
In-Reply-To: <>

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: