Modify

Ticket #3293 (closed Bugs: fixed)

Opened 5 years ago

Last modified 5 years ago

Addition of a matrix with resized identity matrix

Reported by: eva.ketelaer@… Owned by: guwi17
Milestone: Boost 1.41.0 Component: uBLAS
Version: Boost 1.37.0 Severity: Problem
Keywords: resize matrix addition Cc:

Description

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.

Attachments

Change History

comment:1 Changed 5 years ago by nasos_i

A fast debugging suggests that the problem is with matrix resize, where size_common_ is not updated along with size1_ and size2_

comment:2 Changed 5 years ago by guwi17

  • Milestone changed from Boost 1.40.0 to Boost 1.41.0

comment:3 Changed 5 years ago by guwi17

  • Status changed from new to closed
  • Resolution set to fixed

(In [56163]) matrix.hpp, identity_matrix:

fix #3293: added assignments to size_common_ on each place where size1 or size2 are changed

comment:4 Changed 5 years ago by guwi17

(In [56164]) doc/index.htm:

added link to new release notes page

doc/release_notes.htm:

created release notes page to track changes, see #3293 and #3443

comment:5 Changed 5 years ago by guwi17

(In [56626]) close #3293 (resized identity matrix)

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.