A^k for matrix multiplication in R?

前端 未结 6 870
故里飘歌
故里飘歌 2020-12-31 08:22

Suppose A is some square matrix. How can I easily exponentiate this matrix in R?

I tried two ways already: Trial 1 with a for-loop hack and Trial 2

6条回答
  •  佛祖请我去吃肉
    2020-12-31 09:06

    A shorter solution with eigenvalue decomposition:

    "%^%" <- function(S, power)
             with(eigen(S), vectors %*% (values^power * t(vectors)))
    

提交回复
热议问题