Boost logo

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;

}