Boost C++ Libraries: Ticket #688: ublas: bug in mapped_vector_of_mapped_vector https://svn.boost.org/trac10/ticket/688 <pre class="wiki">There is a serious bug in the mapped_vector_of_mapped_vector spare matrix type. Rows containing only zero elements are not treated correctly in prod(). The following code should give a vector that contains only 1 in the last element. Instead prod() gives a vector containing 1 in each element. In debug mode this bug is found by the checks: Check failed in file boost/boost/numeric/ublas/detail/ vector_assign.hpp at line 371: detail::expression_type_check (v, cv) Aborted The bug appears in Boost 1.33 as well as in the CVS version #include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt; #include &lt;boost/numeric/ublas/vector.hpp&gt; int main() { boost::numeric::ublas::mapped_vector_of_mapped_vector&lt;double&gt; m (64,64); boost::numeric::ublas::vector&lt;double&gt; v(64); boost::numeric::ublas::vector&lt;double&gt; w(64); v[63] = 1.; m(63,63) = 1.; w = boost::numeric::ublas::prod(m,v); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/688 Trac 1.4.3 Gunter Mon, 24 Sep 2007 21:23:17 GMT owner, status changed; severity set https://svn.boost.org/trac10/ticket/688#comment:1 https://svn.boost.org/trac10/ticket/688#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">mistevens</span> to <span class="trac-author">Gunter</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> <p> the issue was already solved at 07.11.2006 but the patch was never commited. </p> Ticket Gunter Mon, 24 Sep 2007 21:29:47 GMT status, resolution changed https://svn.boost.org/trac10/ticket/688#comment:2 https://svn.boost.org/trac10/ticket/688#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">fixed</span> </li> </ul> <p> patch commited to SVN. See thread "Serious bug in mapped_vector_of_mapped_vector" of uBLAS mailing list (from sept. 2006!) </p> <p> On Thursday 07 September 2006 14:04, Gunter Winkler wrote: </p> <blockquote class="citation"> <p> On Sunday 23 July 2006 11:13, Matthias Troyer wrote: </p> <blockquote class="citation"> <p> There is a serious bug in the mapped_vector_of_mapped_vector spare matrix type. Rows containing only zero elements are not treated correctly in prod(). The following code should give a vector that contains only 1 in the last element. Instead prod() gives a vector containing 1 in each element. In debug mode this bug is found by the </p> </blockquote> <p> I could reproduce the bug. It is inside the vector_assign logic. The product is correctly computed, but the assignment fails. I will give more details shortly. </p> </blockquote> <p> I finally found the bug and (hopefully) fixed it. The patch and sample program is attached. Is someone using mapped_vector_of_mapped_vector in a larger program? I'd like to know if the changes have any unexpected side affect. </p> <p> I changed the behavior of the iterators: Even the outer iterators skip empty rows (or columns). </p> Ticket