Opened 12 years ago

#4860 new Bugs

Rational does not play well with uBlas

Reported by: pierluigi.rolando@… Owned by: Gunter
Milestone: To Be Determined Component: uBLAS
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

I'm trying to solve a rational linear system using boost/rational + uBlas. I've tried to copy many examples on the web that all follow the same line:

	typedef permutation_matrix<rational_t> pmatrix;
	pmatrix pm(a.size1());
	matrix_t inverse(a.size1(), a.size2());
	lu_factorize(a, pm);

	inverse.assign(identity_matrix<rational_t>(a.size1()));
	lu_substitute(a, pm, inverse);

a is of type matrix_t, which is defined as follows:

typedef rational<long long int> rational_t;
typedef matrix<rational_t> matrix_t;

Compilation fails on the lu_factorize function call with the following error messages:

In file included from interpolator.cpp:5:
/usr/local/include/boost/numeric/ublas/lu.hpp: In function ‘void boost::numeric::ublas::swap_rows(const PM&, MV&, boost::numeric::ublas::matrix_tag) [with PM = boost::numeric::ublas::permutation_matrix<boost::rational<long long int>, boost::numeric::ublas::unbounded_array<boost::rational<long long int>, std::allocator<boost::rational<long long int> > > >, MV = boost::numeric::ublas::matrix<boost::rational<long long int>, boost::numeric::ublas::basic_row_major<long unsigned int, long int>, boost::numeric::ublas::unbounded_array<boost::rational<long long int>, std::allocator<boost::rational<long long int> > > >]’:
/usr/local/include/boost/numeric/ublas/lu.hpp:90:   instantiated from ‘void boost::numeric::ublas::swap_rows(const PM&, MV&) [with PM = boost::numeric::ublas::permutation_matrix<boost::rational<long long int>, boost::numeric::ublas::unbounded_array<boost::rational<long long int>, std::allocator<boost::rational<long long int> > > >, MV = boost::numeric::ublas::lu_factorize(M&, PM&) [with M = matrix_t, PM = main()::pmatrix]::matrix_type]’
/usr/local/include/boost/numeric/ublas/lu.hpp:165:   instantiated from ‘typename M::size_type boost::numeric::ublas::lu_factorize(M&, PM&) [with M = matrix_t, PM = main()::pmatrix]’
interpolator.cpp:122:   instantiated from here
/usr/local/include/boost/numeric/ublas/lu.hpp:83: error: no matching function for call to ‘row(boost::numeric::ublas::matrix<boost::rational<long long int>, boost::numeric::ublas::basic_row_major<long unsigned int, long int>, boost::numeric::ublas::unbounded_array<boost::rational<long long int>, std::allocator<boost::rational<long long int> > > >&, const boost::rational<long long int>&)’
/usr/local/include/boost/numeric/ublas/matrix_proxy.hpp:466: note: candidates are: boost::numeric::ublas::matrix_row<M> boost::numeric::ublas::row(M&, typename M::size_type) [with M = boost::numeric::ublas::matrix<boost::rational<long long int>, boost::numeric::ublas::basic_row_major<long unsigned int, long int>, boost::numeric::ublas::unbounded_array<boost::rational<long long int>, std::allocator<boost::rational<long long int> > > >]
/usr/local/include/boost/numeric/ublas/matrix_proxy.hpp:471: note:                 const boost::numeric::ublas::matrix_row<const M> boost::numeric::ublas::row(const M&, typename M::size_type) [with M = boost::numeric::ublas::matrix<boost::rational<long long int>, boost::numeric::ublas::basic_row_major<long unsigned int, long int>, boost::numeric::ublas::unbounded_array<boost::rational<long long int>, std::allocator<boost::rational<long long int> > > >]

It looks like the two libraries do not play well together, which means that Boost is basically useless for what I'm trying to do :-/

Change History (0)

Note: See TracTickets for help on using tickets.