|
Ublas : |
From: Helfer Thomas (helferthomas_at_[hidden])
Date: 2005-12-23 13:43:27
Hello list,
This is a merely newbie question. I am trying to use lu-factorisation to
solve a basic 3*3 linear equation. When compiling the following code I
have this error :
/usr/include/boost/numeric/ublas/lu.hpp: In function âtypename
M::size_type boost::numeric::ublas::lu_factorize(M&, PM&) [with M =
boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>, PM = boost::numeric::ublas::permutation_matrix<double,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>]â:
essai_ublas.cpp:47: instantiated from here
/usr/include/boost/numeric/ublas/lu.hpp:137: erreur: no matching
function for call to
âproject(boost::numeric::ublas::matrix_column<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >&, boost::numeric::ublas::basic_range<size_t, ptrdiff_t>)â
essai_ublas.cpp:47: instantiated from here
/usr/include/boost/numeric/ublas/lu.hpp:146: erreur: no matching
function for call to
âproject(boost::numeric::ublas::matrix_column<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >&, boost::numeric::ublas::basic_range<size_t, ptrdiff_t>)â
essai_ublas.cpp:47: instantiated from here
/usr/include/boost/numeric/ublas/lu.hpp:150: erreur: no matching
function for call to
âproject(boost::numeric::ublas::matrix_column<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >&, boost::numeric::ublas::basic_range<size_t, ptrdiff_t>)â
/usr/include/boost/numeric/ublas/lu.hpp:150: erreur: no matching
function for call to
âproject(boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >&, boost::numeric::ublas::basic_range<size_t, ptrdiff_t>)â
essai_ublas.cpp:47: instantiated from here
/usr/include/boost/numeric/ublas/lu.hpp:156: erreur: invalid use of
undefined type âstruct
boost::numeric::ublas::triangular_adaptor<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, boost::numeric::ublas::basic_unit_lower<size_t> >â
/usr/include/boost/numeric/ublas/fwd.hpp:186: erreur: declaration of
âstruct
boost::numeric::ublas::triangular_adaptor<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, boost::numeric::ublas::basic_unit_lower<size_t> >â
/usr/include/boost/numeric/ublas/lu.hpp:156: erreur: invalid use of
undefined type âstruct
boost::numeric::ublas::triangular_adaptor<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, boost::numeric::ublas::basic_upper<size_t> >â
/usr/include/boost/numeric/ublas/fwd.hpp:186: erreur: declaration of
âstruct
boost::numeric::ublas::triangular_adaptor<boost::numeric::ublas::matrix<double, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, boost::numeric::ublas::basic_upper<size_t> >â
cc1plus: warnings being treated as errors
/usr/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<double,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>, MV = boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>]â:
/usr/include/boost/numeric/ublas/lu.hpp:82: instantiated from âvoid
boost::numeric::ublas::swap_rows(const PM&, MV&) [with PM =
boost::numeric::ublas::permutation_matrix<double,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>, MV = boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>]â
/usr/include/boost/numeric/ublas/lu.hpp:155: instantiated from
âtypename M::size_type boost::numeric::ublas::lu_factorize(M&, PM&)
[with M = boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>, PM = boost::numeric::ublas::permutation_matrix<double,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>]â
essai_ublas.cpp:47: instantiated from here
/usr/include/boost/numeric/ublas/lu.hpp:75: attention : passing âconst
doubleâ for argument 2 to âboost::numeric::ublas::matrix_row<M>
boost::numeric::ublas::row(M&, typename M::size_type) [with M =
boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>]â
Could someone explain why ?
I am using boost 1.3.x with ubuntu and gcc 4.0.
There is the code in question :
#include <iostream>
#include <cstdlib>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/io.hpp>
// a =
// 1 3 5
// 0 4 6
// 0 0 7
// b =
// 0
// 1
// 2
// ans =
// -0.89286
// -0.17857
// 0.28571
int main(void){
using namespace boost::numeric::ublas;
permutation_matrix<double> P(3);
matrix<double> A(3,3);
vector<double> x(3);
vector<double> rhs(3);
unsigned int i,j;
for(i=0;i<3;i++){
for(j=i;j<3;j++){
A(i,j)=i+1+2*j;
}
rhs(i)=i;
}
lu_factorize(A,P);
// lu_substitute(A,P,rhs);
std::cout << A << std::endl;
return EXIT_SUCCESS;
}