ParaMonte Fortran 2.0.0 Parallel Monte Carlo and Machine Learning LibrarySee the latest version documentation.
pm_matrixTrace Module Reference

This module contains procedures and generic interfaces for computing the additive or multiplicative trace of a given square matrix in arbitrary packing formats. More...

## Data Types

interface  getMatMulTrace
Generate and return the multiplicative trace of an input square matrix of type integer, complex, or real of arbitrary kind.
More...

interface  getMatMulTraceLog
Generate and return the natural logarithm of the multiplicative trace of an input square matrix of type integer, complex, or real of arbitrary kind.
More...

interface  getMatTrace
Generate and return the trace of an input square matrix of type integer, complex, or real of arbitrary kind.
More...

## Variables

character(*, SK), parameter MODULE_NAME = "@pm_matrixPack"

## Detailed Description

This module contains procedures and generic interfaces for computing the additive or multiplicative trace of a given square matrix in arbitrary packing formats.

In linear algebra, the trace of a square 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$$.
The trace is only defined for a square matrix $$(n\times n)$$.
It can be proven that the trace of a matrix is the sum of its (complex) eigenvalues (counted with multiplicities).
It can also be proven that $$tr(AB) = tr(BA)$$ for any two matrices $$A$$ and $$B$$.
This implies that similar matrices have the same trace.
As a consequence one can define the trace of a linear operator mapping a finite-dimensional vector space into itself, since all matrices describing such an operator with respect to a basis are similar.
The trace is related to the derivative of the determinant (through Jacobi formula).

The trace of an $$(n\times n)$$ square matrix $$A$$ is defined as,

$$\up{tr} (\mathbf {A} ) = \sum_{i=1}^{n}a_{ii} = a_{11} + a_{22} + \dots + a_{nn} ~,$$

where $$a_{ii}$$ denotes the entry on the $$i$$th row and $$i$$th column of $$A$$.
The entries of $$A$$ can be real numbers or (more generally) complex numbers.

Note
The trace is not defined for non-square matrices.
Expressions like $$tr(exp(A))$$, where $$A$$ is a square matrix, occur frequently in some fields (e.g. multivariate statistical theory), that a shorthand notation has become common,

$$\up{tre}(A) = \up{tr}(\exp(A)) ~.$$

$$\up{tre}$$ is sometimes referred to as the exponential trace function and is used in the Goldenâ€“Thompson inequality.

This module additionally also computes the multiplicative trace function of a square-matrix which is defined as,

$$\up{trl}(\mathbf{A}) = \prod_{i=1}^{n} a_{ii} = a_{11} \times a_{22} \times \dots \times a_{nn} ~,$$

where $$a_{ii}$$ denotes the entry on the $$i$$th row and $$i$$th column of $$A$$.
The entries of $$A$$ can be real numbers or (more generally) complex numbers.
This multiplicative definition of trace appears in the computation of the determinant of square positive definite matrices.

pm_matrixDet
Test:
test_pm_matrixIndex

Final Remarks â›“

If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.

1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

## ◆ MODULE_NAME

 character(*,SK), parameter pm_matrixTrace::MODULE_NAME = "@pm_matrixPack"

Definition at line 80 of file pm_matrixTrace.F90.