Question
You are required to define and create two sparse matrices, each 1000x1000 in dimension, and add them together to produce a final result matrix. In other words, if A and B are two sparse matrices, you are required to evaluate C = A + B.
This assignment has three major steps: (i) create matrices A and B, (ii) perform the addition of A and B and store the result in a new sparse matrix called C, and (iii) display C. We will next look at each of these steps in greater detail.
1 What is a Matrix? In mathematics, a matrix is an array of elements. Each element in the matrix has a row and column associated with it. A matrix that is comprised of m rows and n columns is denoted as an m X n matrix. 2 Sparse Matrix: an Introduction A sparse matrix is a matrix that consists of elements that are primarily zeroes. Few elements in the matrix have a value associated with them. Matrices are normally represented as a 2-dimensional array in most programming languages For example, an 10 x 8 (m 10, n 8) matrix could be stored in a C++ array of 10 rows and 8 columns, such as matrix[10] [8]. However, an array representation of sparse matrices is highly inefficient. This is because each cell in an array takes a few bytes of memory storage, even if the element is zero. Hypothetically, if every such cell took 8 bytes of storage, a 10000 x 10000 would account for a total storage of 8 × 10000 × 10000 bytes (= 8 x 108 bytes, or 800 million bytes). It is not hard to see that most conventional laptops/PC's will simply bail out if one were to add two such matrices together You are encouraged to read more about sparse matrices, and their myriad applications in a wide variety of domains 3 P roiect Goal You are required to define and create two sparse matrices, each 1000 x 1000 in dimension, and add them together to produce a final result matrix. In other words, if A and B are two sparse matrices, you are required to evaluate C = A + B This assignment has three major steps: (i) create matrices A and B, (ii) perform the addition matrix called C, and (iii) display C. We will of A and B and store the result in a new sparse next look at each of these steps in greater detail
Explanation / Answer
I given input manually , you can set it easily by keeping scanner tp take input values or Random to autofill
Random r=new Random();
r.nextInt(10);