pxjoke

VMAT_lab2_20

Apr 9th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program lab2
  2.   implicit none
  3.   integer, parameter :: dim = 8
  4.   integer :: NDIM = dim, N = dim, i,j,k
  5.   real, dimension(dim, dim) :: Q, A, E, RES, C, R, AA
  6.   real :: WORK(dim), COND, V(dim), IPVT(dim), max_sum = 0, sum_el, p = 10.0
  7.  
  8.   open(1, file="input.txt")
  9.  
  10.   do i=1,dim
  11.     read(1,*) Q(:,i)
  12.   end do
  13.    
  14.   close(1)
  15.  
  16.   do k = 1, 5
  17.     p = p / 10.0
  18.     A = Q
  19.     A(1,1) = A(1,1) + p
  20.     AA = A
  21.  
  22.     write(*,*) "p = ", p
  23.     call DECOMP(NDIM, N, A, COND, IPVT, WORK)
  24.  
  25.     E = 0
  26.     forall (j = 1:dim) E(j,j) = 1
  27.  
  28.     do i=1,dim
  29.       V = 0
  30.       V(i) = 1
  31.       call SOLVE(NDIM, N, A, V, IPVT)
  32.       RES(:,i) = V
  33.     end do
  34.  
  35.     C = matmul(AA, RES)
  36.     R = E - C
  37.  
  38.     write(*,*) "Cond = ", COND
  39.     max_sum = 0
  40.     do i=1,dim
  41.       sum_el = 0
  42.         do j=1, dim
  43.           sum_el = sum_el + abs(R(i,j))
  44.         end do
  45.       if (sum_el > max_sum) then
  46.         max_sum = sum_el
  47.       end if  
  48.     end do
  49.  
  50.     write(*,*) "Norm of R matrix = ", max_sum
  51.     write(*,*) "----------------------"
  52.   end do
  53. end program
Advertisement
Add Comment
Please, Sign In to add comment