For a square matrix , its trace is defined as the sum of its diagonal elements: The trace is not defined for non-square matrices.