1
subroutine test_matmul_t_sparse
8
integer, parameter :: size_mat = 50
9
integer, parameter :: n_samples = 100
10
real, dimension(size_mat,size_mat) :: A, B, C, D
11
type(dynamic_csr_matrix) :: A_d, B_d, C_d
12
type(csr_matrix) :: A_c, B_c, C_dc
14
logical :: fail,fail1,fail2, fail3
15
character(len=size_mat) :: buf
16
real, dimension(4) :: rand0
20
call allocate(A_d, size_mat,size_mat)
21
call allocate(B_d, size_mat,size_mat)
35
call random_number(rand0)
36
i = ceiling(rand0(1)*size_mat)
37
j = ceiling(rand0(2)*size_mat)
40
!call addto(A_d,i,j,rand0(3))
41
!call addto(B_d,i,j,rand0(4))
42
call addto(A_d,i,j,1.0)
43
call addto(B_d,i,j,1.0)
46
if (any(A /= dense(A_d))) then
47
write(0,*) 'A assembly bungled'
54
if (any(B /= dense(B_d))) then
55
write(0,*) 'B assembly bungled'
62
C_d = matmul_T(A_d,B_d)
63
!C_c = matmul_T(A_c,B_c)
70
if (any(abs(C-dense(C_dc))>1.0e-14)) fail3 = .true.
73
do i = 1, size(B_d%colm)
74
if(any(C_d%val(i)%ptr<0.5)) fail2=.true.
83
D = matmul(A, transpose(B))
85
if (any(abs(C-D)>1.0e-14)) fail = .true.
86
!if (any(abs(E-D)>1.0e-14)) fail2 = .true.
87
do i = 1, size(A_d%colm)
88
do j = 2, size(A_d%colm(i)%ptr)
89
if(A_d%colm(i)%ptr(j).le.A_d%colm(i)%ptr(j-1)) then
95
do i = 1, size(B_d%colm)
96
do j = 2, size(B_d%colm(i)%ptr)
97
if(B_d%colm(i)%ptr(j).le.B_d%colm(i)%ptr(j-1)) then
103
call report_test("[matmul_t_sparse dcsr " // trim(buf) // "]", fail, .false., "The output of matmul_t and matmul should be identical.")
104
call report_test("[matmul_t_sparse dcsr dense " // trim(buf) // "]", fail3, .false., "The output of dense(dscr_matrix) and dense(dcsr2csr(dcsr_matrix)) should be identical.")
105
call report_test("[matmul_t_sparse zeros " // trim(buf) // "]", fail2, .false., "The sparsity pattern should not contain zeros")
106
call report_test("[matmul_t_sparse " // trim(buf) // " ordering]", fail1, .false., "We expect the rows to be incrementally ordered in dcsr matrices")
113
end subroutine test_matmul_t_sparse