Boost logo

Ublas :

Subject: [ublas] vector/matrix_assign do not work for integral types (bug?)
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-08-16 03:54:38


Dear all,

I found a possible problem in vector_assign / matrix_assign when
values have integral type.
For instance, try to run the following program:

--- [sample] ---
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <cstddef>
#include <iostream>

namespace ublas = boost::numeric::ublas;

int main()
{
    typedef int value_type;

    std::size_t n(5);

    ublas::vector<value_type> v1;
    ublas::zero_vector<value_type> v2(n);

    v1 = v2;

    std::cerr << "NEW V1: " << v1 << std::endl;
}
--- [/sample] ---

You will end up with a failed assertion:
--- [error] ---
Check failed in file
/home/marco/tmp/boost-trunk/boost/numeric/ublas/detail/vector_assign.hpp
at line 370:
detail::expression_type_check (v, cv)
terminate called after throwing an instance of
'boost::numeric::ublas::external_logic'
  what(): external logic or bad condition of inputs
Aborted (core dumped)
--- [/error] ---

I have identified two possible issues:
1) In detail/vector_assign.hpp and detail/matrix_assign.hpp, the check
in function detail::equals should replace "<" with "<=".

2) In detail/config.hpp, macro BOOST_UBLAS_TYPE_CHECK_MIN should get
zero for integral types.

Unless someone has a different opinion, I will try to create a patch
and open a new trac ticket.

Thank you very much!

Best,

-- Marco