Search code examples
c++loopsiteratorsparse-matrixarmadillo

What is "rudimentary" about Armadillo's sp_mat::const_row_iterator?


Armadillo's documentation mentions that the sp_mat::const_row_iterator is rudimentary (link). I was wondering what this means in the following context. I am deciding between the following two strategies for reading all column values corresponding to each of the rows (in a given set of rows, call it A) from an Armadillo sparse matrix: 1) Loop through each column using an appropriate iterator; if .row() is in A, we extract the element; repeat. 2) For each row in A, use sp_mat::const_row_iteratorobtained with a .begin_row(row) call to iterate through values corresponding to only that row. Does "rudimentary" in the Armadillo documentation means pretty much doing (1)? Or, is it more cost effective than strategy (1)?


Solution

  • From here: http://arma.sourceforge.net/docs.html#SpMat it says sparse matrix support is "preliminary." Not rudimentary. Perhaps it was changed since you read it last. Or you need to provide a link directly to the documentation you are referring to.

    In either case I would read it as telling you that the sparse matrix support has only just been introduced and it may be buggy or may change in future versions.

    And I looked at the source code, and I believe that documentation is out of date and wrong. There's nothing "forward" or "rudimentary" about the iterator implementation.

    From armadillo-7.800.1/include/armadillo_bits/SpMat_iterators_meat.hpp around line 525 is the const_row_iterator implementation, and it looks random access and very complete to me.