Boost logo

Boost Users :

Subject: [Boost-users] multi_array of triangular_matrices runtime error
From: Max S. Kaznady (max.kaznady_at_[hidden])
Date: 2010-08-12 13:16:03


Hello, I just noticed a strange runtime error, and I think that it
should be addressed by the developers. Consider the following
seemingly equivalent statements, in terms of functionality:
using namespace boost::numeric::ublas;
using namespace boost::multi_array;
const unsigned A_dim = 4;
multi_array<triangular_matrix<double, lower> , A_dim>::extent_gen extents;
1)
multi_array<triangular_matrix<double, lower> , A_dim> A(extents[2][2][2][2]);
2)
multi_array<triangular_matrix<double, lower> , A_dim> A;
A = multi_array<triangular_matrix<double, lower> , A_dim>(extents[2][2][2][2]);

Add either statement 1 or 2. Both compile just fine with GCC 4.4, but
the second statement, last line, produces a runtime error:

main: /usr/local/boost/include/boost/multi_array/multi_array_ref.hpp:487:
boost::multi_array_ref<T, NumDims>& boost::multi_array_ref<T,
NumDims>::operator=(const ConstMultiArray&) [with ConstMultiArray =
boost::multi_array<boost::numeric::ublas::triangular_matrix<double,
boost::numeric::ublas::basic_lower<long unsigned int>,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >, 4ul, std::allocator<boost::numeric::ublas::triangular_matrix<double,
boost::numeric::ublas::basic_lower<long unsigned int>,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> > > >, T = boost::numeric::ublas::triangular_matrix<double,
boost::numeric::ublas::basic_lower<long unsigned int>,
boost::numeric::ublas::basic_row_major<long unsigned int, long int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >, long unsigned int NumDims = 4ul]: Assertion
`std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape())' failed.

I KNOW that I can resolve the issue with shared_ptr, having
multi_array store shared pointers to the matrix A. However, if I
understand correctly, then shouldn't the second statement either not
compile or compile and work fine? From what I understand the added
functionality of multi_arrays is that they can store other arrays,
maybe I'm wrong?

Thanks,
Max


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net