
C –15 Solutions
1. Invert a 3x3 Matrix
Data Structure
A new type my_3x3_matrix as a real array (1..3, 1..3)
Subprograms
1. Function to create the matrix
2. Procedure to display the matrix
3. Function to compute the determinant
4. Function to compute the inverse
5. Main program to invert the matrix
Algorithm
Create_Matrix:
For I in 1 .. 3
For J in 1 .. 3
Accept Matrix(I,J)
Return Matrix to the user
Display_Matrix:
For I in 1.. 3
For J in 1.. 3
Display Matrix (I,J);
New_Line
Compute_Determinant:
1. Convert the matrix into a real_matrix (as defined in
Generic_Real_arrays)
2. Compute the determinant using the det function defined in
Generic_Real_Arrays.Operations.
3. Return the computed Value
Compute_Inverse:
1. Convert the matrix into a real_matrix (as defined in
Generic_Real_arrays)
2. Compute the inverse using the Inverse function defined in
Generic_Real_Arrays.Operations.