# [Assignment] Matrix Operation

Tags: C pointers, Matrix, Memory Managment

1. Preamble

A matrix is an ordered array of values arranged in rows and columns. A fundamental operation in matrix algebra is inverse. In an n-by-n square matrix A\, if a unique matrix n-by-n square B\ exists to make *AB = BA = I*****n\ valid, the matrix B\ is called the inverse of A\, denoted by *A*****-1\, where *I*****n\ is an n-by-n identify matrix.

For example, the matrix 𝐴=, its inverse is 𝐴−1=[−211.5−0.5] since

𝐴𝐴−1=[−211.5−0.5]= and 𝐴−1𝐴=[−211.5−0.5]=

Not all square matrices have inverses. A square matrix which has an inverse is called invertible, and a square matrix without an inverse is called singular.

For this assignment, all values are integer. Design, construct and test a program, which uses arrays having constant dimensions, to perform the following sequence of activity:

a) Prompt for the dimension of the square matrix, which may be no bigger than five in either dimension. Read the elements by row, one row per line of input. Test to see if the matrix is invertible. If the matrix is not invertible, print the standard message (below) on a line by itself, in exactly the format shown and terminate execution.

The matrix is singular

b) Otherwise determine the inverse for the input matrix with four decimal places.

3. Examples of Input/Output

Enter the dimension of the square matrix: 2

Now enter values 2 rows by 2 columns

1 2

3 4

The inverse of the matrix is:

-2.0000 1.0000

1.5000 -0.5000