A
aaragon
Hello everyone,
Some time ago I coded a sparse matrix class using a hashed container
that mapped a std:air<size_t,size_t> to a double (i,j representing
the location in the matrix and the double the value). This worked
fine, and it was quite fast, but I had problems when trying to get the
matrix-matrix multiplication so I went ahead and coded a second sparse
matrix class. This time I had a hashed map that mapped the index i
(representing the row) to another hashed map that mapped the j index
to the value. Now the new implementation takes more time of course
because there are two hashing functions involved. I'm wondering if the
creating of m + 1 hash tables (m being the number of rows) has a much
higher overhear than creating just a single hashed container for the
whole thing as in the first implementation.
Does anyone have any suggestions on how to improve this code? I
thought about maybe creating a regular array or an std::vector of hash
tables instead of using a hash table to map the rows, this way I could
avoid one hash function and access the row in constant time. But
before I decided to spend some time coding this, I wanted to ask other
people about it.
Thanks a lot,
aa
Some time ago I coded a sparse matrix class using a hashed container
that mapped a std:air<size_t,size_t> to a double (i,j representing
the location in the matrix and the double the value). This worked
fine, and it was quite fast, but I had problems when trying to get the
matrix-matrix multiplication so I went ahead and coded a second sparse
matrix class. This time I had a hashed map that mapped the index i
(representing the row) to another hashed map that mapped the j index
to the value. Now the new implementation takes more time of course
because there are two hashing functions involved. I'm wondering if the
creating of m + 1 hash tables (m being the number of rows) has a much
higher overhear than creating just a single hashed container for the
whole thing as in the first implementation.
Does anyone have any suggestions on how to improve this code? I
thought about maybe creating a regular array or an std::vector of hash
tables instead of using a hash table to map the rows, this way I could
avoid one hash function and access the row in constant time. But
before I decided to spend some time coding this, I wanted to ask other
people about it.
Thanks a lot,
aa