Re: Sparse Matrix Question



On Apr 28, 11:00 pm, s...@xxxxxxxxxxxxxxx (Victor Eijkhout) wrote:
JC <jeffreycame...@xxxxxxxxx> wrote:
matrix. A sparse matrix is definitely the way to go here but I am
wondering what might be the best sparse matrix algorithm out of the
bunch to use based on the fact that the matrix must be:

- Easily cloneable
- Remove entire columns efficiently
- Remove entire rows efficiently
- Adding of new values can be relatively slower

Use a variant of Compressed Row Storage, where you overallocate each row
slightly. Then you need two pointers per row instead of one: the start
of each row and the end. That way deleting columns is doable by
compacting the rows that have elements in that column. Deleting a row
can also be done by compacting the whole data structure, or by using
mask bits, or by moving the pointer for the i-th row to the i+1st if you
remove the i-th row.

Victor.
--
Victor Eijkhout -- eijkhout at tacc utexas edu

If you need double type for your matrices, you could try

http://sourceforge.net/projects/mtxfx/

It is highly efficient for removing/adding columns (but requires
copying for row removing/addition).
.