Matrix-exponentiation operator: Difference between revisions

add fermat
(add fermat)
Line 1,231:
( scratchpad ) { { 3 2 } { 2 1 } } 4 my-m^n .
{ { 233 144 } { 144 89 } }
 
=={{header|Fermat}}==
Matrix exponentiation for square matrices and integer powers is built in.
<lang fermat>
Array a[2,2]; {illustrate with a 2x2 matrix}
[a]:=[(2/3, 1/3, 4/5, 1/5)];
[a]^-1; {matrix inverse}
[a]^0; {identity matrix}
[a]^2;
[a]^3;
[a]^10;
</lang>
{{out}}
<pre>
[[ -3 / 2, 6, `
5 / 2, -5 ]]
 
[[ 1, 0, `
0, 1 ]]
 
[[ 32 / 45, 52 / 75, `
13 / 45, 23 / 75 ]]
 
[[ 476 / 675, 796 / 1125, `
199 / 675, 329 / 1125 ]]
 
[[ 81409466972 / 115330078125, 135682444612 / 192216796875, `
33920611153 / 115330078125, 56534352263 / 192216796875 ]]</pre>
 
=={{header|Fortran}}==
781

edits