Mercurial > hg > octave-nkf
diff liboctave/Sparse.cc @ 6689:8e0444d90050
[project @ 2007-06-04 22:28:19 by dbateman]
author | dbateman |
---|---|
date | Mon, 04 Jun 2007 22:28:19 +0000 |
parents | 9e70afeb2ebf |
children | 75d99621f850 |
line wrap: on
line diff
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -730,14 +730,22 @@ Sparse<T>::reshape (const dim_vector& new_dims) const { Sparse<T> 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<T> (new_nr, new_nc, new_nnz);