Hello,
I have subscribed to the uBLAS mailing list to come with a proposal of an improvement.
In the current release (1.41.0) of Boost it is not possible to resize sparse matrices while preserving the data. A comment in the source code tells us this feature is unimplemented.
I am using the compressed_matrix<double, column_major> class to represent a sparse matrix and I do really want to increase the number of rows of that matrix on the fly while preserving all data in it. This should be a really trivial task, since no storage has to be changed. We only have to change the size1_ member. Could this behaviour be implemented in Boost in the future, even if not the full resize function would be implemented through this step?
In principle, the change would lead to code like this:
void resize (size_type size1, size_type size2, bool preserve = true) {
// FIXME preserve unimplemented
size1_ = size1;
size2_ = size2;
// some check here, which I don't know how to write in true uBLAS-style
if(major size is changed or minor size is decreased)
{
BOOST_UBLAS_CHECK (!preserve, internal_logic ());
capacity_ = restrict_capacity (capacity_);
filled1_ = 1;
filled2_ = 0;
index1_data_.resize (layout_type::size_M (size1_, size2_) + 1);
index2_data_.resize (capacity_);
value_data_.resize (capacity_);
index1_data_ [filled1_ - 1] = k_based (filled2_);
}
storage_invariants ();
}
Best wishes,
Fredrik Hellman