Skip to content

Commit fbd3d9a

Browse files
committed
add DCT-types tests
1 parent 9c8a885 commit fbd3d9a

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

test/test_fftpack_dct.f90

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module test_fftpack_dct
22

3-
use fftpack, only: rk, dcosti, dcost, dct, idct, dcosqi, dcosqf, dcosqb
3+
use fftpack
44
use testdrive, only: new_unittest, unittest_type, error_type, check
55
implicit none
66
private
@@ -24,27 +24,53 @@ end subroutine collect_dct
2424

2525
subroutine test_classic_dct(error)
2626
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)
2828
real(kind=rk) :: x(4) = [1, 2, 3, 4]
29+
real(kind=rk) :: x2(4)
2930
real(kind=rk) :: eps = 1.0e-10_rk
30-
31+
32+
x2 = x
3133
call dcosti(4, w)
3234
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")
3442
if (allocated(error)) return
43+
3544
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
3752

3853
x = [1, 2, 3, 4]
54+
x2 = x
3955
call dcosqi(4, w)
4056
call dcosqf(4, x, w)
4157
call check(error, sum(abs(x - [11.999626276085150_rk, -9.1029432177492193_rk, &
4258
2.6176618435106480_rk, -1.5143449018465791_rk])) < eps, &
4359
"`dcosqf` failed.")
4460
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+
4567
call dcosqb(4, x, w)
4668
call check(error, sum(abs(x/(4*4) - [real(kind=rk) :: 1, 2, 3, 4])) < eps, &
4769
"`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")
4874

4975
end subroutine test_classic_dct
5076

0 commit comments

Comments
 (0)