test_multi_column Subroutine

public subroutine test_multi_column()

Arguments

None

Calls

proc~~test_multi_column~~CallsGraph proc~test_multi_column test_multi_column add_row add_row proc~test_multi_column->add_row assert_that assert_that proc~test_multi_column->assert_that equal_to equal_to proc~test_multi_column->equal_to

Source Code

   subroutine test_multi_column()
      integer, parameter :: M = 2, N = 3
      type(CSR_SparseMatrix_sp) :: mat(3)
      real :: x(3,N), y_found(3, M), y_expected(3,M)
      
      mat(1) = CSR_SparseMatrix_sp(M, N, 3)
      call add_row(mat(1), 1, 1, [1.,1.])
      call add_row(mat(1), 2, 2, [1.])

      mat(2) = CSR_SparseMatrix_sp(M, N, 3)
      call add_row(mat(2), 1, 2, [1.,1.])
      call add_row(mat(2), 2, 3, [2.])

      mat(3) = CSR_SparseMatrix_sp(M, N, 5)
      call add_row(mat(3), 1, 1, [1.,1.,1.])
      call add_row(mat(3), 2, 2, [1.,2.])

      x = 1
      y_found = matmul(mat, x)

      y_expected(1,:) = [2.,1.]
      y_expected(2,:) = [2.,2.]
      y_expected(3,:) = [3.,3.]

      @assert_that(y_found, is(equal_to(y_expected)))
      
   end subroutine test_multi_column