The following is my implementation of a sparse matrix class. Feel free to comment on my bad coding style as well as use the code. The input file is the bcsstk14 matrix from http://math.nist.gov/MatrixMarket/
Space savings is huge for this matrix. It has about 40,000 nonzeros, the number of elements in the matrix is about 2000^2=4,000,000. So the sparse matrix takes up about 1% (plus pointers and stuff) of the space required for the dense matrix (array[][]).
There is a multiplication timer in the test file, it comes out with .005 seconds whereas dense multiplication takes about 7 seconds (Linux P4 2.3GHz) for this matrix. Which is a speedup factor of about 1400.
Then I have to store a column index up to n times for each element in a row. My implementation is basically Compressed Row Storage see http://www.netlib.org/linalg/html_templates/node90.html
This saves more space by adding a few more pointers.
No... but how would you execute a fast MatVec multiply with std::map<std::pair<size_t,size_t>,T>? I need to have pointers to each row for mine to work.
And how can I determine the amount of memory being used, during execution that is. I tried doing some sizof() things but it only gives the size of the pointer. Is there a recursive sizeof() ? I do not really want to do a memory analysis by hand.
I was hoping for something a bit more specific (yes indeed that was a pun). But I suppose if I have a big enough matrix it will dominate the memory slot.