1
1
module test_fftpack_dct
2
2
3
- use fftpack, only: rk, dcosti, dcost, dct, idct, dcosqi, dcosqf, dcosqb
3
+ use fftpack
4
4
use testdrive, only: new_unittest, unittest_type, error_type, check
5
5
implicit none
6
6
private
@@ -24,27 +24,53 @@ end subroutine collect_dct
24
24
25
25
subroutine test_classic_dct (error )
26
26
type (error_type), allocatable , intent (out ) :: error
27
- real (kind= rk) :: w(3 * 4 + 15 )
27
+ real (kind= rk) :: w(3 * 4 + 15 ), w2( 3 * 4 + 15 )
28
28
real (kind= rk) :: x(4 ) = [1 , 2 , 3 , 4 ]
29
+ real (kind= rk) :: x2(4 )
29
30
real (kind= rk) :: eps = 1.0e-10_rk
30
-
31
+
32
+ x2 = x
31
33
call dcosti(4 , w)
32
34
call dcost(4 , x, w)
33
- call check(error, all (x == [real (kind= rk) :: 15 , - 4 , 0 , - 1.0000000000000009_rk ]), " `dcosti` failed." )
35
+ call check(error, sum (abs (x - [real (kind= rk) :: 15 , - 4 , 0 , - 1.0000000000000009_rk ])) < eps, &
36
+ " `dcost` failed." )
37
+ if (allocated (error)) return
38
+
39
+ call dct_t1i(4 , w2)
40
+ call dct_t1(4 , x2, w2)
41
+ call check(error, maxval (abs (x2- x)) < eps, " dct_t1 failed" )
34
42
if (allocated (error)) return
43
+
35
44
call dcost(4 , x, w)
36
- call check(error, all (x/ (2 * 3 ) == [real (kind= rk) :: 1 , 2 , 3 , 4 ]), " `dcost` failed." )
45
+ call check(error, sum (abs (x/ (2 * 3 ) - [real (kind= rk) :: 1 , 2 , 3 , 4 ])) < eps, &
46
+ " 2nd `dcost` failed." )
47
+ if (allocated (error)) return
48
+
49
+ call dct_t1(4 , x2, w2)
50
+ call check(error, maxval (abs (x2- x)) < eps, " 2nd dct_t1 failed" )
51
+ if (allocated (error)) return
37
52
38
53
x = [1 , 2 , 3 , 4 ]
54
+ x2 = x
39
55
call dcosqi(4 , w)
40
56
call dcosqf(4 , x, w)
41
57
call check(error, sum (abs (x - [11.999626276085150_rk , - 9.1029432177492193_rk , &
42
58
2.6176618435106480_rk , - 1.5143449018465791_rk ])) < eps, &
43
59
" `dcosqf` failed." )
44
60
if (allocated (error)) return
61
+
62
+ call dct_t23i(4 , w2)
63
+ call dct_t3(4 , x2, w2)
64
+ call check(error, maxval (abs (x2- x)) < eps, " dct_t3 failed" )
65
+ if (allocated (error)) return
66
+
45
67
call dcosqb(4 , x, w)
46
68
call check(error, sum (abs (x/ (4 * 4 ) - [real (kind= rk) :: 1 , 2 , 3 , 4 ])) < eps, &
47
69
" `dcosqb` failed." )
70
+ if (allocated (error)) return
71
+
72
+ call dct_t2(4 , x2, w2)
73
+ call check(error, maxval (abs (x2- x)) < eps, " dct_t2 failed" )
48
74
49
75
end subroutine test_classic_dct
50
76
0 commit comments