
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

(Pruett)
LABORATORY ASSIGNMENT Two-Dimensional Arrays (Matrices)
Consider the linear system of equations U~x = ~d where U is the square upper- triangular matrix given below
and d~ = [ 6 , 8 , 12 ]T^ (2)
C Write a small FORTRAN 90 program that declares U to be a two-dimensional array, initializes U using an array constant assignment (inside a RESHAPE intrinsic function), and prints out the matrix U by rows.
C Add the additional statement
WRITE (,) U
near the end of your program, recompile, and re-run. What do you conclude is the conventional (natural) ordering of 2D-array elements in FORTRAN 90? By rows or by columns?
B Write and compile a MODULE linear algebra containing
SUBROUTINE back substitution
that returns the solution ~x of U~x = d~, given an n × n upper-triangular matrix U and an n-vector d~ Refer to Alg. 6.2 of the class notes.
A Modify your main program above to solve U~x = d~. That is, CALL SUB- ROUTINE back substitution for n = 3, the matrix of Eq. 1, and the right- hand-side vector of Eq 2. Print out the solution vector ~x and verify by hand that it is correct.
A+ Add to your module SUBROUTINE residual, which receives n, U, ~d, and ~x as INTENT(IN) arguments and returns the residual n-vector ~r as an IN- TENT(OUT) argument. Verify that your back-substitution algorithm is cor- rect by CALLing the subroutine to compute the residual vector.