Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class SparseMatrix with an __init__ method which uses a numpy.array matrix as input and which generates an internal representation of the matrix in

Write a class SparseMatrix with an __init__ method which uses a numpy.array matrix as input and which generates an internal representation of the matrix in CSR form. Furthermore it should set an attribute intern_represent to the value CSR.

Furthermore the __init__ method should create an attribute number_of_nonzero reporting the number of nonzero elements

Give the class a method, which allows to change a particular element in the matrix. It should have the elements indexes i, j and its value aij as input. If it changes the numbers of nonzero elements it should change the attribute number_of_nonzero accordingly.

Give the class a method changing the internal representation from CSR to CSC. Dont forget to also change the attribute intern_represent.

Extend your __init__ method by an extra parameter Tol which serves as a threshold for converting a given matrix to a sparse matrix. All elements of the original matrix which have an absolute value less than Tol should be considered as zeros. Give Tol a default value 0.

Write a method for elementwise addition of two objects of type SparseMatrix.

Write a method which multiplies a SparseMatrix with a numpy.array of rank one (i.e. a vector).

The last three lines are the important thing.

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago