Re: [R] Efficient way to compute power of a sparse matrix

2007-11-19 Thread Moshe Olshansky
Just a correction to my previous posting - O(N^2.25) algorithm for multiplying two general NxN matrices was too optimistic! There exists an O(N^a) algorithm with a < 2.4, but the constant multiplying N^a is so big that for N around 1000 it seems that one will be unable to end up with significantly

Re: [R] Efficient way to compute power of a sparse matrix

2007-11-19 Thread Moshe Olshansky
Hello Stéphane, Since 20 = 4 + 16 you need 5 matrix multiplications to compute X^20 (2 for X^4, 2 more for X^16 and one more for X^20). If your matrix is NxN, one naive matrix multiplication requires about N^3 operations. In your case N is 900. If it were 1000, 1000^3 is one billion, so 5 matrix m

[R] Efficient way to compute power of a sparse matrix

2007-11-16 Thread Stéphane Dray
Dear all, I would like to compute power of a square non symmetric matrix. This is a part of a simulation study. Matrices are quite large (e.g., 900 by 900), and contains many 0 (more than 99 %). I have try the function mtx.exp of the Biodem package: library(Biodem) m <- matrix(0, 900, 900) i <-