! Verifica solutia
! Solutia: x =b(n,nb)
! Matricile date: a0(n,n); b0(n,nb)

subroutine Proba(n, nb, a0, b0, x, full_check)

real a0(n,n), b0(n,nb), x(n,nb) 
real dif(n,nb), dif1(n)
real dif_max

logical full_check
integer width


dif =matmul(a0,x) -b0

! Write_Proba

write(1, '(//,a)') ' * Proba'

if(full_check) then
write(1, '(/,a)') ' Diferente (A*x-b)'

else
write(1, '(/,a)') ' Diferenta (A*x-b), maxima in modul'
endif


B_DO: DO kb =1,nb
iwk =width(kb)

if(nb >1) then
write(1, '(/, a, I<iwk>, a)') ' Solutia nr. ', kb, ':'
endif


full_if: if(full_check) then
iwn =width(n)+1; iwt =iwn+3;
do i =1,n
!write(1,*) i, dif(i,kb) 
write(1, '(I<iwn>, t<iwt>, 1pG15.7)') i, dif(i,kb) 
enddo

write(1, '(/, a, \)') ' Diferenta maxima in modul:'
endif full_if

dif1 =dif(:,kb)
imax =imaxv(n, dif1)
	if(imax>0) then
dif_max =dif1(imax)
    else
    imax =1
dif_max =dif1(1)
    endif
    
	iwm =width(imax)+1
	write(1, '(1pg15.7, a, i<iwm>)') dif_max, '; ecuatia', imax

ENDDO B_DO

END subroutine Proba
