Mercurial > octave
changeset 23956:70188fd56fe6
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 29 Aug 2017 09:44:46 -0400 |
parents | df49ac93f50c (current diff) 520c37805969 (diff) |
children | 382cc01a60e1 |
files | liboctave/array/Sparse.cc |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/array/Sparse.cc Sun Aug 27 22:12:16 2017 -0700 +++ b/liboctave/array/Sparse.cc Tue Aug 29 09:44:46 2017 -0400 @@ -360,7 +360,8 @@ // Allocate result. change_capacity (nzm > new_nz ? nzm : new_nz); xcidx (0) = 0; - xcidx (1) = new_nz; + for (octave_idx_type j = 0; j < nc; j++) + xcidx (j+1) = j >= c(0) ? new_nz : 0; octave_idx_type *rri = ridx (); T *rrd = data (); @@ -508,7 +509,8 @@ // Allocate result. change_capacity (nzm > new_nz ? nzm : new_nz); xcidx (0) = 0; - xcidx (1) = new_nz; + for (octave_idx_type j = 0; j < nc; j++) + xcidx (j+1) = j >= c(0) ? new_nz : 0; octave_idx_type *rri = ridx (); T *rrd = data (); @@ -645,6 +647,12 @@ } } +/* +%!assert <51880> (sparse (1:2, 2, 1:2, 2, 2), sparse ([0, 1; 0, 2])) +%!assert <51880> (sparse (1:2, 1, 1:2, 2, 2), sparse ([1, 0; 2, 0])) +%!assert <51880> (sparse (1:2, 2, 1:2, 2, 3), sparse ([0, 1, 0; 0, 2, 0])) +*/ + template <typename T> Sparse<T>::Sparse (const Array<T>& a) : rep (nullptr), dimensions (a.dims ())