1
votes

For general information I use boost 1.46. There have been no changes in ublas lib since this version.

I use gcc version 4.6 to compile.

So now my problem. I have a very basic class which is supposed to fit the boost matrix class to a self defined interface. The class looks like this:

template< typename TYPE >
class BoostCoordinateMatrix: public MatrixInterface<TYPE> ,
    public boost::numeric::ublas::coordinate_matrix<TYPE> {
public:
BoostCoordinateMatrix() :
    boost::numeric::ublas::coordinate_matrix<TYPE>() {
}

BoostCoordinateMatrix(int rows, int columns) :
    boost::numeric::ublas::coordinate_matrix<TYPE>(rows, columns) {
}

int rows() const {
    return this->size1();
}

int columns() const {
    return this->size2();
}

virtual void set(int row, int column, TYPE value) {
    (*this)(row, column) = value;
}

TYPE& operator()(int i, int j) {
    return this->boost::numeric::ublas::coordinate_matrix<TYPE>::operator()(
            i, j).ref();
}

TYPE operator()(int i, int j) const {
    return this->boost::numeric::ublas::coordinate_matrix<TYPE>::operator()(
            i, j);
}

};

When compiling this class I get a compiler error for both operator(int i, int j):

./inc/boost_coordinate_matrix.h:38:15: instantiated from ‘TYPE BoostCoordinateMatrix::operator()(int, int) const [with TYPE = double]’ ./inc/flow_field_matrix_free_interface_impl.h:697:1: instantiated from here /usr/include/c++/4.6/bits/stl_tempbuf.h:257:6: error: invalid initialization of non-const reference of type ‘boost::numeric::ublas::index_triple, boost::numeric::ublas::unbounded_array, boost::numeric::ublas::unbounded_array > > >&’ from an rvalue of type ‘boost::numeric::ublas::indexed_iterator, boost::numeric::ublas::unbounded_array, boost::numeric::ublas::unbounded_array > >, std::random_access_iterator_tag>::reference {aka boost::numeric::ublas::index_triple, boost::numeric::ublas::unbounded_array, boost::numeric::ublas::unbounded_array > > >}’ /usr/include/c++/4.6/bits/stl_tempbuf.h:232:5: error: in passing argument 3 of ‘void std::__uninitialized_construct_buf(_ForwardIterator, _ForwardIterator, _Tp&) [with _ForwardIterator = boost::numeric::ublas::index_triple, boost::numeric::ublas::unbounded_array, boost::numeric::ublas::unbounded_array > > >*, _Tp = boost::numeric::ublas::index_triple, boost::numeric::ublas::unbounded_array, boost::numeric::ublas::unbounded_array > > >]’

I hope someone can help me out.

1
What is the .ref() member function in BoostCoordinateMatrix::operator()(int, int) const?Emile Cormier
operator(int i, int j) returns a helperclass instead of the real reference. .ref() gets the right reference, at least this is how i think it works... I have a working interface for the compressed_matrix datatype, which also uses this syntax. EDIT: sry the .ref() was on the wrong function in this code, i got mixed up while formating it, i will now fix this. Ther error nevertheless was the right one...Thorsten
What's happening at /inc/flow_field_matrix_free_interface_impl.h:697:1 ?user1201210
that's not the problem, i don't want to post the flow_field code here, its huge... The problem is reproducable with a simple main function: int main(int argc, char *argv) { BoostCoordinateMatrix<double> matrix(3,3); for(int i = 0; i<3; ++i) { for(int j = 0; j<3 ; ++j) { matrix.set(i,j, ij+j); } } const double m = matrix(1,2); return 0; }Thorsten

1 Answers

0
votes

Ok i think i found the problem:

http://boost.2283326.n4.nabble.com/example-usage-of-coordinate-matrix-fails-on-Ubuntu-11-04-amd-64-td3580407.html

I just tested the newest boost version and this one doesn't compile either.