Preface
Chapter 1
Chapter 3

Main Text
Additional Material for this Chapter
Exercises for this Chapter
Answers to Exercises

Programs to Process Matrices


Size and Methods of Input of Matrices into Programs

With any contemporary discussion of matrices and determinants it would be very incomplete not to involve computers. Computations involving matrices very often can be so tedious and can involve detailed arithmetic operations that the reader can become mentally exhausted that he loses a productive train of thought. In the main texts the examples of matrices and determinants involve shorter computations. Programs have been written to shorten the work with matrix computations.

Many programming languages are available today. The algorithmic language C is widely known either for itself or from a knowledge of its offspring C++. Programs in these discussions were written in C, but their source codes can be converted into other languages, such as Pascal and most programs into Fortran and BASIC. These popular languages may have compilers already e on computers available to the reader. (Later, hopefully, there will be a collection of modified flow charts in jpg format in the appendix to represent the programs. Those should help conversion of the C programs into other languages.)

Some free compilers for converting source code into executivle programs can be downloaded from websites on the internet. These may have limited space in memory for execution. The advantage of C is that it a properly written source code in most every computer.

Some of the programs in these articles process matrices. Usually they require some input. First it may ask for the size of the matrix, which means the number of rows (M) and the number of columns (N). Then the program will ask the input of each row of N elements and do that asking M times to receive the entire matrix. A program for the product of two matrices will ask for an input of a second matrix.

The input can be placed in a data file made by Notepad in the Windows OS. The first line contains the size as two numbers, M and N, on the first line. On the next M lines the rows of length N are written on the file. More than one matrix can be written in this way on the file. Later a program can read that file and process the matrix indicated there.

Linear Forms of Matrices

A matrix A such as:
[1]       MAT A =

10 15 20 25
30 35 40 45
50 55 60 65
is shown as rectangular. From the picture the matrix has 3 rows and 4 columns. The entries listed by rows are :
[2]
10,15,20,25,30,35,40,45,50,55,60,65
Another matrix B
[3]      MAT B =
10 15 20 25 30 35
40 45 50 55 60 65
has the the same list of numbers by rows: [2]. The linear list of entries does not show the shapes of the matrices A and B. They have different shapes and therefore are not equal matrices.

It would be difficult for a computer program to accept a picture of rectangular matrix as input for computation. There is another way. Make a computer program accept data in the form of a linear list [2]. Still the size of the matrix must be given. A rather unusual and non-standard method can be used. Before a list of entries in a linear list place a single number to indicate the size. For matrix A in [1] modify list [2] to read:
[4]

A = {0304,   10,15,20,25,   30,35,40,45,   50,55,60,65}
For matrix B in [3] modify list [2] to read:
[5]
B = {0206,   10,15,20,25,30,35,   40,45,50,55,60,65}

In [4] and [5] matrices A amd B are given in linear forms. We shall say simply, linear matrix A and linear matrix B. In contrast, we say rectangular matrix A and rectangular matrix B in [1] and [3]

The first numbers 0304, meaning a 3x4 matrix in rectangular form, and 0206, meaning a 2x6 matrix in rectangular form, will be called size indicators. For readability the rows are separated by several spaces. In the linear matrix the horizontal rows become horizontal segments. The size indicater states the number of segments and the length of each segment. By the way, the size indicator limits the size of the matrix. The number of columns must be less than 100. However, this is not a severe limitation, since matrices in these chapters will never exceed 13x13.

A comma (,) is placed after each entry in a linear matrix, except after the last entry. The braces and commas distinguish a linear matrix from a rectangular matrix that has only one row (also known as a horizontal vector).

This same form for a linear matrix can be used in writing the matrix to a file. However, to increase readability, the rectangular form can be used by omitting the braces, replacing the spaces by end of line markers, and commas by spaces. For interactive input to a program, also omit braces, replace commas with spaces, and at the end of rows press the enter key.