Generate and return a random upper and lower Cholesky factorization.
See the documentation of pm_distChol for details.
See also setCholRand for generating only the upper or lower subset of the Cholesky factor.
- Parameters
-
[in] | mold | : The input scalar of,
-
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),
whose type and kind determines the type and kind of the output rand .
The value of mold is ignored entirely within the algorithm.
|
[in] | ndim | : The input positive scalar of type integer of default kind IK, representing the rank of the matrix (the number of dimensions) of shape (ndim, ndim) .
|
[in] | subset | : The input scalar constant that can be any of the following:
-
the constant uppDia or an object of type uppDia_type implying that the upper-diagonal triangular block of the argument
rand must be used while the lower subset is not referenced.
-
the constant lowDia or an object of type lowDia_type implying that the lower-diagonal triangular block of the argument
rand must be used while the upper subset is not referenced.
This argument is merely a convenience to differentiate the different procedure functionalities within this generic interface.
Beware that the oppsite subset will not be set to zero explicitly and it is the user's responsibility to ensure it.
The generic interface getCholRand can be used to generate random Cholesky factors whose complementary subset elements are all set to zero.
|
- Returns
rand
: The output matrix of shape (1:ndim, 1:ndim)
of the same type and kind as the input argument mold
, containing an upper or lower Cholesky factorization as specified by the input subset
.
Possible calling interfaces ⛓
Generate and return a random upper and lower Cholesky factorization.
This module contains classes and procedures for generating random upper or lower Cholesky factor tria...
- See also
- getCovRand
setCovRand
getCholRand
setCholRand
Example usage ⛓
12 integer(IK) :: isub, itry, ndim
14 type(csp_type) :: subset(
2)
16 type(display_type) :: disp
20 do isub
= 1,
size(subset)
24 real(TKG),
allocatable :: rand(:,:), cov(:,:)
28 call disp%show(
"ndim = getUnifRand(2, 5)")
30 call disp%show(
"[same_type_as(subset(isub)%val, uppDia), same_type_as(subset(isub)%val, lowDia)]")
31 call disp%show( [
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)] )
32 call disp%show(
"rand = getCholRand(mold, ndim, subset(isub)%val)")
36 call disp%show(
"cov = matmul(rand, transpose(rand))")
37 cov
= matmul(rand,
transpose(rand))
38 call disp%show(
"isMatClass(cov, posdefmat)")
46 complex(TKG),
allocatable :: rand(:,:), cov(:,:)
50 call disp%show(
"ndim = getUnifRand(2, 5)")
52 call disp%show(
"[same_type_as(subset(isub)%val, uppDia), same_type_as(subset(isub)%val, lowDia)]")
53 call disp%show( [
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)] )
54 call disp%show(
"rand = getCholRand(mold, ndim, subset(isub)%val)")
58 call disp%show(
"cov = matmul(rand, conjg(transpose(rand)))")
59 cov
= matmul(rand,
conjg(
transpose(rand)))
60 call disp%show(
"isMatClass(cov, posdefmat)")
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 .true. if and only if the input matrix is of the specified input class.
This module contains the derived types for generating allocatable containers of scalar,...
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 LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
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...
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
This module contains abstract and concrete derived types that are required for compile-time resolutio...
type(posdefmat_type), parameter posdefmat
This is a scalar parameter object of type hermitian_type that is exclusively used to signify the Herm...
This is the csp_type type for generating instances of container of scalar unlimited polymorphic objec...
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 ⛓
3[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
7+1.00000000,
+0.999980330
8+0.00000000,
+0.627283892E-2
9cov
= matmul(rand,
transpose(rand))
15[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
19+1.00000000,
+0.486679018
20+0.00000000,
+0.873580813
21cov
= matmul(rand,
transpose(rand))
27[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
31+0.999999940,
+0.948251069,
-0.638649762,
+0.752539873,
+0.112472862
32+0.00000000,
+0.317521393,
-0.753969848,
-0.528783381,
-0.374730885
33+0.00000000,
+0.00000000,
+0.153804898,
+0.328769594,
+0.180891007
34+0.00000000,
+0.00000000,
+0.00000000,
+0.214435145,
+0.288898736
35+0.00000000,
+0.00000000,
+0.00000000,
+0.00000000,
+0.854834855
36cov
= matmul(rand,
transpose(rand))
42[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
46+1.00000000,
+0.683479846,
+0.429321676
47+0.00000000,
+0.729969323,
-0.687118888
48+0.00000000,
+0.00000000,
+0.586131811
49cov
= matmul(rand,
transpose(rand))
55[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
59+1.00000000,
-0.208362281,
+0.350319833,
+0.372993857,
-0.796791613
60+0.00000000,
+0.978051722,
+0.933816254,
-0.696913421,
+0.520424962
61+0.00000000,
+0.00000000,
+0.725479946E-1,
+0.487141728,
-0.178081349
62+0.00000000,
+0.00000000,
+0.00000000,
+0.371322185,
-0.460583270E-1
63+0.00000000,
+0.00000000,
+0.00000000,
+0.00000000,
+0.245859027
64cov
= matmul(rand,
transpose(rand))
70[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
74(
+1.00000000,
+0.00000000), (
-0.696427166,
-0.153193638), (
+0.604950309,
-0.401363343)
75(
+0.00000000,
+0.00000000), (
+0.701085627,
+0.00000000), (
+0.515467882,
-0.441972882)
76(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.109066740,
+0.00000000)
77cov
= matmul(rand,
conjg(
transpose(rand)))
83[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
87(
+0.999999940,
+0.00000000), (
-0.814798534,
-0.564739704), (
-0.445493579,
-0.682549834)
88(
+0.00000000,
+0.00000000), (
+0.131043822,
+0.00000000), (
-0.170492291,
+0.256871045)
89(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.490520924,
+0.00000000)
90cov
= matmul(rand,
conjg(
transpose(rand)))
96[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
100(
+1.00000000,
+0.00000000), (
+0.252333522,
+0.284540087), (
+0.505015373,
+0.750738680E-1), (
+0.466432720,
-0.357902765)
101(
+0.00000000,
+0.00000000), (
+0.924859345,
+0.00000000), (
+0.229453012,
+0.610010564), (
+0.507515609,
+0.244659126)
102(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.560858250,
+0.00000000), (
-0.209694147,
+0.540583134)
103(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.267231241E-1,
+0.00000000)
104cov
= matmul(rand,
conjg(
transpose(rand)))
110[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
114(
+1.00000000,
+0.00000000), (
-0.567369163,
+0.677293225E-3), (
-0.596424758,
-0.248483270)
115(
+0.00000000,
+0.00000000), (
+0.823463321,
+0.00000000), (
-0.262918830,
-0.173736691)
116(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.695142329,
+0.00000000)
117cov
= matmul(rand,
conjg(
transpose(rand)))
123[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
127(
+0.999999940,
+0.00000000), (
-0.754440963,
+0.634528279), (
-0.856003463,
-0.363812804), (
-0.509728849,
-0.400169566E-1)
128(
+0.00000000,
+0.00000000), (
+0.167907178,
+0.00000000), (
-0.238472015,
+0.227033287), (
-0.534852505,
-0.488764077)
129(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.162742957,
+0.00000000), (
-0.239155278,
-0.180429414)
130(
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.351948112,
+0.00000000)
131cov
= matmul(rand,
conjg(
transpose(rand)))
137[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
141+1.00000000,
+0.00000000,
+0.00000000,
+0.00000000,
+0.00000000
142+0.980282724,
+0.197600275,
+0.00000000,
+0.00000000,
+0.00000000
143-0.908162773,
+0.180209935,
+0.377842426,
+0.00000000,
+0.00000000
144-0.815407559E-1,
-0.460282028,
+0.292683821E-1,
+0.883535445,
+0.00000000
145-0.552618802,
-0.425505310,
+0.257496834E-1,
-0.421366304,
+0.579089880
146cov
= matmul(rand,
transpose(rand))
152[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
156+1.00000000,
+0.00000000,
+0.00000000,
+0.00000000
157-0.880598128,
+0.473863810,
+0.00000000,
+0.00000000
158+0.288508415,
+0.154566169,
+0.944919109,
+0.00000000
159-0.450525552,
-0.442106992,
-0.186803147,
+0.752776682
160cov
= matmul(rand,
transpose(rand))
166[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
170+1.00000000,
+0.00000000,
+0.00000000,
+0.00000000,
+0.00000000
171+0.729097605,
+0.684409857,
+0.00000000,
+0.00000000,
+0.00000000
172-0.144098550,
-0.989551783,
+0.477859052E-2,
+0.00000000,
+0.00000000
173-0.484757096,
-0.387064070,
+0.617888629,
+0.483120561,
+0.00000000
174+0.569720805,
-0.377417922,
+0.310855716,
-0.615052938,
+0.240940735
175cov
= matmul(rand,
transpose(rand))
181[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
185+0.999999940,
+0.00000000,
+0.00000000
186-0.997409284,
+0.719356835E-1,
+0.00000000
187-0.688432395,
-0.119444856E-2,
+0.725299478
188cov
= matmul(rand,
transpose(rand))
194[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
198+1.00000000,
+0.00000000
199-0.676224520E-2,
+0.999977171
200cov
= matmul(rand,
transpose(rand))
206[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
210(
+1.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
211(
+0.278139442,
-0.922443509), (
+0.267836601,
+0.00000000), (
+0.00000000,
+0.00000000)
212(
-0.335017473,
-0.695173919), (
+0.441735148,
-0.748096928E-1), (
+0.451408982,
+0.00000000)
213cov
= matmul(rand,
conjg(
transpose(rand)))
219[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
223(
+1.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
224(
-0.794135094,
+0.324585319), (
+0.513803363,
+0.00000000)
225cov
= matmul(rand,
conjg(
transpose(rand)))
231[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
235(
+1.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
236(
+0.369813383,
+0.655070901), (
+0.658878028,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
237(
+0.266635299,
-0.450432628), (
-0.299397439,
+0.220581830), (
+0.766629517,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
238(
+0.374578834,
-0.500194788), (
-0.346734524,
-0.364071816), (
+0.995573103E-1,
+0.434140116), (
+0.397911370,
+0.00000000), (
+0.00000000,
+0.00000000)
239(
+0.518814027,
-0.127440065), (
+0.113355033,
-0.380458713), (
+0.239206612,
+0.511375606), (
+0.463626385,
-0.248699132E-1), (
+0.150665060,
+0.00000000)
240cov
= matmul(rand,
conjg(
transpose(rand)))
246[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
250(
+1.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
251(
-0.807609379,
-0.369952396E-1), (
+0.588556111,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
252(
-0.486296564,
-0.804358244), (
-0.751082450E-1,
+0.330539227), (
+0.403223410E-1,
+0.00000000), (
+0.00000000,
+0.00000000)
253(
+0.230936900,
-0.443333030), (
+0.559189856,
+0.463470697), (
+0.476008654E-1,
-0.332982719), (
+0.330881119,
+0.00000000)
254cov
= matmul(rand,
conjg(
transpose(rand)))
260[
same_type_as(subset(isub)
%val, uppDia),
same_type_as(subset(isub)
%val, lowDia)]
264(
+1.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
265(
-0.738734245,
-0.340231776), (
+0.581819534,
+0.00000000), (
+0.00000000,
+0.00000000), (
+0.00000000,
+0.00000000)
266(
-0.330684155,
+0.502738416), (
+0.273282290,
+0.633378625), (
+0.402554810,
+0.00000000), (
+0.00000000,
+0.00000000)
267(
-0.369890213,
+0.337053239), (
-0.370498240,
-0.404159755), (
-0.477574974,
+0.294691801), (
+0.366116375,
+0.00000000)
268cov
= matmul(rand,
conjg(
transpose(rand)))
- Test:
- test_pm_distChol
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, Monday March 6, 2017, 3:22 pm, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin.
Definition at line 115 of file pm_distChol.F90.