APL, 32(削除) 32 (削除ここまで) 31 chars
{⍺=0:(⍴⍵)⍴(1+≢⍵)↑1⋄+⍴1⍨1+≢⍵⋄+×ばつ⍨⍣(⍺-1)⊣⍵}
Left argument the power to raise to, right argument the matrix
The. The hardest (most space consuming) bit is building the identity matrix for the case where the desired exponent is 0.
The actual computation is based on the fact that the generalised inner product (.) with + and ×ばつ as operands is effectively the matrix product. This combined with the power ⍣ operator ("repeat") forms the meat of the solution.
APL, 32 chars
{⍺=0:(⍴⍵)⍴(1+≢⍵)↑1⋄+×ばつ⍨⍣(⍺-1)⊣⍵}
Left argument the power to raise to, right argument the matrix
The hardest (most space consuming) bit is building the identity matrix for the case where the desired exponent is 0.
The actual computation is based on the fact that the generalised inner product (.) with + and ×ばつ as operands is effectively the matrix product. This combined with the power ⍣ operator ("repeat") forms the meat of the solution.
APL, (削除) 32 (削除ここまで) 31 chars
{⍺=0:(⍴⍵)⍴1⍨1+≢⍵⋄+×ばつ⍨⍣(⍺-1)⊣⍵}
Left argument the power to raise to, right argument the matrix. The hardest (most space consuming) bit is building the identity matrix for the case where the desired exponent is 0.
The actual computation is based on the fact that the generalised inner product (.) with + and ×ばつ as operands is effectively the matrix product. This combined with the power ⍣ operator ("repeat") forms the meat of the solution.
APL, 32 chars
{⍺=0:(⍴⍵)⍴(1+≢⍵)×ばつ⍨⍣(⍺-1)⊣⍵}
Left argument the power to raise to, right argument the matrix
The hardest (most space consuming) bit is building the identity matrix for the case where the desired exponent is 0.
The actual computation is based on the fact that the generalised inner product (.) with + and ×ばつ as operands is effectively the matrix product. This combined with the power ⍣ operator ("repeat") forms the meat of the solution.