Jump to content

Matrix-exponentiation operator: Difference between revisions

m (→‎{{header|Scheme}}: Added a note)
Line 1,914:
(apply + (map * row col)))
 
(define (multiply-matrix-multiply m1 m2)
(map
(lambda (row)
Line 1,921:
m1))
 
(define (matrix-expoexp mat exp)
 
(define (matrix-expo mat exp)
(cond ((= exp 1) mat)
((even? exp) (square-matrix (matrix-expoexp mat (halve exp))))
(else (multiply-matrix-multiply mat (matrix-expoexp mat (dec exp))))))
 
(define (square-matrix mat)
(multiply-matrix mat mat))
</lang>
 
 
{{out}}
<pre>
> (matrix-exp '((3 2) (2 1)) 50)
((16130531424904581415797907386349 9969216677189303386214405760200)
(9969216677189303386214405760200 6161314747715278029583501626149))
</pre>
 
=={{header|Seed7}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.