Mercurial > hg > octave-lyh
changeset 854:fb983bf4fd07
[project @ 1994-10-21 19:02:15 by jwe]
author | jwe |
---|---|
date | Fri, 21 Oct 1994 19:02:15 +0000 |
parents | c346a0268e31 |
children | f4feb9b57f12 |
files | src/tc-rep-ass.cc src/tc-rep-idx.cc |
diffstat | 2 files changed, 41 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tc-rep-ass.cc +++ b/src/tc-rep-ass.cc @@ -849,15 +849,37 @@ if (nr == 1) { - for (int i = 0; i < iv.capacity (); i++) - REP_ELEM_ASSIGN (0, iv.elem (i), rhs_m.elem (0, i), - rhs_cm.elem (0, i), rhs.is_real_type ()); + if (rhs_nr == 1) + { + for (int i = 0; i < iv.capacity (); i++) + REP_ELEM_ASSIGN (0, iv.elem (i), rhs_m.elem (0, i), + rhs_cm.elem (0, i), rhs.is_real_type ()); + } + else if (rhs_nc == 1) + { + for (int i = 0; i < iv.capacity (); i++) + REP_ELEM_ASSIGN (0, iv.elem (i), rhs_m.elem (i, 0), + rhs_cm.elem (i, 0), rhs.is_real_type ()); + } + else + panic_impossible (); } else if (nc == 1) { - for (int i = 0; i < iv.capacity (); i++) - REP_ELEM_ASSIGN (iv.elem (i), 0, rhs_m.elem (i, 0), - rhs_cm.elem (i, 0), rhs.is_real_type ()); + if (rhs_nr == 1) + { + for (int i = 0; i < iv.capacity (); i++) + REP_ELEM_ASSIGN (iv.elem (i), 0, rhs_m.elem (0, i), + rhs_cm.elem (0, i), rhs.is_real_type ()); + } + else if (rhs_nc == 1) + { + for (int i = 0; i < iv.capacity (); i++) + REP_ELEM_ASSIGN (iv.elem (i), 0, rhs_m.elem (i, 0), + rhs_cm.elem (i, 0), rhs.is_real_type ()); + } + else + panic_impossible (); } else panic_impossible ();
--- a/src/tc-rep-idx.cc +++ b/src/tc-rep-idx.cc @@ -66,11 +66,13 @@ switch (args.length ()) { case 2: - if (args(1).rows () != 0 && args(1).columns () != 0) + if (! args(1).is_magic_colon () + && args(1).rows () != 0 && args(1).columns () != 0) goto index_error; case 1: - if (args(0).rows () != 0 && args(0).columns () != 0) + if (! args(0).is_magic_colon () + && args(0).rows () != 0 && args(0).columns () != 0) goto index_error; return Matrix (); @@ -148,7 +150,7 @@ { Matrix mj = arg.matrix_value (); - idx_vector j (mj, user_pref.do_fortran_indexing, ""); + idx_vector j (mj, user_pref.do_fortran_indexing, "", 1); if (! j) return retval; @@ -176,7 +178,7 @@ { Matrix mi = arg.matrix_value (); - idx_vector i (mi, user_pref.do_fortran_indexing, ""); + idx_vector i (mi, user_pref.do_fortran_indexing, "", 1); if (! i) return retval; @@ -491,12 +493,6 @@ if (! iv) return retval; - if (iv.max () >= nr * nc || iv.min () < 0) - { - error ("matrix index out of range"); - return retval; - } - int result_size = iv.length (); if (nc == 1 || (nr != 1 && iv.one_zero_only ())) @@ -943,7 +939,13 @@ break; case magic_colon: - retval = do_matrix_index (ri, magic_colon); + { + if (index_check (ri, "row") < 0) + return tree_constant (); + if (range_max_check (tree_to_mat_idx (ri.max ()), 0, nr, nc) < 0) + return tree_constant (); + retval = do_matrix_index (ri, magic_colon); + } break; default: