[Boost-bugs] [Boost C++ Libraries] #3293: Addition of a matrix with resized identity matrix

Subject: [Boost-bugs] [Boost C++ Libraries] #3293: Addition of a matrix with resized identity matrix
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-07-28 08:01:20


#3293: Addition of a matrix with resized identity matrix
------------------------------------------+---------------------------------
 Reporter: eva.ketelaer@… | Owner: guwi17
     Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: uBLAS
  Version: Boost 1.37.0 | Severity: Problem
 Keywords: resize matrix addition |
------------------------------------------+---------------------------------
 Hello,

 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.

 I used the following code:

 #include <boost/numeric/ublas/io.hpp>
 #include <boost/numeric/ublas/matrix.hpp>

 namespace ublas = boost::numeric::ublas;

 int main(int argc, char *argv[])
 {

         int m=6;
         ublas::matrix<double> H(m, m);
         ublas::identity_matrix<double> I(m), J(m-1);

         for(int i=0; i<m; ++i)
                 for(int j=0; j<m; ++j)
                         H(i,j)=i+j;

         H += I;

         H.resize(m-1,m-1,true);
         I.resize(m-1,true);

         for(int i=0; i<m-1; ++i)
                 for(int j=0; j<m-1; ++j)
                         H(i,j)=i+j;

         H += I;

         return 0;
 }
 I get the error:
 Check failed in file /usr/include/boost/numeric/ublas/matrix.hpp at line
 2545:
 it_ < (*this) ().size1 ()
 terminate called after throwing an instance of
 'boost::numeric::ublas::bad_index'
   what(): bad index

 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3293>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC