pxjoke

VMAT_lab2_24

Apr 9th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program lab2
  2. integer, parameter :: N = 6, alpha = 4
  3. real, dimension(N, N) :: Q
  4. real, dimension(N) :: Z, g, IPVT, WORK
  5. real :: u = 2.0, x, y, COND, res
  6.  
  7.  do k=1, N
  8.   g(k) = 2.0**(k-4.0)
  9.  end do
  10.  
  11. do l=1,4
  12. u = u / 10.0
  13. x = 4 + u
  14. y = 4 - u
  15. do i=1,N
  16.   do j=1, N
  17.     if ( i > j) then
  18.       Q(i,j) = y
  19.       cycle
  20.     end if
  21.     if (i < j) then
  22.       Q(i,j) = x
  23.       cycle
  24.     end if
  25.     Q(i,j) = alpha
  26.      
  27.   end do
  28. end do
  29.  
  30. do i=1,N
  31.  
  32.   Z(i) = y * sum(g(1:i-1)) + alpha * g(i) + x * sum(g(i+1:N))
  33.  
  34. end do
  35.  
  36. call DECOMP (N,N,Q,COND,IPVT,WORK)
  37. call SOLVE (N,N,Q,Z,IPVT)
  38. write(*,*) "COND = ", COND
  39. write(*,*) "u = ", u
  40. write(*,*) "g = ", g
  41. write(*,*) "z = ", z
  42.  
  43. res = sum(abs(z-g)) / sum(abs(g))
  44. write(*,*) "RESULT = ", res
  45. write(*,*) "---------------------------------"
  46. end do
  47.  
  48. end program lab2
Advertisement
Add Comment
Please, Sign In to add comment