# HG changeset patch # User jwe # Date 1098120891 0 # Node ID 36f954d8d53af07a1f289302c5b0529d6dcb7d52 # Parent ea74d76ff607e49e702fd5d78c97babc16b9a063 [project @ 2004-10-18 17:34:51 by jwe] diff --git a/liboctave/Array.cc b/liboctave/Array.cc --- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -112,6 +112,10 @@ } } + // XXX FIXME XXX -- it would be better if we did not have to do + // this, so we could share the data while still having different + // dimension vectors. + retval.make_unique (); retval.dimensions = new_dimensions; @@ -2540,16 +2544,22 @@ int lhs_nr = lhs.rows (); int lhs_nc = lhs.cols (); - int rhs_nr = rhs.rows (); - int rhs_nc = rhs.cols (); - - if (rhs.length () > 2) + Array xrhs = rhs; + + int rhs_nr = xrhs.rows (); + int rhs_nc = xrhs.cols (); + + if (xrhs.ndims () > 2) { - dim_vector dv_tmp = rhs.squeeze().dims (); + xrhs = xrhs.squeeze (); + + dim_vector dv_tmp = xrhs.dims (); switch (dv_tmp.length ()) { case 1: + // XXX FIXME XXX -- this case should be unnecessary, because + // squeeze should always return an object with 2 dimensions. if (rhs_nr == 1) rhs_nc = dv_tmp.elem (0); break; @@ -2609,7 +2619,7 @@ { MAYBE_RESIZE_LHS; - RT scalar = rhs.elem (0, 0); + RT scalar = xrhs.elem (0, 0); for (int j = 0; j < m; j++) { @@ -2634,7 +2644,7 @@ for (int i = 0; i < n; i++) { int ii = idx_i.elem (i); - lhs.elem (ii, jj) = rhs.elem (i, j); + lhs.elem (ii, jj) = xrhs.elem (i, j); } } } @@ -2704,7 +2714,7 @@ } } - if (assign1 ((Array&) lhs, (Array&) rhs, rfv)) + if (assign1 (lhs, xrhs, rfv)) { int len = lhs.length (); @@ -2735,7 +2745,7 @@ lhs.maybe_delete_elements (idx_i); else { - if (assign1 ((Array&) lhs, (Array&) rhs, rfv)) + if (assign1 (lhs, xrhs, rfv)) lhs.dimensions = dim_vector (1, lhs.length ()); else retval = 0; @@ -2753,7 +2763,7 @@ lhs.maybe_delete_elements (idx_i); else { - if (assign1 ((Array&) lhs, (Array&) rhs, rfv)) + if (assign1 (lhs, xrhs, rfv)) lhs.dimensions = dim_vector (lhs.length (), 1); else retval = 0; @@ -2794,7 +2804,7 @@ int ii = idx_i.elem (k++); int fr = ii % lhs_nr; int fc = (ii - fr) / lhs_nr; - lhs.elem (fr, fc) = rhs.elem (i, j); + lhs.elem (fr, fc) = xrhs.elem (i, j); } } } diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2004-10-18 John W. Eaton + + * Array.cc (assign2): Save result of squeeze operation. + Squeeze if ndims is > 2, not if length of RHS vector is > 2. + 2004-10-11 David Bateman * oct-fftw.cc (class octave_fftw_planner): Add inplace[2] to