【问题标题】:Compile Error - boost::numeric::ublas::coordinate_matrix编译错误 - boost::numeric::ublas::coordinate_matrix
【发布时间】:2012-03-21 12:21:34
【问题描述】:

对于一般信息,我使用 boost 1.46。自此版本以来,ublas lib 没有任何变化。

我使用gcc 4.6版编译。

所以现在我的问题。我有一个非常基本的类,它应该适合 boost 矩阵类到自定义接口。该类如下所示:

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);
}

};

在编译此类时,两个运算符(int i,int j)都会出现编译器错误:

./inc/boost_coordinate_matrix.h:38:15: 从‘TYPE BoostCoordinateMatrix::operator()(int, int) const [with TYPE = double]'实例化 ./inc/flow_field_matrix_free_interface_impl.h:697:1:从这里实例化 /usr/include/c++/4.6/bits/stl_tempbuf.h:257:6: 错误:'boost::numeric::ublas::index_triple, boost::numeric::ublas: :unbounded_array, boost::numeric::ublas::unbounded_array > > >&' 来自 '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: 错误:传递 'void std::__uninitialized_construct_buf(_ForwardIterator, _ForwardIterator, _Tp&) 的参数 3 [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 > > >]'

希望有人能帮帮我。

【问题讨论】:

  • BoostCoordinateMatrix::operator()(int, int) const中的.ref()成员函数是什么?
  • operator(int i, int j) 返回一个辅助类而不是真正的引用。 .ref() 得到了正确的参考,至少我认为它是这样工作的……我有一个用于压缩矩阵数据类型的工作接口,它也使用这种语法。编辑:sry .ref() 在此代码中使用了错误的函数,我在格式化时弄混了,我现在将解决这个问题。然而,他们的错误是正确的......
  • /inc/flow_field_matrix_free_interface_impl.h:697:1 发生了什么?
  • 这不是问题,我不想在这里发布 flow_field 代码,它太大了......这个问题可以通过一个简单的 main 函数重现: int main(int argc, char *argv) { BoostCoordinateMatrix 矩阵(3,3); for(int i = 0; ij+j); } } const double m = 矩阵(1,2);返回0; }

标签: c++ gcc boost ublas


【解决方案1】:

好的,我想我找到了问题:

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

我刚刚测试了最新的 boost 版本,这个也没有编译。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 2014-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多