This assignment is about computing the determinant of a square matrix. We will do this by transforming the matrix into upper triangular form, after which the determinant is product of the numbers on the main diagonal (upper left to lower right).
We will run this with several different input files, each of which provides the dimension of the matrix and the values in it.
Input File
The first line in the input file contains one small integer N such as 4. This is the size of the matrix (N by N). We will always have N < 11.
After that, we have N lines, each containing 4 REAL values separated by spaces. Each line is one row of the matrix.
We will test this with 3 input files which can find on the web site. You may want to test it with your own data as well. We will read the input files with input redirection.
What to do
Declare a 2-dimensional array of size 10 x 10. (We will end up using the upper left portion of it.)
Open the file and read the first line, providing the number N.
Read the rest of the file and store the numbers in the array. This can be done with two DO loops, or with a DO loop and an implied DO loop, or even with two implied DO loops nested.
Now what do we do? We work with one column at a time, left to right.
The role of SIGN is this: if two rows of a matrix are switched, the determinant is multiplied by -1.
If an row or column if 0, the determinant is 0.
Print out the original matrix, the upper triangular form of the matrix and a line stating its determinant.
Notes
Another way to manage the array is to use what is called an "allocatable array", in which the dimensions can be specified at run time.
Your program should be well structured and properly documented. You may want to use more subroutines as well. Do not use any GO TOs. Do use IMPLICIT NONE.
You need to compile and link your program as usual.