Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-09-07 08:04:40

On Sunday 23 July 2006 11:13, Matthias Troyer wrote:
> There is a serious bug in the mapped_vector_of_mapped_vector spare
> matrix type. Rows containing only zero elements are not treated
> correctly in prod(). The following code should give a vector that
> contains only 1 in the last element. Instead prod() gives a vector
> containing 1 in each element. In debug mode this bug is found by the

I could reproduce the bug. It is inside the vector_assign logic. The product
is correctly computed, but the assignment fails. I will give more details

#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>

typedef boost::numeric::ublas::mapped_vector_of_mapped_vector<double>
typedef boost::numeric::ublas::vector<double> DENSE_VECTOR;

int main(int argc, char * argv[])


  std::fill(x.begin(), x.end(), 1.0);

  std::cout << "matrix A " << A << "\n";
  std::cout << "vector x " << x << "\n";

  std::cout << "prod(A,x) " << prod(A,x) << "\n";

  y = prod(A,x); // <- this raises the exception
  std::cout << "prod(A,x) " << y << "\n";

  return EXIT_SUCCESS;