3. WHAT IS
TRACE?
In linear algebra, the trace of a matrix A, denoted tr(A),
is defined to be the sum of elements on the main
diagonal (from the upper left to the lower right) of A.
4. where denotes the entry on the ith row and ith column of A.
The trace is only defined for a square matrix (n × n).
The trace of an n × n matrix A is defined as
6. Properties
for all square matrices A and B, and all scalars c
A matrix and its transpose have the same trace
This follows immediately from the fact that transposing a square matrix does not
affect elements along the main diagonal.
7. Properties
The matrices in a trace of a product can be switched without changing the result:
If A is an m × n matrix and B is an n × m matrix, then
8. Algorithm
Traverse the matrix along the main diagonal and keep adding to the sum.
for i = 1 : ord
t_sum = t_sum + matrix(i , i);
end
Time Complexity O(n) where n is order of the matrix
Auxiliary Space O(1)