DiagonalMat |
Syntax |
DiagonalMat(L:LIST):MAT DiagMat(L:LIST):MAT |
Description |
Example |
DiagonalMat([3,4,5]); Mat([ [3, 0, 0], [0, 4, 0], [0, 0, 5] ]) ------------------------------- -- fast implementation for high powers of a diagonal matrix Define PowerDiag(M, Exp) If Not IsDiagonal(M) Then Error("PowerDiag: matrix must be diagonal"); EndIf; Return DiagonalMat([ M[I, I]^Exp | I In 1..Len(M) ]); EndDefine; PowerDiag(Identity(3), 200000000); Mat([ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]) ------------------------------- |
See Also |