# HG changeset patch # User jwe # Date 1097583002 0 # Node ID f09fd9e154e86003cb2a96394feedc3eab18ade4 # Parent 50140aa23b32f1e4a338f785725cdf746ed8fe09 [project @ 2004-10-12 12:08:54 by jwe] diff -r 50140aa23b32 -r f09fd9e154e8 src/ChangeLog --- a/src/ChangeLog Mon Oct 11 16:31:52 2004 +0000 +++ b/src/ChangeLog Tue Oct 12 12:10:02 2004 +0000 @@ -1,3 +1,9 @@ +2004-10-12 David Bateman + + * pt-mat.cc (tm_row_const::tm_row_const_rep::do_init_element, + tm_const::init): Dimensionality of matrices not necessarily the + same. Check before comparing. + 2004-10-06 John W. Eaton * pt-fcn-handle.h (tree_fcn_handle::name): New function. @@ -135,7 +141,7 @@ Call delete on each symbol record in the table instead of just clearing them. -2004-09-17 David Bateman +2004-09-17 David Bateman * DLD-FUNCTIONS/sort.cc (ascending_compare, descending_compare): Now templates (avoids g++ 3.4.x compile problems). @@ -1312,7 +1318,7 @@ * ov-str-mat.cc (octave_char_matrix_str::load_hdf5, octave_char_matrix_str::save_hdf5): Likewise. -2004-03-03 David Bateman +2004-03-03 David Bateman * ov-cell.cc (octave_cell::save_hdf5, octave_cell::load_hdf5): Make N-d aware. @@ -1502,7 +1508,7 @@ (set_default_fftw_wisdom_prog): Rename from set_default_wisdom_prog. * defaults.h.in (Vfftw_wisdom_prog): Provide extern decl. -2004-02-16 David Bateman +2004-02-16 David Bateman * DLD-FUNCTIONS/fft.cc: Adapt for Nd arrays, combine with ifft.cc. * DLD-FUNCTIONS/ifft.cc: Delete. @@ -2918,7 +2924,7 @@ New files. * Makefile.in (OP_XSRC): Add them to the list. -2003-09-09 David Bateman +2003-09-09 David Bateman * OPERATORS/op-cs-s.cc (DEFBINOP): First arg is complex, second is double. @@ -3619,7 +3625,7 @@ * DLD-FUNCTIONS/sqrtm.cc: New file. -2003-02-18 David Bateman +2003-02-18 David Bateman * DLD-FUNCTIONS/lu.cc (Flu): Allow non-square matrices. diff -r 50140aa23b32 -r f09fd9e154e8 src/pt-mat.cc --- a/src/pt-mat.cc Mon Oct 11 16:31:52 2004 +0000 +++ b/src/pt-mat.cc Tue Oct 12 12:10:02 2004 +0000 @@ -198,13 +198,16 @@ } else { + int len = (this_elt_dv.length () < dv.length () + ? this_elt_dv.length () : dv.length ()); + if (this_elt_nr != dv (0)) { eval_error ("number of rows must match", elt->line (), elt->column (), this_elt_nr, dv (0)); return false; } - for (int i = 2; i < this_elt_dv.length (); i++) + for (int i = 2; i < len; i++) { if (this_elt_dv (i) != dv (i)) { @@ -212,6 +215,22 @@ return false; } } + + if (this_elt_dv.length () > len) + for (int i = len; i < this_elt_dv.length (); i++) + if (this_elt_dv (i) != 1) + { + eval_error ("dimensions mismatch", elt->line (), elt->column (), this_elt_dv (i), 1); + return false; + } + + if (dv.length () > len) + for (int i = len; i < dv.length (); i++) + if (dv (i) != 1) + { + eval_error ("dimensions mismatch", elt->line (), elt->column (), 1, dv (i)); + return false; + } } dv.elem (1) = dv.elem (1) + this_elt_nc; @@ -423,8 +442,10 @@ else { bool get_out = false; + int len = (this_elt_dv.length () < dv.length () + ? this_elt_dv.length () : dv.length ()); - for (int i = 1; i < this_elt_dv.length (); i++) + for (int i = 1; i < len; i++) { if (i == 1 && this_elt_nc != dv (1)) { @@ -441,6 +462,24 @@ } } + if (this_elt_dv.length () > len) + for (int i = len; i < this_elt_dv.length (); i++) + if (this_elt_dv (i) != 1) + { + ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, this_elt_dv (i), 1); + get_out = true; + break; + } + + if (dv.length () > len) + for (int i = len; i < dv.length (); i++) + if (dv (i) != 1) + { + ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, 1, dv(i)); + get_out = true; + break; + } + if (get_out) break; }