Question: In python: Define a subclass of Matrix called SparseMatrix. In a sparse matrix, we keep track of the nonzero elements in a dictionary. The keys
In python:
Define a subclass of Matrix called SparseMatrix. In a sparse matrix, we keep track of the nonzero elements in a dictionary. The keys are tuples (i,j) giving the location of the element and the value assigned to this key gives the value of the nonzero element. If a tuple (i,j) does not appear in the dictionary, the matrix element at that location is assumed to be zero. When creating or modifying a sparse matrix, we dont want to store zero entries. In the class SparseMatrix override some (but as few as possible) of the parent class Matrix to make sparse matrices work anywhere you can put a Matrix
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
