I'm using the boost library(1.44) and VC++ 2010.
I found some problem with below code,
using namespace boost::numeric;
typedef double value_type;
typedef ublas::mapped_matrix<value_type> StorageMap;
typedef ublas::mapped_matrix<value_type, ublas::row_major, std::tr1::unordered_map<size_t, value_type> > StorageUnorderedMap;
StorageMap mat; //<== (1)
//StorageUnorderedMap mat; //<== (2)
//Looping over non-zero elements of sparse matrix.
size_t numElemLoop= 0;
for(auto it1= mat.begin1(); it1 != mat.end1(); ++it1)
{
for(auto it2= it1.begin(); it2 != it1.end(); ++it2)
++numElemLoop;
}
assert(mat.nnz() == numElemLoop); //<== (3)
This test failed for only StorageUnorderedMap using std::tr1::unordered_map. But insert_element() and find_element() test passed for all.
Perhaps try to use unordered_multimap. It could be that some insertions fail because of equal keys. Then the counts will not match up.