Re: [R] How do I write a sum of matrixes??

From: Alberto Monteiro <albmont_at_centroin.com.br>
Date: Tue, 06 May 2008 16:23:38 -0200

> 3) Bill Venables offered this about a week ago in this list:
> --------------
> This is probably as good a way as any way for this kind of problem.
> First define a binary operator:
>
> > "%^%" <- function(x, n)
> with(eigen(x), vectors %*% (values^n * t(vectors)))
>
This example only works for _diagonalizable_ matrices. It crashes, for example, in cases like:

m <- rbind(c(1,1,0), c(0,1,1), c(0,0,1)) m %^% 2
m %*% m

Alberto Monteiro



R-help_at_r-project.org 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. Received on Tue 06 May 2008 - 18:40:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 May 2008 - 20:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive