Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 6: Loops with 2 dimensional arrays Matrix Multiplication In this lab you will be using Java to perform Matrix operations. The Matrix operations that

Assignment 6: Loops with 2 dimensional arrays Matrix Multiplication

In this lab you will be using Java to perform Matrix operations. The Matrix operations that you will be performing are Addition, Subtraction, and Multiplication.

Of these, the Multiplication is the most complex operation and requires a bit of careful thought in order to get it right.

For the purposes of this assignment assume that you are working with square matrices (i.e. matrices that have an equal number of rows and columns); also make the assumption that the first index in a 2D array are being used to represent row, and the second index for column.

An individual item in a Matrix is called an element or cell. Thus, a11 is the element/cell at row 1, column 1.

Task 1: Researching Matrix Multiplication

First research on the web to learn more about Matrix Multiplication.

Here are some helpful resources:

https://www.mathsisfun.com/algebra/matrix-multiplying.html - helpful and clear description of Matrix Multiplication.

http://mathworld.wolfram.com/MatrixMultiplication.html - more exhaustive description of Matrix Multiplication; this may be helpful in thinking how to generalize the formula/operation for a specific cell.

https://matrix.reshish.com/multiplication.php - you can use this calculator to check your results.

Task 2: Matrix Addition

Deliverable 1: Complete the code for Matrix Addition and include a screenshot of working Matrix addition here.

Task 3: Matrix Addition

Deliverable 2: Complete the code for Matrix Addition and include a screenshot of working Matrix addition here.

Task 4: Matrix Multiplication

Now write the program to perform the Matrix multiplication.

First make sure that you have a good handle on how to calculate the individual cells.

You can use the Matrix we have been using in class as a reference:

A =

3

4

5

2

9

7

17

3

19

B =

12

1

5

3

7

9

11

23

99

R = A * B =

103

146

546

128

226

784

422

475

1993

This is what will need careful thought. You will still need the 2 for loops to go through each cell in the Result matrix; so what we are concerned about is how to get the right value for each cell.

A =

3

4

5

2

9

7

17

3

19

B =

12

1

5

3

7

9

11

23

99

R = A * B =

103

146

546

128

226

784

422

475

1993

r11 = a11 * b11 + a12 * b21 + a13 * b31

= 3 * 12 + 4 * 3 + 5 * 11

= 36 + 12 + 55

= 103

Carefully study the formula for that first cell and see whether you can determine what to do. Remember that you could utilize a Method to perform the operations for each resultant cell.

Here is the same formula rewritten in array terms:

R[0][0] = A[0][0] * B[0][0] + A[0][1] * B[1][0] + A[0][2] * B[2][0]

Does that help you to detect a pattern?

Deliverable 3: Write down your program logic for how to complete the Matrix Multiplication.

Deliverable 4: Include a screenshot of the working Matrix Multiplication.

Submission instructions:

Please save your modified document with a name in the following format:

Lastname_firstname_COMP170_Assignment6.docx

Submit the document and source code files to Sakai. Do not .zip the files into one file.

Grading

Assignment 6: Loops with 2 dimensional arrays Matrix Multiplication. 1

Deliverable 1 (5 points). 2

Deliverable 2 (5 points). 2

Deliverable 3 (1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions