Boost logo

Ublas :

Subject: Re: [ublas] vector_of_vector
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2017-10-06 10:56:27

Maybe use proxies, that are a light-weight view of what is in the matrix?


#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>

int main () {
    using namespace boost::numeric::ublas;
    matrix<double> m (3, 3);
    for (unsigned i = 0; i < m.size1 (); ++ i) {
        matrix_row<matrix<double> > mr (m, i);
        for (unsigned j = 0; j < mr.size (); ++ j)
            mr (j) = 3 * i + j;
        std::cout << mr << std::endl;

Hi. I'd like to have a matrix<T> stored in such a way that I can quickly use each row (or else column) as a vector<T>. Seeing the vector_of_vector matrix type, at least the name suggests that this is what I need, but I suspect this is not so because I can't get it to do that. Does anyone have a hint on how to extract an entire row of a matrix into a vector as efficiently as possible?


ublas mailing list
Sent to: athanasios.iliopoulos.ctr.gr_at_[hidden]<mailto:athanasios.iliopoulos.ctr.gr_at_[hidden]>