RosettaCodeData/Task/Matrix-exponentiation-operator/Chapel/matrix-exponentiation-operator-1.chapel
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00:00

12 lines
264 B
Text

proc **(a, e) {
// create result matrix of same dimensions
var r:[a.domain] a.eltType;
// and initialize to identity matrix
forall ij in r.domain do
r(ij) = if ij(1) == ij(2) then 1 else 0;
for 1..e do
r *= a;
return r;
}