我有一段非常简单的处理矩阵的代码。这是一个简短的摘录:
typedef boost::multiprecision::cpp_dec_float_100 SuperFloat;
typedef boost::numeric::ublas::matrix<SuperFloat> Matrix;
int function(Matrix& matrix){
boost::numeric::ublas::permutation_matrix<std::size_t> pm(matrix.size1());
int res = lu_factorize(matrix,pm); // this is a problem
return res;
}
该代码使用 g++ 5.2.0 和 boost 1.58 在我的笔记本上完美编译和运行。但是,当我尝试在工作中使用 gcc 4.9.2 和 boost 1.53 在我的台式机上编译相同的代码时,我收到一条可怕的错误消息(数英里的模板参数),最终结果如下:
cannot convert ‘boost::numeric::ublas::norm_inf
# gazillions of template arguments
to type ‘const bool&’
std::max<S> (std::max<S> (norm_inf (e1), norm_inf (e2)), min_norm);
stl_algobase.h:261:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
我现在有点困惑。参数的模板解析似乎失败了,这导致两个参数max
属于不同的类型。不幸的是,我不能明确地对它们进行类型转换,因为导致问题的实际调用被埋在 boost 中的某个地方uBLAS
。
由于我能够在我的笔记本上使用不同的 gcc 和 boost 版本编译相同的代码,因此这里一定存在某种版本问题。从 gcc4.9 到 5.2 是否有一些影响模板分辨率的特殊变化,或者 uBLAS 在 boost 中是否存在导致此问题的问题?
克服此类问题的建议方法是什么?虽然显而易见的解决方案是在我的工作计算机上更新 gcc 和 boost,但编写依赖于某些版本的 gcc 或 boost 来编译它的代码肯定不是非常可取的。