Boost logo

Ublas :

Subject: [ublas] How to sort rows/columns in sparse matrix
From: Ernest Turro (ernest.turro_at_[hidden])
Date: 2010-03-05 11:27:03


I'd like to sort the rows of my row-major compressed_matrix. Ideally I would use standard sort(), passing mat.begin1(), mat.end1() and a compare function. The compare function would take two matrix_row<M> parameters, use them to compare the two rows by iterating over the non-zero elements and return a boolean. However, this results in plenty of compiler errors relating to various operands not being implemented for the two iterators (-, +, <) (cf. ). Does anyone have any suggestions on how to achieve this? I imagine it would be quite useful in general, e.g. to remove duplicate rows from a sparse matrix.