Re: vector_of_vector

Nasos Iliopoulos via ublas <[email protected]>
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <CY4PR22MB0790B6B6D96919D683C6EA8599710@CY4PR22MB0790.namprd22.prod.outlook.com>
Maybe use proxies, that are a light-weight view of what is in the matrix?

http://www.boost.org/doc/libs/1_47_0/libs/numeric/ublas/doc/matrix_proxy.htm

example:

#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?

Thanks



_______________________________________________
ublas mailing list
[email protected]<mailto:[email protected]>
https://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [email protected]<mailto:[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.