Skip to content
Prev 65643 / 398506 Next

matrix program

On Wed, 9 Mar 2005 15:24:45 -0400 Owen Buchner wrote:

            
Are you looking for something like this toy example?

Generate a matrix mm and a vector xx:

R> mm <- matrix(rep(1, 4), ncol = 2)
R> xx <- rep(1, 2)
R> mm
     [,1] [,2]
[1,]    1    1
[2,]    1    1
R> xx
[1] 1 1

And then pre-multiply 10 times by mm:

R> for(i in 1:10) xx <- mm %*% xx
R> xx
     [,1]
[1,] 1024
[2,] 1024

which in this case is of course just 2^10.

hth,
Z