class="resources"
Finds the trace of Input Matrix. You can use this polymorphic VI to find the trace for a real square matrix or a complex square matrix. The data type you wire to the Input Matrix input determines the polymorphic instance to use. Details Example

![]() |
Input Matrix must have as many rows as columns. Its dimensions must also be greater than zero. If Input Matrix is an empty array or is not square, the VI sets trace to NaN and returns an error. |
![]() |
trace is the sum of the main diagonal of Input Matrix. |
![]() |
error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster. |

![]() |
Input Matrix must have as many rows as columns, and its dimensions must be greater than zero. If Input Matrix is an empty array or is not square, the VI sets trace to NaN and returns an error. |
![]() |
trace is the sum of the main diagonal of Input Matrix. |
![]() |
error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster. |
The VI uses the following equation to compute the trace.

where A is Input Matrix, tr(A) is trace, and n is the dimension of Input Matrix.
Refer to the Linear Algebra Calculator VI in the labview\examples\analysis\linaxmpl.llb directory for an example of using the Trace VI.