Boost logo

Ublas :

From: Peter Melchior (pmelchior_at_[hidden])
Date: 2007-01-30 05:29:05


Hello everybody,

I'm trying to use vector expressions for atlas methods.
I did a fresh checkout of the sandbox and tried to compile the example
from the atlas bindings documentation:

#include <iostream>
  #include <complex>
  #include <boost/numeric/bindings/traits/std_vector.hpp>
  #include <boost/numeric/bindings/traits/std_valarray.hpp>
  #include <boost/numeric/bindings/traits/ublas_vector.hpp>
  #include <boost/numeric/bindings/traits/ublas_matrix.hpp>
  #include <boost/numeric/bindings/atlas/cblas1.hpp>

  namespace ublas = boost::numeric::ublas;
  namespace atlas = boost::numeric::bindings::atlas;

  int main() {
    std::vector<float> sv (8);
    // initialisation...
    std::cout << atlas::nrm2 (sv) << std::endl;

    std::valarray<std::complex<double> > va (10);
    // ...
    std::cout << atlas::nrm2 (va) << std::endl;

    ublas::vector<double> uv (18);
    // ...
    std::cout << atlas::nrm2 (uv) << std::endl;
    ublas::vector_range<ublas::vector<double> > ur (uv, ublas::range (3,
15));
    std::cout << atlas::nrm2 (ur) << std::endl;
    ublas::vector_slice<ublas::vector<double> > us (uv, ublas::slice (1,
3, 5));
    std::cout << atlas::nrm2 (us) << std::endl;
    ublas::vector_slice<ublas::vector_range<ublas::vector<double> > >
      usr (ur, ublas::slice (2, 2, 4));
    std::cout << atlas::nrm2 (usr) << std::endl;

    ublas::matrix<double> um (5, 5);
    // ...
    ublas::matrix_row<ublas::matrix<double> > umr (um, 1);
    std::cout << atlas::nrm2 (umr) << std::endl;
    ublas::matrix_column<ublas::matrix<double> > umc (um, 2);
    std::cout << atlas::nrm2 (umc) << std::endl;
  }

I get the following error message, which leaves me in a clueless state:

/usr/include/boost/numeric/ublas/vector_expression.hpp: In static member
   function `static typename
   boost::numeric::bindings::traits::default_vector_traits<VR, typename
   V::value_type>::pointer

boost::numeric::bindings::traits::vector_detail_traits<boost::numeric::ublas::vector_reference<T>,
   VR>::storage(VR&) [with V = boost::numeric::ublas::vector<double,
   boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >,
   VR = const

boost::numeric::ublas::vector_reference<boost::numeric::ublas::vector<double,
   boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> > >]
   ':
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/traits/ublas_vector.hpp:95: instantiated from `static typename boost::numeric::bindings::traits::default_vector_traits<VR, typename V::value_type>::pointer boost::numeric::bindings::traits::vector_detail_traits<boost::numeric::ublas::vector_range<E>, VR>::storage(VR&) [with V = boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, VR = const boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >]'
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/traits/vector_traits.hpp:74: instantiated from `typename boost::numeric::bindings::traits::vector_traits<V>::pointer boost::numeric::bindings::traits::vector_storage(V&) [with V = const boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >]'
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/atlas/cblas1.hpp:331: instantiated from `typename boost::numeric::bindings::traits::type_traits<typename boost::numeric::bindings::traits::vector_traits<V>::value_type>::real_type boost::numeric::bindings::atlas::nrm2(const Vct&) [with Vct = boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >]'
testMatrix.cc:54: instantiated from here
/usr/include/boost/numeric/ublas/vector_expression.hpp:329: error:
`const T&
   boost::numeric::ublas::vector_reference<E>::expression() const [with
T =
   boost::numeric::ublas::vector<double,
   boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >]'
   is private
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/traits/ublas_vector.hpp:69: error: within
   this context
/usr/include/boost/numeric/ublas/vector_expression.hpp: In static member
   function `static int

boost::numeric::bindings::traits::vector_detail_traits<boost::numeric::ublas::vector_reference<T>,
   VR>::stride(VR&) [with V = boost::numeric::ublas::vector<double,
   boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >,
   VR = const

boost::numeric::ublas::vector_reference<boost::numeric::ublas::vector<double,
   boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> > >]
   ':
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/traits/ublas_vector.hpp:96: instantiated from `static typename boost::numeric::bindings::traits::default_vector_traits<VR, typename V::value_type>::pointer boost::numeric::bindings::traits::vector_detail_traits<boost::numeric::ublas::vector_range<E>, VR>::storage(VR&) [with V = boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >, VR = const boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >]'
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/traits/vector_traits.hpp:74: instantiated from `typename boost::numeric::bindings::traits::vector_traits<V>::pointer boost::numeric::bindings::traits::vector_storage(V&) [with V = const boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >]'
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/atlas/cblas1.hpp:331: instantiated from `typename boost::numeric::bindings::traits::type_traits<typename boost::numeric::bindings::traits::vector_traits<V>::value_type>::real_type boost::numeric::bindings::atlas::nrm2(const Vct&) [with Vct = boost::numeric::ublas::vector_range<boost::numeric::ublas::vector<double, boost::numeric::ublas::unbounded_array<double, std::allocator<double> > > >]'
testMatrix.cc:54: instantiated from here
/usr/include/boost/numeric/ublas/vector_expression.hpp:329: error:
`const T&
   boost::numeric::ublas::vector_reference<E>::expression() const [with
T =
   boost::numeric::ublas::vector<double,
   boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >]'
   is private
../../boost-sandbox/boost-sandbox/boost/numeric/bindings/traits/ublas_vector.hpp:72: error: within
   this context

Line 54 in my example is

std::cout << atlas::nrm2 (ur) << std::endl;

Thus, the use of a vector expression for a atlas method does not work
here.

Any ideas what goes wrong here?

Thanks in advance,

Peter Melchior

-- 
Peter Melchior
Institut fuer Theoretische Astrophysik
Albert-Ueberle-Str. 3-5
69120 Heidelberg, Germany
Mail: pmelchior_at_[hidden]
Phone: +49 6221 544869