Boost logo

Ublas :

From: Vassilis Virvilis (vasvir_at_[hidden])
Date: 2006-06-28 13:31:16


Consider the simple c++ program

---------------
#include <iostream>

#include <boost/numeric/ublas/vector_sparse.hpp>

using namespace boost::numeric;
typedef double Real;

//typedef ublas::mapped_vector<Real> SparseVector;
//typedef ublas::coordinate_vector<Real> SparseVector;
typedef ublas::compressed_vector<Real> SparseVector;

int main(int, char **)
{
     SparseVector a(3);
     a[0] = 1;
     a[1] = 2;
     a[2] = -3;

     SparseVector b;
     const Real ts = -1;

     //neither of the two forms pass the compilation -- requires NDEBUG
     b = ts * a;
     //b.assign(ts * a);

     std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
     std::cout << b[0] << " " << b[1] << " " << b[2] << std::endl;

     return 0;
}
--------------

The assignment b = ts * a doesn't compile due to

distcc g++-4.1 -o sparse_multiplication_int.o -c -g3 -g -Wall -W -Wconversion -Wwrite-strings -Wpointer-arith -Wsign-promo -Wsign-compare -DDEBUG=1 -DSIGFPE=1 -I. -I/home/bill/src sparse_multiplication_int.cpp
/usr/include/boost/numeric/ublas/detail/vector_assign.hpp: In function 'void boost::numeric::ublas::vector_assign(V&, const boost::numeric::ublas::vector_expression<E>&, boost::numeric::ublas::sparse_tag) [with F = boost::numeric::ublas::scalar_assign, V = boost::numeric::ublas::mapped_vector<double, boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > > >, E = boost::numeric::ublas::vector_binary_scalar1<const double, boost::numeric::ublas::mapped_vector<double, boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > > >, boost::numeric::ublas::scalar_multiplies<double, double> >]':
/usr/include/boost/numeric/ublas/detail/vector_assign.hpp:448: instantiated from 'void boost::numeric::ublas::vector_assign(V&, const boost::numeric::ublas::vector_expression<E>&) [with F = boost::numeric::ublas::scalar_assign, V = boost::numeric::ublas::mapped_vector<double, boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > > >, E = boost::numeric::ublas::vector_binary_scalar1<const double, boost::numeric::ublas::mapped_vector<double, boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > > >, boost::numeric::ublas::scalar_multiplies<double, double> >]'
/usr/include/boost/numeric/ublas/vector_sparse.hpp:312: instantiated from 'boost::numeric::ublas::mapped_vector<T, A>::mapped_vector(const boost::numeric::ublas::vector_expression<E>&, typename A::size_type) [with AE = boost::numeric::ublas::vector_binary_scalar1<const double, boost::numeric::ublas::mapped_vector<double, boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > > >, boost::numeric::ublas::scalar_multiplies<double, double> >, T = double, A = boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > >]'
/usr/include/boost/numeric/ublas/vector_sparse.hpp:462: instantiated from 'boost::numeric::ublas::mapped_vector<T, A>& boost::numeric::ublas::mapped_vector<T, A>::operator=(const boost::numeric::ublas::vector_expression<E>&) [with AE = boost::numeric::ublas::vector_binary_scalar1<const double, boost::numeric::ublas::mapped_vector<double, boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > > >, boost::numeric::ublas::scalar_multiplies<double, double> >, T = double, A = boost::numeric::ublas::map_std<unsigned int, double, std::allocator<std::pair<const unsigned int, double> > >]'
sparse_multiplication_int.cpp:24: instantiated from here
/usr/include/boost/numeric/ublas/detail/vector_assign.hpp:356: error: 'cv' has incomplete type

but with NDEBUG it compiles and works.

Is this known?

        .bill

PS: I am not subscribed in the list. Please keep me in the TO or the CC headers.