# HG changeset patch # User jwe # Date 1074787311 0 # Node ID 8d4bb887f381c965a918ee9d1717290efcad3cd3 # Parent 2c73119a576a98d92084f198787d87e760f38d93 [project @ 2004-01-22 16:01:51 by jwe] diff -r 2c73119a576a -r 8d4bb887f381 liboctave/Array.cc --- a/liboctave/Array.cc Thu Jan 22 04:36:54 2004 +0000 +++ b/liboctave/Array.cc Thu Jan 22 16:01:51 2004 +0000 @@ -843,9 +843,11 @@ int old_len = length (); int len = get_size (dv); - + rep = new typename Array::ArrayRep (len); + dim_vector dv_old = dimensions; + dimensions = dv; Array ra_idx (dimensions.length (), 0); @@ -861,10 +863,10 @@ for (int i = 0; i < old_len; i++) { - if (index_in_bounds (ra_idx, dimensions)) - xelem (ra_idx) = old_data[i]; - - increment_index (ra_idx, dimensions); + if (index_in_bounds (ra_idx, dv_old)) + xelem (ra_idx) = old_data[get_scalar_idx (ra_idx, dv_old)]; + + increment_index (ra_idx, dv_old); } if (--old_rep->count <= 0) @@ -2232,6 +2234,29 @@ int rhs_nr = rhs.rows (); int rhs_nc = rhs.cols (); + + if (rhs.length () > 2) + { + dim_vector dv_tmp = rhs.squeeze().dims (); + + if (dv_tmp.length () > 2) + { + (*current_liboctave_error_handler) + ("Dimension mismatch"); + + return 0; + } + + if (dv_tmp.length () == 1) + if (rhs_nr == 1) + rhs_nc = dv_tmp.elem (0); + + else if (dv_tmp.length () == 2) + { + rhs_nr = dv_tmp.elem (0); + rhs_nc = dv_tmp.elem (1); + } + } idx_vector *tmp = lhs.get_idx (); diff -r 2c73119a576a -r 8d4bb887f381 liboctave/ChangeLog --- a/liboctave/ChangeLog Thu Jan 22 04:36:54 2004 +0000 +++ b/liboctave/ChangeLog Thu Jan 22 16:01:51 2004 +0000 @@ -1,3 +1,8 @@ +2004-01-22 Petter Risholm + + * Array.cc (Array::assign2): Check for RHS dimensions larger + than 2. + 2004-01-21 Petter Risholm * Array.h (Array::chop_trailing_singletons): New function.