Starting from:
$26.99

$20.99

Homework 6 solution

For this assignment you will turn in:

 

In class(10pts):

 

1.       A statement of the problem (typed)

 

2.       An explanation of your solution (typed)

 

3.       A flowchart (hand-drawn or computer generated)

 

4.       Pseudocode (typed)

 

Via BlackBoard(40pts):

 

1.       C program named <username_matrix_mult.c

 

Assignment:

 

Follow the steps that we have outlined in class for algorithm development to generate a program that takes in two matrices (A and B) and multiplies them, then outputs the result. Remember matrix multiplication is NOT just C[0][0] = A[0][0]*B[0][0]. To multiply two matrices (A and B) together first, the number of columns in A must equal the number of rows in B. So A (4x2) x B (2x3) = C (4x3). Matrix multiplication works as follows:

11

1
 
11


= ( ⋮

⋮ ) ,  = ( ⋮

⋮ )
 1

 
 
 

 
 
 
 
 
 1
 
 
 
 
11


 
 
×  = (  ⋮


)
 
 
 
 1

 
 
 
  ℎ          = ∑                ∗

 =1

 

In short, you multiply each individual element of the row of A to the corresponding element of the column of B and then sum them.

Specifications:

 

Inputs:

 

-          Dimensions of each array (n x m)

 

-          The elements of each matrix (A and B)

 

Outputs:

 

-          The resulting matrix C=A x B

 

Functions:

 

1.  void printMatrix(int row, int col, float m[row][col])

 

a.       prints a nicely formatted matrix

 

2.  float calcEntry(float x[], float y[])

 

a.       Takes the ith row of A and the jth column from B in order to calculate C[i][j]

b.      Returns the value that will be put into C[i][j]

 

*  This is the minimum functions that you must use. You may use others if you like.

 

Other:

 

1.       This is individual work. You may NOT work in groups.

 

2.       Please staple all work together.

 

3.       You are expected to error check.

 

4.       For code: No compile = No points, no exceptions!

More products