c15_ps06_sol

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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
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~
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/28/2012 for the course AERO 16.01 taught by Professor Markdrela during the Fall '05 term at MIT.

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 Right Arrow Icon
Ask a homework question - tutors are online