linalg::tr
-- trace of a matrixlinalg::tr
(A)
returns the trace of the
square matrix A, i.e., the sum of the diagonal elements of
A.
linalg::tr(A)
A |
- | a square matrix of a domain of category Cat::Matrix |
an element of the component ring of A
.
We compute the trace of the following matrix:
>> A := Dom::Matrix(Dom::Integer) (3, 3, (i, j) -> 3*(i - 1) + j)
+- -+ | 1, 2, 3 | | | | 4, 5, 6 | | | | 7, 8, 9 | +- -+
>> linalg::tr(A)
15