ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_matrixDet Module Reference

This module contains procedures and generic interfaces relevant to the computation of the determinants of square matrices.
More...

Data Types

interface  getMatDet
 Generate and return the determinant of the input general square matrix.
More...
 
interface  getMatDetSqrt
 Generate and return the square-root of the determinant of the input positive-definite square matrix. More...
 
interface  getMatDetSqrtLog
 Generate and return the natural logarithm of the square-root of the determinant of the input positive-definite square matrix. More...
 
interface  setMatDet
 Return the determinant of the input square matrix. More...
 
interface  setMatDetSqrt
 Return the determinant of the input positive-definite square matrix. More...
 
interface  setMatDetSqrtLog
 Return the natural logarithm of the square-root of the determinant of the input positive-definite square matrix. More...
 

Variables

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

Detailed Description

This module contains procedures and generic interfaces relevant to the computation of the determinants of square matrices.

The determinant is a scalar value that is a function of the entries of a square matrix.
It characterizes some properties of the matrix and the linear map represented by the matrix.
In particular, the determinant is nonzero if and only if the matrix is invertible and the linear map represented by the matrix is an isomorphism.
The determinant of a product of matrices is the product of their determinants (the preceding property is a corollary of this one).
The determinant of a matrix \(A\) is denoted \(\det(A)\), or \(|A|\).
The determinant of a \(2 \times 2\) matrix is,

\begin{equation} \begin{vmatrix}a&b\\c&d\end{vmatrix} = ad - bc ~, \end{equation}

and the determinant of a \(3 \times 3\) matrix is,

\begin{equation} \begin{vmatrix}a&b&c\\d&e&f\\g&h&i\end{vmatrix} = aei + bfg + cdh - ceg - bdi - afh ~. \end{equation}

The determinant of an \(n \times n\) matrix can be defined in several equivalent ways.
The Leibniz formula expresses the determinant as a sum of signed products of matrix entries such that each summand is the product of \(n\) different entries, and the number of these summands is \(n!\), the factorial of \(n\) (the product of the \(n\) first positive integers).
The Laplace expansion expresses the determinant of an \(n\times n\) matrix as a linear combination of determinants of \((n-1)\times (n-1)\) submatrices.
Gaussian elimination expresses the determinant as the product of the diagonal entries of a diagonal matrix that is obtained by a succession of elementary row operations.
Determinants are used for defining the characteristic polynomial of a matrix, whose roots are the eigenvalues.
In geometry, the signed \(n\)-dimensional volume of a \(n\)-dimensional parallelepiped is expressed by a determinant.
This is used in calculus with exterior differential forms and the Jacobian determinant, in particular for changes of variables in multiple integrals.

Properties of the determinant

The determinant is the unique function defined on the \(n\times n\) matrices that has the four following properties:

  1. The determinant of the identity matrix is 1.
  2. The determinant is a homogeneous function, i.e.,

    \begin{equation} \det(cA) = c^{n}\det(A) ~,~ \text{for an} ~n\times n~ \text{matrix} ~A ~. \end{equation}

  3. The exchange of two rows (or of two columns) multiplies the determinant by −1.
  4. Multiplying a row (or a column) by a number multiplies the determinant by this number.
  5. Adding to a row (or a column) a multiple of another row (or column) does not change the determinant.
  6. If some column can be expressed as a linear combination of the other columns (i.e. the columns of the matrix form a linearly dependent set), the determinant is \(0\).
    As a special case, this includes: if some column is such that all its entries are zero, then the determinant of that matrix is \(0\).
  7. Adding a scalar multiple of one column to another column does not change the value of the determinant.
    This is a consequence of multilinearity and being alternative:
    By multilinearity the determinant changes by a multiple of the determinant of a matrix with two equal columns, which determinant is \(0\), since the determinant is alternating.
    If \(A\) is a triangular matrix, i.e., \(a_{ij} = 0\), whenever \(i > j\) or, alternatively, whenever \(i < j\), then its determinant equals the product of the diagonal entries:

    \begin{equation} \det(A) = a_{11}a_{22}\cdots a_{nn} = \prod _{i=1}^{n}a_{ii} ~. \end{equation}

    Indeed, such a matrix can be reduced, by appropriately adding multiples of the columns with fewer nonzero entries to those with more entries, to a diagonal matrix (without changing the determinant).
  8. The determinant of a general square matrix mat whose LUP factorization lup(:,:) is returned by setMatLUP can be computed as (-1)**nswap * getMatMulTrace(lup), where nswaps is the number of swaps made to rows of the original mat compute its lup.
    In other words, nswap = count([(rperm(i) /= i, i = 1, size(rperm))] where rperm is the row permutation vector returned by setMatLUP.
  9. The determinant of a positive-definite square matrix mat whose upper or lower Cholesky factorization chol(:,:) is returned by setMatChol is the square of the product of the diagonal elements of its Cholesky factorization and, by definition, is always a positive real number.
See also
pm_matrixLUP
pm_matrixChol
pm_matrixTrace
pm_matrixTrans
pm_matrixInv
Wikipedia Determinant
Wolfram Determinant
Test:
test_pm_matrixDet


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.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  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, Oct 18, 2009, 4:10 PM, Houghton, Michigan

Variable Documentation

◆ MODULE_NAME

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

Definition at line 106 of file pm_matrixDet.F90.