test_solver1 Program

Uses

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

Calls

program~~test_solver1~~CallsGraph program~test_solver1 test_solver1 check check program~test_solver1->check interface~solve forsolver::solve program~test_solver1->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 :: expected_x
real(kind=rk), dimension(:), allocatable :: b
integer :: m
integer :: n
integer :: i
integer :: j
type(unit_test) :: ut

Source Code

program test_solver1

   use kinds
   use forsolver
   use forunittest

   implicit none

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

   m = 3
   n = 2

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

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

   b = [4.0_rk, -2.0_rk, 3.0_rk]

   expected_x = [-4.0_rk/7.0_rk, 5.0_rk/7.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_solver1.1' )

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

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

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

end program test_solver1