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 module contains implementations of the tests of the module [pm_mathFactoring](@ref pm_mathFactoring).
19 : !>
20 : !> \fintest
21 : !>
22 : !> \author
23 : !> \AmirShahmoradi, Tuesday 2:06 AM, September 21, 2021, Dallas, TX
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : use pm_kind, only: LK, RKB
28 : use pm_val2str, only: getStr
29 : use pm_distLogUnif, only: getLogUnifRand
30 :
31 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 :
33 : integer :: i, j
34 : integer(IKC), allocatable :: IntList(:), Factoring(:)
35 : integer(IKC), parameter :: UPPER = 127_IKC
36 :
37 5 : assertion = .true._LK
38 :
39 1540 : IntList = [2_IKC, 3_IKC, 4_IKC, (getLogUnifRand(2_IKC, UPPER), i = 1, 100)]
40 505 : do i = 1, 100
41 1985 : Factoring = getFactoring(IntList(i))
42 1485 : assertion = assertion .and. logical(product(Factoring) == IntList(i), LK)
43 500 : call report()
44 500 : call test%assert(assertion, SK_"getFactoring(): The condition `product(Factoring) == IntList(i)` must hold.")
45 1490 : do j = 1, size(Factoring)
46 985 : assertion = assertion .and. logical(size(getFactoring(Factoring(j))) == 1, LK)
47 985 : call report()
48 1485 : call test%assert(assertion, SK_"getFactoring(): The factors of a positive integer must be prime numbers.")
49 : end do
50 : end do
51 :
52 :
53 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 :
55 : contains
56 :
57 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 :
59 1485 : subroutine report()
60 1485 : if (test%traceable .and. .not. assertion) then
61 : ! LCOV_EXCL_START
62 : write(test%disp%unit,"(*(g0,:,', '))")
63 : write(test%disp%unit,"(*(g0,:,', '))") "PosInt ", IntList(i)
64 : write(test%disp%unit,"(*(g0,:,', '))") "Factoring ", Factoring
65 : write(test%disp%unit,"(*(g0,:,', '))")
66 : ! LCOV_EXCL_STOP
67 : end if
68 1485 : end subroutine
69 :
70 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|