Sparse matrix column/row removal.
Describe the feature you would like to be implemented.
Matrix column (or row according when RowMajor) removal (and addition) for sparse matrices.
Would such a feature be useful for other users? Why?
If you think people might want to resize a matrix, there is no reason to belive the removed or added dimensions have to be the "last ones".
People are doing column removal by doing very expensive copies in a loop. But removing a column by manipulating CompressedStorage would cost almost nothing!
In my case, I am writing a GCS (geometric constraint system), and when a constraint is removed, I need to remove a column. I will simply subclass SparseMatrix and implement it, by now.
Adding a column filled with zeros is very easy, either. One might want to decide whether to use (some of the) "left" column's free space or not.
Any hints on how to implement the requested feature?
Remove a column: (column j) Besides resizing / managing allocated buffers...
// use memcpy... I don't really know...
for(i=j;.....; ++i)
{
m_outerIndex[i] = m_outerIndex[i+1];
m_innerNonZeros[i] = m_innerNonZeros[i+1];
}
Adding is not hard, either. After increasing the size of allocated buffers...
// use memcpy... I don't really know...
for(i=j;.....; ++i)
{
m_outerIndex[i+1] = m_outerIndex[i];
m_innerNonZeros[i+1] = m_innerNonZeros[i];
}
m_innerNonZeros[j] = 0;