Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] A function for raising a matrix to a power?

Atte Tenkanen

2007-05-06

Replies:

Hi,

Is there a function for raising a matrix to a power? For example if you like to compute A%*%A%*%A, is there an abbreviation similar to A^3?

Atte Tenkanen

> A=rbind(c(1,1),c(-1,-2))
> A
  [,1] [,2]
[1,]   1   1
[2,]  -1  -2
> A^3
  [,1] [,2]
[1,]   1   1
[2,]  -1  -8

But:

> A%*%A%*%A
  [,1] [,2]
[1,]   1   2
[2,]  -2  -5

______________________________________________
R-help@(protected)
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.
©2008 r-help.com - Jax Systems, LLC, U.S.A.