61 logical(
LK) :: assertion
62 integer(
IK) ,
parameter :: nd
= 10_IK
63 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
64 real(
RK) ,
parameter :: ellVolCoef_ref
= acos(
-1._RK)
**(
0.5_RK*nd)
/ gamma(
0.5_RK*nd
+1._RK)
65 real(
RK) :: ellVolCoef
66 real(
RK) :: difference
67 ellVolCoef
= getEllVolCoef(nd
= nd)
68 difference
= abs(ellVolCoef
- ellVolCoef_ref)
69 assertion
= difference
< tolerance
70 if (
test%traceable
.and. .not. assertion)
then
72 write(
test%disp
%unit,
"(*(g0,:,' '))")
73 write(
test%disp
%unit,
"(*(g0,:,' '))")
"ellVolCoef_ref = ", ellVolCoef_ref
74 write(
test%disp
%unit,
"(*(g0,:,' '))")
"ellVolCoef = ", ellVolCoef
75 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
76 write(
test%disp
%unit,
"(*(g0,:,' '))")
84 logical(
LK) :: assertion
85 integer(
IK) ,
parameter :: nd
= 11_IK
86 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
87 real(
RK) ,
parameter :: ellVolCoef_ref
= acos(
-1._RK)
**(
0.5_RK*nd)
/ gamma(
0.5_RK*nd
+1._RK)
88 real(
RK) :: ellVolCoef
89 real(
RK) :: difference
92 ellVolCoef
= getEllVolCoef(nd
= nd)
94 difference
= abs(ellVolCoef
- ellVolCoef_ref)
95 assertion
= difference
< tolerance
96 if (
test%traceable
.and. .not. assertion)
then
98 write(
test%disp
%unit,
"(*(g0,:,' '))")
99 write(
test%disp
%unit,
"(*(g0,:,' '))")
"ellVolCoef_ref = ", ellVolCoef_ref
100 write(
test%disp
%unit,
"(*(g0,:,' '))")
"ellVolCoef = ", ellVolCoef
101 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
102 write(
test%disp
%unit,
"(*(g0,:,' '))")
110 logical(
LK) :: assertion
111 integer(
IK) ,
parameter :: nd
= 10_IK
112 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
113 real(
RK) ,
parameter :: logEllVolCoef_ref
= log(
acos(
-1._RK)
**(
0.5_RK*nd)
/ gamma(
0.5_RK*nd
+1._RK) )
114 real(
RK) :: logEllVolCoef
115 real(
RK) :: difference
116 logEllVolCoef
= getLogEllVolCoef(nd
= nd)
117 difference
= abs(logEllVolCoef
- logEllVolCoef_ref)
118 assertion
= difference
< tolerance
119 if (
test%traceable
.and. .not. assertion)
then
121 write(
test%disp
%unit,
"(*(g0,:,' '))")
122 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logEllVolCoef_ref = ", logEllVolCoef_ref
123 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logEllVolCoef = ", logEllVolCoef
124 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
125 write(
test%disp
%unit,
"(*(g0,:,' '))")
133 logical(
LK) :: assertion
134 integer(
IK) ,
parameter :: nd
= 11_IK
135 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
136 real(
RK) ,
parameter :: logEllVolCoef_ref
= log(
acos(
-1._RK)
**(
0.5_RK*nd)
/ gamma(
0.5_RK*nd
+1._RK) )
137 real(
RK) :: logEllVolCoef
138 real(
RK) :: difference
141 logEllVolCoef
= getLogEllVolCoef(nd
= nd)
143 difference
= abs(logEllVolCoef
- logEllVolCoef_ref)
144 assertion
= difference
< tolerance
145 if (
test%traceable
.and. .not. assertion)
then
147 write(
test%disp
%unit,
"(*(g0,:,' '))")
148 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logEllVolCoef_ref = ", logEllVolCoef_ref
149 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logEllVolCoef = ", logEllVolCoef
150 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
151 write(
test%disp
%unit,
"(*(g0,:,' '))")
159 logical(
LK) :: assertion
160 integer(
IK) ,
parameter :: nd
= 10_IK
161 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
162 real(
RK) ,
parameter :: logVolUnitBall_ref
= log(
acos(
-1._RK)
**(
0.5_RK*nd)
/ gamma(
0.5_RK*nd
+1._RK) )
163 real(
RK) :: logVolUnitBall
164 real(
RK) :: difference
166 difference
= abs(logVolUnitBall
- logVolUnitBall_ref)
167 assertion
= difference
< tolerance
168 if (
test%traceable
.and. .not. assertion)
then
170 write(
test%disp
%unit,
"(*(g0,:,' '))")
171 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolUnitBall_ref = ", logVolUnitBall_ref
172 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolUnitBall = ", logVolUnitBall
173 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
174 write(
test%disp
%unit,
"(*(g0,:,' '))")
182 logical(
LK) :: assertion
183 integer(
IK) ,
parameter :: nd
= 11_IK
184 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
185 real(
RK) ,
parameter :: logVolUnitBall_ref
= log(
acos(
-1._RK)
**(
0.5_RK*nd)
/ gamma(
0.5_RK*nd
+1._RK) )
186 real(
RK) :: logVolUnitBall
187 real(
RK) :: difference
192 difference
= abs(logVolUnitBall
- logVolUnitBall_ref)
193 assertion
= difference
< tolerance
194 if (
test%traceable
.and. .not. assertion)
then
196 write(
test%disp
%unit,
"(*(g0,:,' '))")
197 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolUnitBall_ref = ", logVolUnitBall_ref
198 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolUnitBall = ", logVolUnitBall
199 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
200 write(
test%disp
%unit,
"(*(g0,:,' '))")
210 logical(
LK) :: assertion
212 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
213 real(
RK) ,
parameter :: LogVolUnitBall_ref(
0:
6)
= log([
1._RK,
2._RK,
acos(
-1._RK),
4*acos(
-1._RK)
/3,
acos(
-1._RK)
**2/2,
8*acos(
-1._RK)
**2/15,
acos(
-1._RK)
**3/6])
214 real(
RK) :: logVolUnitBall
215 real(
RK) :: difference
218 difference
= abs(logVolUnitBall
- LogVolUnitBall_ref(nd))
219 assertion
= difference
< tolerance
220 if (
test%traceable
.and. .not. assertion)
then
222 write(
test%disp
%unit,
"(*(g0,:,' '))")
223 write(
test%disp
%unit,
"(*(g0,:,' '))")
"nd = ", nd
224 write(
test%disp
%unit,
"(*(g0,:,' '))")
"LogVolUnitBall_ref(nd) = ", LogVolUnitBall_ref(nd)
225 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolUnitBall = ", logVolUnitBall
226 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
227 write(
test%disp
%unit,
"(*(g0,:,' '))")
238 logical(
LK) :: assertion
240 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
241 real(
RK) ,
parameter :: SurfUnitBall_ref(
0:
8)
= [
0._RK,
2._RK,
2*acos(
-1._RK),
4*acos(
-1._RK),
2*acos(
-1._RK)
**2,
8*acos(
-1._RK)
**2/3,
acos(
-1._RK)
**3,
16*acos(
-1._RK)
**3/15,
acos(
-1._RK)
**4/3]
242 real(
RK) :: surfUnitBall
243 real(
RK) :: difference
245 surfUnitBall
= exp(getLogSurfUnitBall(nd
= nd))
246 difference
= abs(surfUnitBall
- SurfUnitBall_ref(nd))
247 assertion
= difference
< tolerance
248 if (
test%traceable
.and. .not. assertion)
then
250 write(
test%disp
%unit,
"(*(g0,:,' '))")
251 write(
test%disp
%unit,
"(*(g0,:,' '))")
"nd = ", nd
252 write(
test%disp
%unit,
"(*(g0,:,' '))")
"SurfUnitBall_ref(nd) = ", SurfUnitBall_ref(nd)
253 write(
test%disp
%unit,
"(*(g0,:,' '))")
"surfUnitBall = ", surfUnitBall
254 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
255 write(
test%disp
%unit,
"(*(g0,:,' '))")
264 logical(
LK) :: assertion
265 integer(
IK) ,
parameter :: nd
= 10_IK
266 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
267 real(
RK) ,
parameter :: logSqrtDetCovMat
= 2._RK
268 real(
RK) ,
parameter :: logVolEll_ref
= 2.936157686464955_RK
269 real(
RK) :: logVolEll
270 real(
RK) :: difference
271 logVolEll
= getLogVolEll(nd
= nd, logSqrtDetCovMat
= logSqrtDetCovMat)
272 difference
= abs(logVolEll
- logVolEll_ref)
273 assertion
= difference
< tolerance
274 if (
test%traceable
.and. .not. assertion)
then
276 write(
test%disp
%unit,
"(*(g0,:,' '))")
277 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolEll_ref = ", logVolEll_ref
278 write(
test%disp
%unit,
"(*(g0,:,' '))")
"logVolEll = ", logVolEll
279 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
280 write(
test%disp
%unit,
"(*(g0,:,' '))")
293 logical(
LK) :: assertion
294 integer(
IK) ,
parameter :: nEllipsoid
= 2_IK
295 real(
RK) ,
parameter :: tolerance
= 1.e-10_RK
296 integer(
IK) ,
parameter :: nd
= 2_IK
297 real(
RK) ,
parameter :: LogSqrtDetCovMat(nEllipsoid)
= [ (
log(
real(i,
RK)), i
= 1, nEllipsoid) ]
298 real(
RK) ,
parameter :: EllipsoidVolume_ref(
*)
= [
1.144729885849400_RK,
1.837877066409345_RK ]
299 real(
RK),
allocatable :: EllipsoidVolume(:)
300 real(
RK),
allocatable :: Difference(:)
301 EllipsoidVolume
= getLogVolEll(nd
= nd, LogSqrtDetCovMat
= LogSqrtDetCovMat)
303 if (
allocated(Difference))
deallocate(Difference);
allocate(Difference,
mold = EllipsoidVolume)
304 Difference
= abs(EllipsoidVolume
- EllipsoidVolume_ref)
305 assertion
= all(Difference
< tolerance)
306 if (
test%traceable
.and. .not. assertion)
then
308 write(
test%disp
%unit,
"(*(g0,:,' '))")
309 write(
test%disp
%unit,
"(*(g0,:,' '))")
"EllipsoidVolume_ref = ", EllipsoidVolume_ref
310 write(
test%disp
%unit,
"(*(g0,:,' '))")
"EllipsoidVolume = ", EllipsoidVolume
311 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", Difference
312 write(
test%disp
%unit,
"(*(g0,:,' '))")
320 use pm_domainBall,
only: getUnifRand
323 logical(
LK) :: assertion
324 integer(
IK) ,
parameter :: nd
= 2_IK
325 real(
RK) ,
parameter :: mean(nd)
= [
1._RK,
2._RK ]
326 real(
RK) ,
parameter :: CovMat(nd,nd)
= reshape( [
1._RK,
0.5_RK,
0.5_RK,
1._RK ], shape
= shape(CovMat) )
327 real(
RK) ,
parameter :: choDia(nd)
= [
1._RK,
0.866025403784439_RK ]
328 real(
RK) ,
parameter :: choLow(nd,nd)
= reshape( [
1._RK,
0.5_RK,
0.5_RK,
1._RK ], shape
= shape(CovMat) )
329 real(
RK) ,
parameter :: invCov(nd,nd)
= reshape( [
+1.333333333333333_RK,
-0.666666666666667_RK &
330 ,
-0.666666666666667_RK,
+1.333333333333333_RK ]
&
331 , shape
= shape(invCov) )
332 real(
RK) :: X(nd), NormedPoint(nd)
333 call getUnifRand(X, mean, choLow, choDia)
334 NormedPoint
= X
- mean
335 assertion
= isInsideEllipsoid(nd, NormedPoint, invCov)
336 NormedPoint
= [
-1.e2_RK,
1.e2_RK]
337 assertion
= assertion
.and. .not. isInsideEllipsoid(nd, NormedPoint, invCov)
345 logical(
LK) :: assertion
346 integer(
IK) ,
parameter :: nd
= 2_IK
347 real(
RK) ,
parameter :: tolerance
= 1.e-12_RK
348 real(
RK) ,
parameter :: mean(nd)
= [
1._RK,
2._RK ]
349 real(
RK) ,
parameter :: CovMat(nd,nd)
= reshape( [
1._RK,
0.5_RK,
0.5_RK,
1._RK ], shape
= shape(CovMat) )
350 real(
RK) ,
parameter :: choDia(nd)
= [
1._RK,
0.866025403784439_RK ]
351 real(
RK) ,
parameter :: choLow(nd,nd)
= reshape( [
1._RK,
0.5_RK,
0.5_RK,
1._RK ], shape
= shape(CovMat) )
352 real(
RK) ,
parameter :: invCov(nd,nd)
= reshape( [
+1.333333333333333_RK,
-0.666666666666667_RK &
353 ,
-0.666666666666667_RK,
+1.333333333333333_RK ]
&
354 , shape
= shape(invCov) )
355 real(
RK) :: X(nd), NormedPoint(nd)
356 X
= getRandPointOnEllipsoid(nd,mean,choLow,choDia)
357 NormedPoint
= X
- mean
358 assertion
= dot_product(NormedPoint,
matmul(invCov,NormedPoint))
- 1._RK < tolerance
359 NormedPoint
= [
-1.e2_RK,
1.e2_RK]
360 assertion
= assertion
.and. .not. isInsideEllipsoid(nd, NormedPoint, invCov)
362 if (
test%traceable
.and. .not. assertion)
then
363 write(
test%disp
%unit,
"(*(g0,:,', '))")
364 write(
test%disp
%unit,
"(*(g0,:,', '))")
"RandPointOnEllipsoid ", X
365 write(
test%disp
%unit,
"(*(g0,:,', '))")
"distance from center ",
dot_product(NormedPoint,
matmul(invCov,NormedPoint))
366 write(
test%disp
%unit,
"(*(g0,:,', '))")
"expected distance ",
1._RK
367 write(
test%disp
%unit,
"(*(g0,:,', '))")
Generate and return the natural logarithm of the volume of an -dimensional ellipsoid.
Generate and return the natural logarithm of the volume of an -dimensional ball of unit-radius.
This module contains classes and procedures for setting up and computing the properties of the hyper-...
character(*, SK), parameter MODULE_NAME
This module contains classes and procedures for reporting and handling errors.
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 IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
This module contains tests of the module pm_ellipsoid.
logical(LK) function test_getLogVolUnitBall_2()
logical(LK) function test_getLogVolUnitBall_1()
logical(LK) function test_getLogSurfUnitBall_1()
Test getLogSurfUnitBall() for a range of values from an independent source.
logical(LK) function test_getRandPointOnEllipsoid_1()
logical(LK) function test_getLogVolEll_2()
Test the accuracy of pm_ellipsoid::getLogVolEll().
logical(LK) function test_getEllVolCoef_2()
logical(LK) function test_getLogVolEll_1()
logical(LK) function test_getLogEllVolCoef_2()
logical(LK) function test_getLogVolUnitBall_3()
Test getLogVolUnitBall() for a range of values from an independent source.
logical(LK) function test_isInsideEllipsoid_1()
logical(LK) function test_getEllVolCoef_1()
logical(LK) function test_getLogEllVolCoef_1()
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
This is the derived type test_type for generating objects that facilitate testing of a series of proc...