Opened 14 years ago

Closed 12 years ago

#120 closed bug (fixed)

No warning when matrix size is inconsistent

Reported by: bulygin Owned by: hannes
Priority: minor Milestone: 3-1-1
Component: dontKnow Version:
Keywords: matrix Cc: greuel


I noticed that no warning (or error) message is output when one creates a matrix which size is not compatible with a defining list on the right hand size. The following code show the problem:

> ring r=0,x,dp;
> // suppose I made a misprint and "2" should be "3" below
> matrix m[2][3]=1,0,0,0,1,0,0,0,1; // RHS is a 3x3 matrix
> print(m); // m is 2x3 matrix
> // the same with "4"
> matrix m2[4][3]=1,0,0,0,1,0,0,0,1;
> print(m); // m is 4x3 matrix

So if the number of elemets N in a matrix that is being defined is less than the list size L on the right, then simply first N entries of the list are taken. Next, if N>L, then the list is (with no notice) appended with zeroes.

This is may be a good thing to do by default, but I guess at least a warning message should be displayed, saying that defined dimensions and the defining list size do not match. Otherwise, if the code is involved enough, the user may work with incorrect matrices -- the effect not so easily found sometimes.

Change History (1)

comment:1 Changed 12 years ago by hannes

Resolution: fixed
Status: newclosed

fix with revision 14055: a warning will be displayed if option(warn) is active.

Note: See TracTickets for help on using tickets.