Generate and return the trace of an input square matrix of type integer
, complex
, or real
of arbitrary kind.
See the documentation of pm_matrixTrace for more details.
- Parameters
-
[in] | mat | : The input non-zero-order matrix of shape (1 : ndim * (ndim - 1) / 2 or (1:ndim, 1:ndim) of,
-
type
integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
-
type
complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the matrix whose trace is to be computed.
It can be of rank 1 (of shape (1 : ndim * (ndim - 1) / 2 ) if and only if the input argument mat is present and set to lfpack.
|
[in] | pack | : The input scalar that can be,
-
the constant lfpack signifying the linear full packing of the input matrix.
-
the constant rdpack signifying the rectangular default packing of the input matrix.
-
the constant rfpack signifying the rectangular full packing of the input matrix.
(optional, default = rdpack) |
[in] | subset | : The input scalar that can be,
-
the constant uppDia signifying the storage of the upper-diagonal subset of original matrix in the input
matrix .
-
the constant lowDia signifying the storage of the lower-diagonal subset of original matrix in the input
matrix .
(optional. It must be present if and only if the input argument is present and set to either lfpack or rfpack.) |
- Returns
trace
: The output scalar of the same type and kind as the input matrix mat
, containing the trace of the input square matrix.
Possible calling interfaces ⛓
!
Generate and return the trace of an input square matrix of type integer, complex, or real of arbitrar...
This module contains procedures and generic interfaces for computing the additive or multiplicative t...
- Warning
- The input matrix must correspond to a square matrix or a triangular subset of a non-zero-order square matrix.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
The
pure
procedure(s) documented herein become impure
when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1
.
By default, these procedures are pure
in release
build and impure
in debug
and testing
builds.
- See also
- getMatTrace
getMatMulTrace
getMatMulTraceLog
pm_matrixPack
pm_matrixSubset
Example usage ⛓
3 use iso_fortran_env,
only:
output_unit
13 integer(IK) :: ndim, itry, ntry
= 5
15 type(display_type) :: disp
19 integer,
allocatable :: mat(:,:), rfp(:,:), lfp(:)
22 call disp%show(
"ndim = getUnifRand(1, 7)")
24 call disp%show(
"mat = getUnifRand(1, 9, ndim, ndim)")
30 call disp%show(
"getMatTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))")
32 call disp%show(
"getMatTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))")
34 call disp%show(
"getMatTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)")
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
Generate and return a copy of a desired subset of the input source matrix of arbitrary shape (:) or (...
This module contains classes and procedures for computing various statistical quantities related to t...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter CK
The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
This module contains procedures and generic interfaces relevant to copying (diagonal or upper/lower t...
This module contains abstract and concrete derived types that are required for compile-time resolutio...
type(lowDia_type), parameter lowDia
This is a scalar parameter object of type lowDia_type that is exclusively used to request lower-diago...
type(uppLowDia_type), parameter uppLowDia
This is a scalar parameter object of type uppLowDia_type that is exclusively used to request full dia...
type(uppLow_type), parameter uppLow
This is a scalar parameter object of type uppLow_type that is exclusively used to request upper-lower...
type(uppDia_type), parameter uppDia
This is a scalar parameter object of type uppDia_type that is exclusively used to request upper-diago...
type(dia_type), parameter dia
This is a scalar parameter object of type dia_type that is exclusively used to request unit (or Ident...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
5+6,
+9,
+2,
+1,
+6,
+7,
+3
6+2,
+8,
+9,
+6,
+1,
+1,
+6
7+8,
+6,
+5,
+8,
+3,
+9,
+2
8+3,
+2,
+6,
+3,
+5,
+9,
+6
9+4,
+8,
+5,
+2,
+6,
+2,
+6
10+6,
+2,
+7,
+4,
+2,
+1,
+5
11+4,
+5,
+9,
+7,
+4,
+4,
+6
- Test:
- test_pm_matrixTrace
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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, April 23, 2017, 1:36 AM, Institute for Computational Engineering and Sciences (ICES), University of Texas at Austin
Definition at line 161 of file pm_matrixTrace.F90.