PROGRAM nag_tri_lin_sys_ex06 ! Example Program Text for nag_tri_lin_sys ! NAG fl90, Release 4. NAG Copyright 2000. ! .. Use Statements .. USE nag_examples_io, ONLY : nag_std_in, nag_std_out USE nag_tri_lin_sys, ONLY : nag_tri_lin_sol, nag_tri_lin_cond, & nag_tri_mat_det ! .. Implicit None Statement .. IMPLICIT NONE ! .. Intrinsic Functions .. INTRINSIC EPSILON, KIND, SCALE ! .. Parameters .. INTEGER, PARAMETER :: wp = KIND(1.0D0) ! .. Local Scalars .. INTEGER :: det_exp, i, n REAL (wp) :: bwd_err, fwd_err, rcond_inf COMPLEX (wp) :: det_frac CHARACTER (1) :: uplo ! .. Local Arrays .. COMPLEX (wp), ALLOCATABLE :: a(:,:), b(:) ! .. Executable Statements .. WRITE (nag_std_out,*) 'Example Program Results for nag_tri_lin_sys_ex06' READ (nag_std_in,*) ! Skip heading in data file READ (nag_std_in,*) n READ (nag_std_in,*) uplo ALLOCATE (a(n,n),b(n)) ! Allocate storage SELECT CASE (uplo) CASE ('L','l') READ (nag_std_in,*) (a(i,:i),i=1,n) CASE ('U','u') READ (nag_std_in,*) (a(i,i:),i=1,n) END SELECT READ (nag_std_in,*) b ! Compute the determinant CALL nag_tri_mat_det(uplo,a,det_frac,det_exp) WRITE (nag_std_out,*) WRITE (nag_std_out,'(1X,''determinant = det_frac*SCALE(1.0_wp,det_exp) & &='',2X,"(",ES11.3,",",ES11.3,")")') det_frac*SCALE(1.0_wp,det_exp) ! Compute the condition number rcond_inf = nag_tri_lin_cond(uplo,a) WRITE (nag_std_out,*) WRITE (nag_std_out,'(1X,''kappa(A) (1/rcond_inf)''/9X,ES11.2)') 1/ & rcond_inf IF (rcond_inf<=EPSILON(1.0_wp)) THEN WRITE (nag_std_out,*) WRITE (nag_std_out,*) ' ** WARNING ** ' WRITE (nag_std_out,*) & 'The matrix is almost singular: the solution may have no accuracy.' WRITE (nag_std_out,*) & 'Examine the forward error bound estimate returned in fwd_err.' END IF ! Solve the system of equations CALL nag_tri_lin_sol(uplo,a,b,bwd_err=bwd_err,fwd_err=fwd_err) WRITE (nag_std_out,*) WRITE (nag_std_out,*) 'Solution' WRITE (nag_std_out,'(3X,''('',F7.4,'','',F7.4,'')'')') b WRITE (nag_std_out,*) WRITE (nag_std_out,*) 'Backward error bound' WRITE (nag_std_out,'(2X,ES11.2)') bwd_err WRITE (nag_std_out,*) WRITE (nag_std_out,*) 'Forward error bound (estimate)' WRITE (nag_std_out,'(2X,ES11.2)') fwd_err DEALLOCATE (a,b) ! Deallocate storage END PROGRAM nag_tri_lin_sys_ex06