Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program lab2
- implicit none
- integer, parameter :: dim = 8
- integer :: NDIM = dim, N = dim, i,j,k
- real, dimension(dim, dim) :: Q, A, E, RES, C, R, AA
- real :: WORK(dim), COND, V(dim), IPVT(dim), max_sum = 0, sum_el, p = 10.0
- open(1, file="input.txt")
- do i=1,dim
- read(1,*) Q(:,i)
- end do
- close(1)
- do k = 1, 5
- p = p / 10.0
- A = Q
- A(1,1) = A(1,1) + p
- AA = A
- write(*,*) "p = ", p
- call DECOMP(NDIM, N, A, COND, IPVT, WORK)
- E = 0
- forall (j = 1:dim) E(j,j) = 1
- do i=1,dim
- V = 0
- V(i) = 1
- call SOLVE(NDIM, N, A, V, IPVT)
- RES(:,i) = V
- end do
- C = matmul(AA, RES)
- R = E - C
- write(*,*) "Cond = ", COND
- max_sum = 0
- do i=1,dim
- sum_el = 0
- do j=1, dim
- sum_el = sum_el + abs(R(i,j))
- end do
- if (sum_el > max_sum) then
- max_sum = sum_el
- end if
- end do
- write(*,*) "Norm of R matrix = ", max_sum
- write(*,*) "----------------------"
- end do
- end program
Advertisement
Add Comment
Please, Sign In to add comment