# HG changeset patch # User dbateman # Date 1180996099 0 # Node ID 8e0444d9005002fe8e938abcc0b17a823c54984d # Parent b26a8e0e42cd979331d2b8a3405da1f24d378a59 [project @ 2007-06-04 22:28:19 by dbateman] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2007-06-04 David Bateman + + * Sparse.cc (Sparse Sparse::reshape): If length of new + dimensions is greater than 2, collapse to 2-D. + 2007-06-02 David Bateman * SparseCmplxQR.cc: Changes to support CXSparse 2.2.0. diff --git a/liboctave/Sparse.cc b/liboctave/Sparse.cc --- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -730,14 +730,22 @@ Sparse::reshape (const dim_vector& new_dims) const { Sparse retval; - - if (dimensions != new_dims) + dim_vector dims2 = new_dims; + + if (dims2.length () > 2) { - if (dimensions.numel () == new_dims.numel ()) + for (octave_idx_type i = 2; i < dims2.length(); i++) + dims2 (1) *= dims2(i); + dims2.resize (2); + } + + if (dimensions != dims2) + { + if (dimensions.numel () == dims2.numel ()) { octave_idx_type new_nnz = nnz (); - octave_idx_type new_nr = new_dims (0); - octave_idx_type new_nc = new_dims (1); + octave_idx_type new_nr = dims2 (0); + octave_idx_type new_nc = dims2 (1); octave_idx_type old_nr = rows (); octave_idx_type old_nc = cols (); retval = Sparse (new_nr, new_nc, new_nnz); diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,17 +1,12 @@ -<<<<<<< ChangeLog -<<<<<<< ChangeLog 2007-06-03 Søren Hauberg * plot/axes.m: Eliminate redundant else clause. -======= -======= 2007-06-03 David Bateman * polynomial/spline.m: Add a small tolerance to spline tests. * pkg/pkg.m: Protect against multiple actions being define. ->>>>>>> 1.846 2007-06-01 David Bateman * pkg.m (pkg:is_superuser): Remove function used in one place and @@ -19,7 +14,6 @@ (pkg:install): Check for existence of files to install before globbing and warn the user if they don't exist. ->>>>>>> 1.844 2007-05-31 David Bateman * miscellaneous/copyfile.m: Split copying of multiple files to a