test_solver2 Program

Uses

  • program~~test_solver2~~UsesGraph program~test_solver2 test_solver2 forunittest forunittest program~test_solver2->forunittest kinds kinds program~test_solver2->kinds module~forsolver forsolver program~test_solver2->module~forsolver module~forsolver->kinds fordiff fordiff module~forsolver->fordiff

Calls

program~~test_solver2~~CallsGraph program~test_solver2 test_solver2 check check program~test_solver2->check interface~solve forsolver::solve program~test_solver2->interface~solve proc~solver_lin forsolver::solver_lin interface~solve->proc~solver_lin proc~gels_rel forsolver::gels_rel proc~solver_lin->proc~gels_rel proc~gesv_rel forsolver::gesv_rel proc~solver_lin->proc~gesv_rel interface~gels external_interfaces_solver::gels proc~gels_rel->interface~gels interface~gesv external_interfaces_solver::gesv proc~gesv_rel->interface~gesv

Variables

Type Attributes Name Initial
real(kind=rk), dimension(:,:), allocatable :: A
real(kind=rk), dimension(:), allocatable :: x1
real(kind=rk), dimension(:), allocatable :: x2
real(kind=rk), dimension(:), allocatable :: x3
real(kind=rk), dimension(:), allocatable :: expected_x
real(kind=rk), dimension(:), allocatable :: b
integer :: m
integer :: n
integer :: i
integer :: j
type(unit_test) :: ut

Source Code

program test_solver2

   use kinds
   use forsolver
   use forunittest

   implicit none

   real(rk), dimension(:,:), allocatable :: A
   real(rk), dimension(:)  , allocatable :: x1, x2, x3, expected_x, b
   integer                               :: m,n, i, j
   type(unit_test) :: ut

   m = 4
   n = 4

   allocate(A(m,n),b(m),x1(n),x2(n),x3(n),expected_x(n))

   A(1,:) = [ 1.0_rk,  1.0_rk,  -3.0_rk,  1.0_rk]
   A(2,:) = [-5.0_rk,  3.0_rk,  -4.0_rk,  1.0_rk]
   A(3,:) = [ 1.0_rk,  0.0_rk,   2.0_rk, -1.0_rk]
   A(4,:) = [ 1.0_rk,  2.0_rk,   0.0_rk,  0.0_rk]

   b = [2.0_rk, 0.0_rk, 1.0_rk, 12.0_rk]

   expected_x = [22.0_rk/17.0_rk, 91.0_rk/17.0_rk, 84.0_rk/17.0_rk, 173.0_rk/17.0_rk]

   x1 = solve(A, b)

   ! check if solution is close to expected_x
   call ut%check(x1, expected_x, 1.0e-6_rk, 'test_solver2.1' )

   x2 = solve(A, b, method='gesv')

   ! check if solution is close to expected_x
   call ut%check(x2, expected_x, 1.0e-6_rk, 'test_solver2.2' )

   x3 = solve(A, b, method='gels')

   ! check if solution is close to expected_x
   call ut%check(x3, expected_x, 1.0e-6_rk, 'test_solver2.3' )

   deallocate(A,b,x1,x2,x3,expected_x)

end program test_solver2