Part 1 – Basic Implementation

You must implement a Sparse Matrix as described in class. Values stored in the matrix should be doubles. You must implement the following methods:

public class SparseMatrix { public SparseMatrix(int numRows, int numColumns) { // create a new, empty sparse matrix } public double get(int row, int column) { // return the value at the specified row and column } public void set(double value, int row, int column) { // set the value of the matrix at the provided position // if value is not zero you should add/edit a Node // if value is zero then you must delete the node // (and any row/column dummies that are no longer needed) } public String toString() { // return the matrix as a printable, multi-line String } }

Part 2 – Matrix Multiplication

Matrix multiplication is a common operation. You must implement the following two meth- ods:

public void multiplyBy(SparseMatrix other){ // multiply this matrix by other. } public void multiplyBy(double[][] other) { // multiply this sparse matrix by a normal 2D array matrix }

Part 3 – Main

You must implement a main method that will create 2 sparse matrices interactively and multiply them together, printing the result of every operation. Interactive input must by done using the command-line; do NOT use JOptionPane.

First, main must ask the user to enter the size of the matrix A. Create two sparse matrices (A and B). B is the same size as A, but with the rows and columns reversed. So if A is 4 rows and 10 columns, B is 10 rows and 4 columns.

Then main will ask the user to set a value in either A or B. If the user types in ”A 1 3 4” then set A[1][3] = 4. Likewise entering ”B 2 1 8” sets B[2][1] = 8. This loop continues until the user enters the string ”done”.

After every operation you must print out both matrices. Finally, after the user as entered ”done” you must call ”A.multiplyBy(B)” and print the result of the multiplication.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.