Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!! !!!!
4 : !!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5 : !!!! !!!!
6 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7 : !!!! !!!!
8 : !!!! This file is part of the ParaMonte library. !!!!
9 : !!!! !!!!
10 : !!!! LICENSE !!!!
11 : !!!! !!!!
12 : !!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13 : !!!! !!!!
14 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 :
17 : !> \brief
18 : !> This include file contains the implementations of procedures of [test_pm_complexAbs](@ref test_pm_complexAbs).
19 : !>
20 : !> \fintest
21 : !>
22 : !> \author
23 : !> \FatemehBagheri, Wednesday 12:20 AM, October 13, 2021, Dallas, TX
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : use pm_distUnif, only: setUnifRand
28 : use pm_kind, only: SK, IK, LK
29 : use pm_val2str, only: getStr
30 :
31 : #if abs_ENABLED
32 :
33 : integer(IK) , parameter :: NP = 5_IK
34 : character(*, SK), parameter :: PROCEDURE_NAME = "abs()"
35 : complex(CKC) :: Matrix(NP,NP), MatrixABS(NP,NP)
36 : integer(IK) :: i, j
37 :
38 4 : assertion = .true._LK
39 4 : call setUnifRand(Matrix(1,1))
40 4 : MatrixABS(1,1) = abs(Matrix(1,1))
41 :
42 4 : assertion = assertion .and. abs(Matrix(1,1)%re) == MatrixABS(1,1)%re
43 4 : call report(1_IK, 1_IK, int(__LINE__, IK))
44 :
45 4 : assertion = assertion .and. abs(Matrix(1,1)%im) == MatrixABS(1,1)%im
46 4 : call report(1_IK, 1_IK, int(__LINE__, IK))
47 :
48 124 : call setUnifRand(Matrix)
49 244 : MatrixABS = abs(Matrix)
50 :
51 124 : assertion = assertion .and. all(abs(Matrix%re) == MatrixABS%re)
52 24 : do j = 1, NP
53 124 : do i = 1, NP
54 120 : call report(1_IK, 1_IK, int(__LINE__, IK))
55 : end do
56 : end do
57 :
58 124 : assertion = assertion .and. all(abs(Matrix%im) == MatrixABS%im)
59 24 : do j = 1, NP
60 124 : do i = 1, NP
61 120 : call report(1_IK, 1_IK, int(__LINE__, IK))
62 : end do
63 : end do
64 :
65 : contains
66 :
67 208 : subroutine report(i,j, line)
68 : integer(IK), intent(in) :: i, j, line
69 208 : if (test%traceable .and. .not. assertion) then
70 : ! LCOV_EXCL_START
71 : write(test%disp%unit,"(*(g0,:,', '))")
72 : write(test%disp%unit,"(*(g0,:,', '))") "abs(Matrix(i,j)%re)", abs(Matrix(i,j)%re)
73 : write(test%disp%unit,"(*(g0,:,', '))") "abs(Matrix(i,j)%im)", abs(Matrix(i,j)%im)
74 : write(test%disp%unit,"(*(g0,:,', '))") "MatrixABS(i,j%re) ", MatrixABS(i,j)%re
75 : write(test%disp%unit,"(*(g0,:,', '))") "MatrixABS(i,j%im) ", MatrixABS(i,j)%im
76 : write(test%disp%unit,"(*(g0,:,', '))")
77 : ! LCOV_EXCL_STOP
78 : end if
79 208 : call test%assert(assertion, PROCEDURE_NAME//SK_" The elemental absolute of complex values must be correctly computed.", line)
80 208 : end subroutine
81 :
82 : #else
83 :
84 : #error "Unrecognized interface."
85 :
86 : #endif
87 :
88 : #undef COMPARE
|