title: Matrix power in R
body: <p>Trying to compute the power of a matrix in R, I found that package <code>expm</code> implements the operator <a href="http://finzi.psych.upenn.edu/R/library/expm/html/matpow.html" rel="noreferrer">%^%</a>. </p>
  
  <p>So x %^% k computes the k-th power of a matrix. </p>
  
  <pre><code>&gt; A&lt;-matrix(c(1,3,0,2,8,4,1,1,1),nrow=3)
  
  &gt; A %^% 5
        [,1]  [,2] [,3]
  [1,]  6469 18038 2929
  [2,] 21837 60902 9889
  [3,] 10440 29116 4729
  </code></pre>
  
  <p>but, to my surprise:</p>
  
  <pre><code>&gt; A
       [,1] [,2] [,3]
  [1,]  691 1926  312
  [2,] 2331 6502 1056
  [3,] 1116 3108  505
  </code></pre>
  
  <p>somehow the initial matrix A has changed to A %^% 4 !!!</p>
  
  <p>How do you perform the matrix power operation?</p>