Mercurial > hg > octave-nkf
changeset 5045:f09fd9e154e8
[project @ 2004-10-12 12:08:54 by jwe]
author | jwe |
---|---|
date | Tue, 12 Oct 2004 12:10:02 +0000 |
parents | 50140aa23b32 |
children | ea74d76ff607 |
files | src/ChangeLog src/pt-mat.cc |
diffstat | 2 files changed, 52 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2004-10-12 David Bateman <dbateman@free.fr> + + * 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 <jwe@octave.org> * 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 <dbateman@free.fr> +2004-09-17 David Bateman <dbateman@free.fr> * 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 <dbateman@free.fr> +2004-03-03 David Bateman <dbateman@free.fr> * 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 <dbateman@free.fr> +2004-02-16 David Bateman <dbateman@free.fr> * 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 <dbateman@free.fr> +2003-09-09 David Bateman <dbateman@free.fr> * 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 <dbateman@free.fr> +2003-02-18 David Bateman <dbateman@free.fr> * DLD-FUNCTIONS/lu.cc (Flu): Allow non-square matrices.
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -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; }