Assignment 13 - Introduction to Engineering Computing - Fall 2008 | ENGR 0012, Assignments of Engineering

Material Type: Assignment; Class: INTRO TO ENGINEERING COMPUTING; Subject: Engineering; University: University of Pittsburgh; Term: Fall 2008;

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-yh0
koofers-user-yh0 🇺🇸

5

(1)

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Engr 0012/0711: Introduction to Engineering Computing
page
1 of 4
Fall Term, 2008
Programming Assignment 13 - Due Monday, December 1
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
Matrix addition:
[]
[
]
[
]
NxMNxMNxM BAC
+
=
where jijiji bac ,,,
+
=
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
Matrix subtraction:
[]
[
]
[
]
NxMNxMNxM BAC
=
where jijiji bac ,,,
=
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
Matrix multiplication:
[]
[
]
[
]
PxNNxMPxM BAC =
where =
=
=Nk
kjkkiji bac 1,,,
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
Matrix element by element multiplication:
[
]
[
]
[
]
M
xP MxN M xN
CAB=
where
,,,
*
ij ij ij
cab=
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?)
pf3
pf4

Partial preview of the text

Download Assignment 13 - Introduction to Engineering Computing - Fall 2008 | ENGR 0012 and more Assignments Engineering in PDF only on Docsity!

page 1 of 4 Fall Term, 2008

Programming Assignment 13 - Due Monday, December 1

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

Matrix addition: [ C ] M xN =[ A ] MxN +[ B ] MxN

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

Matrix subtraction: [ C ] M xN =[ A ] MxN −[ B ] MxN

where ci (^) , j = ai , jbi , 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

Matrix multiplication: [ C ] M xP =[ A ] MxN [ B ] NxP

where ∑

= = (^) = 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

Matrix element by element multiplication: [ C ] M x P = [ A ] M x N [ B ] M x N

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

Programming Assignment 12 - Evaluation Criteria

Names __________________________________

Criteria Points

Available

Points

Awarded

Program Style

header in each function 10

purpose/goal state in headers 10

meaningful variable names 10

variables defined w/ comment 10

whitespace/readability 10

algorithm comments 10

Working Functions

no assignment statements

in main

display header function 10

file reading function 20

menu function 10

matrix add function 20

matrix subtract function 20

matrix multiply function 30

Element multiply function 20

screen display function 20

file report function 20

Program Function

pleasing user interface 40

switch/case in main 30

loops work in main 30

Total Pts: /