{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

c15_ps06_sol

# c15_ps06_sol - C 15 Solutions 1 Invert a 3x3 Matrix Data...

This preview shows pages 1–3. Sign up to view the full content.

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.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. Convert the real_matrix back into the user defined type 4. Return the inverted matrix Main Program: 1. Prompt the user to enter a matrix 2. Display accepted matrix to the user 3. Check if matrix is singular by computing the determinant. 4. If matrix is not singular (determinant /= 0) a. Compute the inverse b. Display inverse to the user 5. Else, Display “Cannot Invert” 2. Code Listing GNAT 3.13 p ( 20000509 ) Copyright 1992 - 2000 Free Software Foundation, Inc. Compiling: c:/docume~
This is the end of the preview. Sign up to access the rest of the document.
• Fall '05
• MarkDrela
• Trinity, Inverse function, The Matrix Reloaded, The Matrix Revolutions, Wachowski brothers, Function composition

{[ snackBarMessage ]}

### Page1 / 4

c15_ps06_sol - C 15 Solutions 1 Invert a 3x3 Matrix Data...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online