> 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@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.