Opened 12 years ago

Last modified 4 years ago

#4549 new Bugs

vector/matrix_assign do not work for integral types

Reported by: Marco Guazzone <marco.guazzone@…> Owned by: Gunter
Milestone: To Be Determined Component: uBLAS
Version: Boost Development Trunk Severity: Problem
Keywords: Cc: jonathan.jones@…

Description

I have found a possible problem in vector_assign and matrix_assign functions when vector and matrix values have integral type.

For instance, when you try to assign two integral vectors (e.g., ublas::vector<int>), you'll end up with the following runtime assertion:

Check failed in file
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)

Similar exception will be thrown for integral matrices.

I have identified two possible issues:

  1. In detail/vector_assign.hpp and detail/matrix_assign.hpp, the check in function detail::equals should use <= instead of <.
  1. In detail/config.hpp, macro BOOST_UBLAS_TYPE_CHECK_MIN should get zero for integral types.

Attachments (3)

vector_matrix_assign-allow_integral_types.patch (2.3 KB ) - added by Marco Guazzone <marco.guazzone@…> 12 years ago.
Possible solution.
test_ticket4549.cpp (2.4 KB ) - added by Marco Guazzone <marco.guazzone@…> 12 years ago.
Test case: test copy-construction/-assignement of an integral vector and an integral matrix. The test fails to run if the proposed patch is not applied.
vector_matrix_assign-allow_integral_types-20120827.patch (2.3 KB ) - added by marco.guazzone@… 10 years ago.
Patch file changed to fit actual (Boost 1.51) changes.

Download all attachments as: .zip

Change History (6)

by Marco Guazzone <marco.guazzone@…>, 12 years ago

Possible solution.

by Marco Guazzone <marco.guazzone@…>, 12 years ago

Attachment: test_ticket4549.cpp added

Test case: test copy-construction/-assignement of an integral vector and an integral matrix. The test fails to run if the proposed patch is not applied.

comment:1 by Jonathan Jones <jonathan.jones@…>, 10 years ago

Cc: jonathan.jones@… added

comment:2 by marco.guazzone@…, 10 years ago

It seems that this patch has been never added to the repo. I cannot see it in current svn trunk.

Since I've realized that one of the involved files is changed (i.e., boost/numeric/ublas/detail/config.hpp), I add a new patch to fit actual changes.

The test file that I've already attached is still OK.

by marco.guazzone@…, 10 years ago

Patch file changed to fit actual (Boost 1.51) changes.

comment:3 by sudhanshu.gupta05@…, 4 years ago

When I ran the attached test case , it works for integral vector but not integral matrix for Boost 1.65.1 . Please let me know if we have fix for integral matrix ?

Thanks

Note: See TracTickets for help on using tickets.