Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2005-06-24 06:30:34


On Friday 24 June 2005 00:13, Vardan Akopian wrote:
>>> Interestingly, when NDEBUG is off, ublas's internal runtime check
>>> catches the problem with an assertion failure:
>>> Assertion failed in file
>>> ../../../../boost_1_32_0/boost/numeric/ublas/matrix_assign.hpp at line
>>> 797:
>>> equals (m, cm)
>>> terminate called after throwing an instance of
>>> 'boost::numeric::ublas::external_logic'
>>> what(): external logic
>>> Aborted
>>
>> That means, that ublas internal checks work perfectly and inform the user
>> about a broken algorithm.

I tracked the bug down until matrix_expression.hpp:2121-2131 where
matrix_binary::const_iterator1::operator += ( n )
is defined as
            const_iterator1 &operator += (difference_type n) {
                i_ += n, it1_ += n, it2_ += n;
                return *this;
            }
which may move the iterator (far) behind the end if n is too large. I suggest
changing this to n times calling operator ++ () which already checks the
bounds (depending on the iterator type.) Or it may move the iterator if the
index is already larger than i_.

mfg
GUnter