linalg::tr -- trace of a matrix
Introductionlinalg::tr(A) returns the trace of the
square matrix A, i.e., the sum of the diagonal elements of
A.
Call(s)linalg::tr(A)
ParametersA |
- | a square matrix of a domain of category Cat::Matrix |
Returnsan element of the component ring of A.
Related
Functions
Example
1We 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