Matrix-exponentiation operator: Difference between revisions

Content added Content deleted
m (→‎{{header|Scheme}}: Added a note)
Line 1,902: Line 1,902:
=={{header|Scheme}}==
=={{header|Scheme}}==


For simplicity, the matrix is represented as a list of lists, and no dimension checking occurs.
For simplicity, the matrix is represented as a list of lists, and no dimension checking occurs. This implementation does not work when the exponent is 0.


<lang scheme>
<lang scheme>
Line 1,926: Line 1,926:
((even? exp) (square-matrix (matrix-expo mat (halve exp))))
((even? exp) (square-matrix (matrix-expo mat (halve exp))))
(else (multiply-matrix mat (matrix-expo mat (dec exp))))))
(else (multiply-matrix mat (matrix-expo mat (dec exp))))))


</lang>
</lang>