Boost logo

Boost Users :

Subject: [Boost-users] assigning a value to a matrix shared_ptr
From: Max S. Kaznady (max.kaznady_at_[hidden])
Date: 2010-07-27 20:40:38


Hello,

I am trying to assign a value to the matrix, which is pointed to by
the shared pointer, but I am not sure which operator to call, please
have a look at the following code, I commented the problem:

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

int main () {
    using namespace boost::numeric::ublas;
    matrix<double> m (3, 3);
    boost::shared_ptr<matrix<double>> m2(new matrix<double>(3,3));
    for (unsigned i = 0; i < m.size1 (); ++ i)
        for (unsigned j = 0; j < m.size2 (); ++ j) {
            m (i, j) = 3 * i + j;
            /// now do the same operation to the shared pointer's matrix
            m2->operator*(i, j) = 3 * i + j; // this results in a runtime error
    }
    std::cout << m << std::endl;
    // And how do we print m2 ?
}

Thanks,
Max


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net