ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_matrixTrace::getMatMulTrace Interface Reference

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

Detailed Description

Generate and return the multiplicative 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,
  1. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64),
  2. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
  3. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the matrix whose multiplicative 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,
  1. the constant lfpack signifying the linear full packing of the input matrix.
  2. the constant rdpack signifying the rectangular default packing of the input matrix.
  3. the constant rfpack signifying the rectangular full packing of the input matrix.
(optional, default = rdpack)
[in]subset: The input scalar that can be,
  1. the constant uppDia signifying the storage of the upper-diagonal subset of original matrix in the input matrix.
  2. 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
mulTrace : The output scalar of the same type and kind as the input matrix mat, containing the multiplicative trace of the input square matrix.


Possible calling interfaces

use pm_matrixTrace, only: lfpack, rdpack, rfpack, uppDia, lowDia
mulTrace = getMatMulTrace(mat)
mulTrace = getMatMulTrace(mat, pack) ! pack = rdpack
mulTrace = getMatMulTrace(mat, pack, subset) ! pack = rdpack/lfpack, subset = uppDia/lowDia
!
Generate and return the multiplicative trace of an input square matrix of type integer,...
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

1program example
2
3 use iso_fortran_env, only: output_unit
4 use pm_kind, only: SK, IK, LK, CK, RK
6 use pm_matrixCopy, only: getMatCopy, rdpack, rfpack, lfpack
8 use pm_distUnif, only: getUnifRand
9 use pm_io, only: display_type
10
11 implicit none
12
13 integer(IK) :: ndim, itry, ntry = 5
14
15 type(display_type) :: disp
16 disp = display_type(file = "main.out.F90")
17
18 block
19 integer, allocatable :: mat(:,:), rfp(:,:), lfp(:) ! all integer kinds are supported.
20 do itry = 1, ntry
21 call disp%skip()
22 call disp%show("ndim = getUnifRand(1, 7)")
23 ndim = getUnifRand(1, 7)
24 call disp%show("mat = getUnifRand(1, 9, ndim, ndim)")
25 mat = getUnifRand(1, 9, ndim, ndim)
26 call disp%show("mat")
27 call disp%show( mat )
28 call disp%show("getMatMulTrace(mat)")
29 call disp%show( getMatMulTrace(mat) )
30 call disp%show("getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))")
31 call disp%show( getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia)) )
32 call disp%show("getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))")
33 call disp%show( getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia)) )
34 call disp%show("getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)")
35 call disp%show( getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia) )
36 call disp%skip()
37 end do
38 end block
39
40end program example
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.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
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...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter CK
The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I...
Definition: pm_kind.F90:542
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
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.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2ndim = getUnifRand(1, 7)
3mat = getUnifRand(1, 9, ndim, ndim)
4mat
5+1, +5, +1, +3, +5, +4
6+6, +1, +8, +7, +1, +1
7+1, +6, +2, +9, +7, +7
8+6, +8, +9, +1, +5, +3
9+6, +7, +3, +9, +3, +5
10+2, +3, +5, +6, +5, +1
12+6
13getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))
14+6
15getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))
16+6
17getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)
18+900
19
20
21ndim = getUnifRand(1, 7)
22mat = getUnifRand(1, 9, ndim, ndim)
23mat
24+5, +7
25+6, +5
27+25
28getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))
29+25
30getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))
31+25
32getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)
33+30
34
35
36ndim = getUnifRand(1, 7)
37mat = getUnifRand(1, 9, ndim, ndim)
38mat
39+7, +3, +8, +5, +8, +4
40+7, +2, +8, +1, +1, +4
41+2, +9, +3, +8, +6, +7
42+7, +8, +4, +7, +6, +6
43+2, +8, +9, +6, +6, +6
44+5, +9, +9, +4, +6, +3
46+5292
47getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))
48+5292
49getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))
50+5292
51getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)
52+68040
53
54
55ndim = getUnifRand(1, 7)
56mat = getUnifRand(1, 9, ndim, ndim)
57mat
58+3, +7, +5, +3, +8
59+1, +2, +7, +2, +6
60+5, +6, +2, +2, +1
61+2, +1, +9, +4, +3
62+2, +4, +4, +6, +8
64+384
65getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))
66+384
67getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))
68+384
69getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)
70+576
71
72
73ndim = getUnifRand(1, 7)
74mat = getUnifRand(1, 9, ndim, ndim)
75mat
76+2, +7, +9, +2, +7
77+8, +1, +8, +6, +3
78+1, +7, +3, +7, +2
79+6, +6, +9, +6, +5
80+9, +1, +4, +8, +7
82+252
83getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = uppDia))
84+252
85getMatMulTrace(getMatCopy(rdpack, mat, rdpack, subset = lowDia))
86+252
87getMatMulTrace(getMatCopy(lfpack, mat, rdpack, lowDia), lfpack, lowDia)
88+576
89
90
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.

  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, April 23, 2017, 1:36 AM, Institute for Computational Engineering and Sciences (ICES), University of Texas at Austin

Definition at line 1465 of file pm_matrixTrace.F90.


The documentation for this interface was generated from the following file: