Boost logo

Boost Users :

Subject: Re: [Boost-users] multi_array of triangular_matrices runtime error
From: Max S. Kaznady (max.kaznady_at_[hidden])
Date: 2010-08-12 14:55:02


Actually, the second case can be fixed with:
multi_array<triangular_matrix<double, lower> , A_dim> A;
A.resize(extents[2][2][2][2]);

But still, for the developer, the code for the second case should not
compile then.

Max

On Thu, Aug 12, 2010 at 1:16 PM, Max S. Kaznady <max.kaznady_at_[hidden]> wrote:
> 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