@@ -7,6 +7,12 @@ module test_fftpack_dct
77
88 public :: collect_dct
99
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+
1016contains
1117
1218 ! > Collect all exported unit tests
@@ -26,15 +32,16 @@ subroutine test_classic_dct(error)
2632 type (error_type), allocatable , intent (out ) :: error
2733 real (kind= rk) :: w(3 * 4 + 15 )
2834 real (kind= rk) :: x(4 ) = [1 , 2 , 3 , 4 ]
29- real (kind= rk) :: eps = 1.0e-10_rk
3035
3136 call dcosti(4 , w)
3237 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." )
3440 if (allocated (error)) return
3541
3642 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." )
3845
3946 end subroutine test_classic_dct
4047
@@ -46,23 +53,25 @@ subroutine test_modernized_dct(error)
4653 if (allocated (error)) return
4754 call check(error, all (dct(x, 3 ) == dct(x)), " `dct(x, 3)` failed." )
4855 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." )
5058
5159 end subroutine test_modernized_dct
5260
5361 subroutine test_modernized_idct (error )
5462 type (error_type), allocatable , intent (out ) :: error
55- real (kind= rk) :: eps = 1.0e-10_rk
5663 real (kind= rk) :: x(4 ) = [1 , 2 , 3 , 4 ]
5764
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, &
5967 " `idct(dct(x))/(2.0_rk*(4.0_rk-1.0_rk))` failed." )
6068 if (allocated (error)) return
6169 call check(error, all (idct(dct(x), 2 )/ (2.0_rk * (2.0_rk - 1.0_rk )) == [real (kind= rk) :: 5.5 , 9.5 ]), &
6270 " `idct(dct(x), 2)/(2.0_rk*(2.0_rk-1.0_rk))` failed." )
6371 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, &
6675 " `idct(dct(x, 2), 4)/(2.0_rk*(4.0_rk-1.0_rk))` failed." )
6776
6877 end subroutine test_modernized_idct
0 commit comments