


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: INTRO TO ENGINEERING COMPUTING; Subject: Engineering; University: University of Pittsburgh; Term: Fall 2008;
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



page 1 of 4 Fall Term, 2008
Problem : You have been hired by WeAreSoftware, Inc as a new software project engineer. WeAreSoftware is developing a new product that it hopes will rival and supplant MATLAB as an engineering tool for design and analysis. You have been assigned to the team in charge of developing the matrix handling portion of the software package.
Background : The basic matrix operations that you need to perform in this first round of development are
where ci (^) , j = ai , j + bi , j note: matrix addition is only permitted if [A] and [B] have the same dimensions a warning should be displayed if the addition cannot be performed
where ci (^) , j = ai , j − bi , j note: matrix subtraction is only permitted if [A] and [B] have the same dimensions a warning should be displayed if the subtraction cannot be performed
= = (^) = kN c (^) i , j k 1 ai , kbk , j note: matrix multiplication is only permitted if [B]NxP has the same number of rows as [A]MxN has columns. The resulting matrix has dimension MxP. a warning should be displayed if the multiplication cannot be performed
where ci j (^) , = ai j (^) , * bi j , note: element by element multiplication is only permitted if [B]NxP has the same number of rows and columns as [A]MxN. a warning should be displayed if the multiplication cannot be performed
Assignment : Design and code a C program that has the following functions: a) a function that will read a data file that contains a two-dimensional matrix. the first row of the data file will have two entries: the number of rows in the matrix followed by the number of columns in the matrix. the remainder of the file will contain the (real, floating point) matrix elements, row by row. the function should return the number of rows and columns in the matrix as well as the matrix. What does this function need from the calling function to do its job? (nothing - why?) What does this function need from the user to do its job? (1 thing - what?)
page 2 of 4 Fall Term, 2008
What will the function return to the calling program, if successful? (3 things - what? what type of data?)
b) A function that will display a menu and determine the user’s choice from the menu. User’s choices are: Enter A to add two matrices Enter S to subtract two matrices Enter M to multiply two matrices Enter E to multiply the element by elements of two matrices Enter N to move to next case or exit Please enter your choice Use an error check to assure that a proper choice is made. Return the user choice with the return statement. What does this function need from the calling function to do its job? (nothing - why?) What will the function return to the calling program, if successful? (1 thing - what?)
c) A function that will add two matrices. What does this function need from the calling function to do its job? (6 things - what are they?) What will the function return to the calling program, if successful? (3 things - what are they?) The function should display an error message if it cannot add the two matrices.
d) A function that will subtract two matrices. How does this function differ from the one that adds two matrices? What does this function need from the calling function to do its job? (6 things - what are they?) What will the function return to the calling program, if successful? (3 things - what are they?) The function should display an error message if it cannot subtract the two matrices.
e) A function that will multiply two matrices. How does this function differ from the one that adds two matrices? What does this function need from the calling function to do its job? (6 things - what are they?) What will the function return to the calling program, if successful? (3 things - what are they?) The function should display an error message if it cannot multiply the two matrices.
f) A function that will multiply element by element two matrices. How does this function differ from the one that adds two matrices? What does this function need from the calling function to do its job? (6 things - what are they?) What will the function return to the calling program, if successful? (3 things - what are they?)
page 4 of 4 Fall Term, 2008