RosettaCodeData/Task/Matrix-exponentiation-operator/Jsish/matrix-exponentiation-opera...

24 lines
655 B
Plaintext

/* Matrix exponentiation, in Jsish */
require('Matrix');
if (Interp.conf('unitTest')) {
var m = new Matrix([[3, 2], [2, 1]]);
; m;
; m.exp(0);
; m.exp(1);
; m.exp(2);
; m.exp(4);
; m.exp(10);
}
/*
=!EXPECTSTART!=
m ==> { height:2, mtx:[ [ 3, 2 ], [ 2, 1 ] ], width:2 }
m.exp(0) ==> { height:2, mtx:[ [ 1, 0 ], [ 0, 1 ] ], width:2 }
m.exp(1) ==> { height:2, mtx:[ [ 3, 2 ], [ 2, 1 ] ], width:2 }
m.exp(2) ==> { height:2, mtx:[ [ 13, 8 ], [ 8, 5 ] ], width:2 }
m.exp(4) ==> { height:2, mtx:[ [ 233, 144 ], [ 144, 89 ] ], width:2 }
m.exp(10) ==> { height:2, mtx:[ [ 1346269, 832040 ], [ 832040, 514229 ] ], width:2 }
=!EXPECTEND!=
*/