Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program lab2
- integer, parameter :: N = 6, alpha = 4
- real, dimension(N, N) :: Q
- real, dimension(N) :: Z, g, IPVT, WORK
- real :: u = 2.0, x, y, COND, res
- do k=1, N
- g(k) = 2.0**(k-4.0)
- end do
- do l=1,4
- u = u / 10.0
- x = 4 + u
- y = 4 - u
- do i=1,N
- do j=1, N
- if ( i > j) then
- Q(i,j) = y
- cycle
- end if
- if (i < j) then
- Q(i,j) = x
- cycle
- end if
- Q(i,j) = alpha
- end do
- end do
- do i=1,N
- Z(i) = y * sum(g(1:i-1)) + alpha * g(i) + x * sum(g(i+1:N))
- end do
- call DECOMP (N,N,Q,COND,IPVT,WORK)
- call SOLVE (N,N,Q,Z,IPVT)
- write(*,*) "COND = ", COND
- write(*,*) "u = ", u
- write(*,*) "g = ", g
- write(*,*) "z = ", z
- res = sum(abs(z-g)) / sum(abs(g))
- write(*,*) "RESULT = ", res
- write(*,*) "---------------------------------"
- end do
- end program lab2
Advertisement
Add Comment
Please, Sign In to add comment