@@ -7,6 +7,12 @@ module test_fftpack_dct
7
7
8
8
public :: collect_dct
9
9
10
+ #if defined(fftpack_sp)
11
+ real (kind= rk) :: eps = 1.0e-5_rk
12
+ #else
13
+ real (kind= rk) :: eps = 1.0e-10_rk
14
+ #endif
15
+
10
16
contains
11
17
12
18
! > Collect all exported unit tests
@@ -26,15 +32,16 @@ subroutine test_classic_dct(error)
26
32
type (error_type), allocatable , intent (out ) :: error
27
33
real (kind= rk) :: w(3 * 4 + 15 )
28
34
real (kind= rk) :: x(4 ) = [1 , 2 , 3 , 4 ]
29
- real (kind= rk) :: eps = 1.0e-10_rk
30
35
31
36
call dcosti(4 , w)
32
37
call dcost(4 , x, w)
33
- call check(error, all (x == [real (kind= rk) :: 15 , - 4 , 0 , - 1.0000000000000009_rk ]), " `dcosti` failed." )
38
+ call check(error, sum (abs (x - [real (kind= rk) :: 15 , - 4 , 0 , - 1.0000000000000009_rk ])) < eps, &
39
+ " `dcosti` failed." )
34
40
if (allocated (error)) return
35
41
36
42
call dcost(4 , x, w)
37
- call check(error, all (x/ (2.0_rk * (4.0_rk - 1.0_rk )) == [real (kind= rk) :: 1 , 2 , 3 , 4 ]), " `dcost` failed." )
43
+ call check(error, sum (abs (x/ (2.0_rk * (4.0_rk - 1.0_rk )) - &
44
+ [real (kind= rk) :: 1 , 2 , 3 , 4 ])) < eps, " `dcost` failed." )
38
45
39
46
end subroutine test_classic_dct
40
47
@@ -46,23 +53,25 @@ subroutine test_modernized_dct(error)
46
53
if (allocated (error)) return
47
54
call check(error, all (dct(x, 3 ) == dct(x)), " `dct(x, 3)` failed." )
48
55
if (allocated (error)) return
49
- call check(error, all (dct(x, 4 ) == [real (kind= rk) :: - 3 , - 3.0000000000000036_rk , 15 , 33 ]), " `dct(x, 4)` failed." )
56
+ call check(error, sum (abs (dct(x, 4 ) - [real (kind= rk) :: - 3 , - 3.0000000000000036_rk , 15 , 33 ])) &
57
+ < eps, " `dct(x, 4)` failed." )
50
58
51
59
end subroutine test_modernized_dct
52
60
53
61
subroutine test_modernized_idct (error )
54
62
type (error_type), allocatable , intent (out ) :: error
55
- real (kind= rk) :: eps = 1.0e-10_rk
56
63
real (kind= rk) :: x(4 ) = [1 , 2 , 3 , 4 ]
57
64
58
- call check(error, all (idct(dct(x))/ (2.0_rk * (4.0_rk - 1.0_rk )) == [real (kind= rk) :: 1 , 2 , 3 , 4 ]), &
65
+ call check(error, sum (abs (idct(dct(x))/ (2.0_rk * (4.0_rk - 1.0_rk )) - &
66
+ [real (kind= rk) :: 1 , 2 , 3 , 4 ])) < eps, &
59
67
" `idct(dct(x))/(2.0_rk*(4.0_rk-1.0_rk))` failed." )
60
68
if (allocated (error)) return
61
69
call check(error, all (idct(dct(x), 2 )/ (2.0_rk * (2.0_rk - 1.0_rk )) == [real (kind= rk) :: 5.5 , 9.5 ]), &
62
70
" `idct(dct(x), 2)/(2.0_rk*(2.0_rk-1.0_rk))` failed." )
63
71
if (allocated (error)) return
64
- call check(error, all (idct(dct(x, 2 ), 4 )/ (2.0_rk * (4.0_rk - 1.0_rk )) == &
65
- [0.16666666666666666_rk , 0.33333333333333331_rk , 0.66666666666666663_rk , 0.83333333333333315_rk ]), &
72
+ call check(error, sum (abs (idct(dct(x, 2 ), 4 )/ (2.0_rk * (4.0_rk - 1.0_rk )) - &
73
+ [0.16666666666666666_rk , 0.33333333333333331_rk , &
74
+ 0.66666666666666663_rk , 0.83333333333333315_rk ])) < eps, &
66
75
" `idct(dct(x, 2), 4)/(2.0_rk*(4.0_rk-1.0_rk))` failed." )
67
76
68
77
end subroutine test_modernized_idct
0 commit comments