Chat with us, powered by LiveChat Algorithms and Abstract Data Types | WriteDemy

Question Description

In this assignment you will create a calculator for performing matrix operations that exploits the (expected)sparseness of it’s matrix operands. An 𝑛 × 𝑛 square matrix is said to be sparse if the number of non-zeroentries (abbreviated NNZ) is small compared to the total number of entries, 𝑛2. The result will be a Javaprogram capable of performing fast matrix operations, even on very large matrices, provided they aresparse.Given 𝑛 × 𝑛 matrices A and B, their product 𝐶 = 𝐴 ⋅ 𝐵 is the 𝑛 × 𝑛 matrix whose 𝑖𝑗thentry is given by𝐶𝑖𝑗 = ∑ 𝐴𝑖𝑘𝑛𝑘=1 𝐵𝑘𝑗.Thus the element in the ith row and jth column of C is the vector dot product of the ith row of A with the jthcolumn of B. If we consider addition and multiplication of real numbers to be our basic operations, thenthe above formula can be computed in time Θ(𝑛3), which is impractical for matrix sizes n of more than afew thousand. If it so happens that A and B are sparse, then a great many of these arithmetic operationsinvolve adding or multiplying by zero, hence are unnecessary.The sum S, and difference D, of A and B are the 𝑛 × 𝑛 matrices having 𝑖𝑗thentries:𝑆𝑖𝑗 = 𝐴𝑖𝑗 + 𝐵𝑖𝑗 and 𝐷𝑖𝑗 = 𝐴𝑖𝑗 − 𝐵𝑖𝑗The scalar product of a real number x with A is denoted 𝑥𝐴, and has 𝑖𝑗thentry (𝑥𝐴)𝑖𝑗 = 𝑥 ⋅ 𝐴𝑖𝑗. Thetranspose of A, denoted 𝐴𝑇, is the matrix whose 𝑖𝑗𝑡ℎentry is the 𝑗𝑖𝑡ℎentry of A: (𝐴𝑇)𝑖𝑗 = 𝐴𝑗𝑖. In otherwords, the rows of A are the columns of 𝐴𝑇, and the columns of A are the rows of 𝐴𝑇. Each of theseoperations can be computed in time Θ(𝑛2), and just as for multiplication, their cost can be improved uponsignificantly when A and B are sparse.As one would expect, the cost of a matrix operation depends heavily on the choice of data structure usedto represent the matrix operands. There are several ways to represent a square matrix with real entries. Thestandard approach is to use a 2-dimensional 𝑛 × 𝑛 array of doubles. The advantage of this representationis that all of the above matrix operations have a straight-forward implementation using nested loops. Thisproject will use a very different representation however. Here you will represent a matrix as a 1-dimensionalarray of Lists. Each List will represent one row of the Matrix, but only the non-zero entries will be stored.Therefore List elements must store, not just the matrix entries, but the column index in which those entriesreside. For example, the matrix below would have the following representation as an array of Lists.𝑀 = [1.0 0.0 2.03.0 0.0 0.00.0 4.0 5.0] Array of Lists: [1: (1,1.0) (3,2.0)2: (1,3.0)3: (2,4.0) (3,5.0)This method obviously results in a substantial space savings when the Matrix is sparse. In addition, thestandard matrix operations defined above can be performed more efficiently on sparse matrices. As youwill see though, the matrix operations are much more difficult to implement using this representation. Thetrade-off then, is a gain in space and time efficiency for sparse matrices, at the expense of more complicatedalgorithms for performing standard matrix operations. Designing these algorithms in terms of our List ADToperations will constitute the majority of the work you do on this assignment.It will be necessary to make some minor changes to your List ADT from pa1. First you must convert yourList ADT from a List of ints to a List of Objects. This entails changing certain field types, declarationstatements, method parameters, and return types from int to Object. The Objects referred to by these Listelements will be defined in the Matrix ADT specified below. Second, it will be necessary to eliminate theList operations copy() and cat() (which was optional anyway.) All other List operations from pa1 will beretained. The equals() operation however will be altered slightly so as to override, rather than overloadObject's built in equals() method. This is done by changing it's signature from boolean equals(ListL), as in pa1 to public boolean equals(Object x), which is it's signature in the superclass Object.Indeed, all equals() methods in this project should carry this same signature.File FormatsThe top level client module for this project will be called Sparse.java. It will take two command linearguments giving the names of the input and output files, respectively. The input file will begin with asingle line containing three integers n, a and b, separated by spaces. The second line will be blank, and thefollowing a lines will specify the non-zero entries of an 𝑛 × 𝑛 matrix A. Each of these lines will contain aspace separated list of three numbers: two integers and a double, giving the row, column, and value of thecorresponding matrix entry. After another blank line, will follow b lines specifying the non-zero entries ofan 𝑛 × 𝑛 matrix B. For example, the two matrices

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order