Boost logo

Ublas :

Subject: [ublas] [projections] crow & ccolumn
From: dariomt_at_[hidden]
Date: 2011-07-01 06:45:35


Hi,

I've noticed there are two free functions row() and column() overloaded on
the const-ness of the matrix, but there is no shortcut to force creating a
row or column proxy on a const matrix from a non-const matrix.

I'd like to propose adding two more free functions ublas::crow() and
ublas::ccolumn(), following the style of boost::cref() (wrt boost::ref) or
the C++0x cbegin() and co. Better names are a possibility, maybe const_row()
and const_column()?

I can even suggest some code, hopefully correct:

template<class M>
    BOOST_UBLAS_INLINE
    const matrix_row<const M> crow (M &data, typename M::size_type i) {
        return matrix_row<const M> (data, i);
    }

template<class M>
    BOOST_UBLAS_INLINE
    const matrix_column<const M> ccolumn (M &data, typename M::size_type j)
{
        return matrix_column<const M> (data, j);
    }

Do you think this is worth having in Boost.Ublas?