Boost C++ Libraries: Ticket #3293: Addition of a matrix with resized identity matrix https://svn.boost.org/trac10/ticket/3293 <p> Hello, </p> <p> I have an identity matrix of size m. I add it to another matrix. It works. Then a I resize both matrixes to size m-1 x m-1 and I cannot add the matrices. </p> <p> I used the following code: </p> <p> #include &lt;boost/numeric/ublas/io.hpp&gt; #include &lt;boost/numeric/ublas/matrix.hpp&gt; </p> <p> namespace ublas = boost::numeric::ublas; </p> <p> int main(int argc, char *argv[]) { </p> <blockquote> <p> int m=6; ublas::matrix&lt;double&gt; H(m, m); ublas::identity_matrix&lt;double&gt; I(m), J(m-1); </p> </blockquote> <p> </p> <blockquote> <p> for(int i=0; i&lt;m; ++i) </p> <blockquote> <p> for(int j=0; j&lt;m; ++j) </p> <blockquote> <p> H(i,j)=i+j; </p> </blockquote> </blockquote> </blockquote> <p> </p> <blockquote> <p> H += I; </p> </blockquote> <p> </p> <blockquote> <p> H.resize(m-1,m-1,true); I.resize(m-1,true); </p> </blockquote> <p> </p> <blockquote> <p> for(int i=0; i&lt;m-1; ++i) </p> <blockquote> <p> for(int j=0; j&lt;m-1; ++j) </p> <blockquote> <p> H(i,j)=i+j; </p> </blockquote> </blockquote> </blockquote> <p> </p> <blockquote> <p> H += I; </p> </blockquote> <p> </p> <blockquote> <p> return 0; </p> </blockquote> <p> } I get the error: Check failed in file /usr/include/boost/numeric/ublas/matrix.hpp at line 2545: it_ &lt; (*this) ().size1 () terminate called after throwing an instance of 'boost::numeric::ublas::bad_index' </p> <blockquote> <p> what(): bad index </p> </blockquote> <p> I checked the sizes of the matrices and everything seems to be correct. I use the boost version 1.37.0 in ubuntu 9.04. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3293 Trac 1.4.3 nasos_i Thu, 10 Sep 2009 17:17:18 GMT <link>https://svn.boost.org/trac10/ticket/3293#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3293#comment:1</guid> <description> <p> A fast debugging suggests that the problem is with matrix resize, where size_common_ is not updated along with size1_ and size2_ </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gunter</dc:creator> <pubDate>Sat, 12 Sep 2009 22:02:32 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/3293#comment:2 https://svn.boost.org/trac10/ticket/3293#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.40.0</span> → <span class="trac-field-new">Boost 1.41.0</span> </li> </ul> Ticket Gunter Sat, 12 Sep 2009 23:07:48 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3293#comment:3 https://svn.boost.org/trac10/ticket/3293#comment:3 <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-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/56163" title="matrix.hpp, identity_matrix: fix #3293: added assignments to ...">[56163]</a>) matrix.hpp, identity_matrix: </p> <p> fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3293" title="#3293: Bugs: Addition of a matrix with resized identity matrix (closed: fixed)">#3293</a>: added assignments to size_common_ on each place where size1 or size2 are changed </p> Ticket Gunter Sat, 12 Sep 2009 23:10:40 GMT <link>https://svn.boost.org/trac10/ticket/3293#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3293#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/56164" title="doc/index.htm: added link to new release notes page ...">[56164]</a>) doc/index.htm: </p> <p> added link to new release notes page </p> <p> doc/release_notes.htm: </p> <p> created release notes page to track changes, see <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3293" title="#3293: Bugs: Addition of a matrix with resized identity matrix (closed: fixed)">#3293</a> and <a class="new ticket" href="https://svn.boost.org/trac10/ticket/3443" title="#3443: Tasks: improve documentation (new)">#3443</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gunter</dc:creator> <pubDate>Tue, 06 Oct 2009 23:47:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3293#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3293#comment:5</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/56626" title="close #3293 (resized identity matrix) * merged [56163] into release ">[56626]</a>) close <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3293" title="#3293: Bugs: Addition of a matrix with resized identity matrix (closed: fixed)">#3293</a> (resized identity matrix) </p> <ul><li>merged <a class="changeset" href="https://svn.boost.org/trac10/changeset/56163" title="matrix.hpp, identity_matrix: fix #3293: added assignments to ...">[56163]</a> into release </li></ul> </description> <category>Ticket</category> </item> </channel> </rss>