我正在尝试使用boost
多精度模板库以及lapack
后端的数字绑定来实现一些数字过程。
但是,模板分辨率似乎没有按预期工作。我已经能够将它缩小到这个最小的例子:
#include <boost/numeric/ublas/symmetric.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/numeric/bindings/traits/ublas_matrix.hpp>
#include "boost/numeric/bindings/lapack/syev.hpp"
#include "boost/numeric/bindings/lapack/workspace.hpp"
typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<100> > SuperFloat;
typedef std::numeric_limits<boost::multiprecision::cpp_dec_float<100> > SuperFloatPrecision;
typedef boost::numeric::ublas::matrix<SuperFloat> Matrix;
typedef boost::numeric::ublas::symmetric_matrix<SuperFloat> MatrixSym;
inline int diagonalize(Matrix& eigenvectors, boost::numeric::ublas::vector<SuperFloat>& eigenvalues) {
int r = boost::numeric::bindings::lapack::syev( 'U', eigenvectors, eigenvalues, boost::numeric::bindings::lapack::minimal_workspace() );
return r;
}
int main(){
std::cout << "hello!" << std::endl;
return 0;
}
产生此错误消息:
boost/numeric/bindings/lapack/syev.hpp: In instantiation of ‘int boost::numeric::bindings::lapack::syev(char, A&, W&, boost::numeric::bindings::lapack::minimal_workspace) [with A = boost::numeric::ublas::matrix<boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u> > >; W = boost::numeric::ublas::vector<boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u> > >]’:
test.cxx:13:137: required from here
boost/numeric/bindings/lapack/syev.hpp:163:8: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’
BOOST_STATIC_ASSERT( (boost::mpl::or_< boost::is_same< matrix_structure, traits::symmetric_t >
^
In file included from ./boost/numeric/bindings/traits/traits.hpp:18:0,
from ./boost/numeric/bindings/traits/ublas_matrix.hpp:17,
from test.cxx:3:
./boost/numeric/bindings/traits/matrix_traits.hpp: In instantiation of ‘char boost::numeric::bindings::traits::matrix_uplo_tag(SymmM&) [with SymmM = boost::numeric::ublas::matrix<boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u> > >]’:
boost/numeric/bindings/lapack/syev.hpp:181:47: required from ‘int boost::numeric::bindings::lapack::syev(char, A&, W&, boost::numeric::bindings::lapack::minimal_workspace) [with A = boost::numeric::ublas::matrix<boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u> > >; W = boost::numeric::ublas::vector<boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u> > >]’
test.cxx:13:137: required from here
./boost/numeric/bindings/traits/matrix_traits.hpp:141:56: error: no type named ‘uplo_type’ in ‘struct boost::numeric::bindings::traits::matrix_traits<boost::numeric::ublas::matrix<boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u> > > >’
typedef typename matrix_traits<SymmM>::uplo_type uplo_t;
是否可以使用lapack
作为升级UBLAS
的后端,模仿多精度,或者这是徒劳的努力?
有没有其他方法可以做,例如,ublas多精度矩阵的特征向量分解?