Mercurial > hg > octave-lyh
changeset 14569:3a9a56999ce5
maint: periodic merge from stable to default
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Apr 2012 13:18:56 -0400 |
parents | 98aaebc56d7c (current diff) 82449d607d20 (diff) |
children | 1c0f0e8f9a1b |
files | src/data.cc src/oct-map.cc |
diffstat | 3 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -1337,6 +1337,9 @@ ## Test non-square size %!assert(diag ([1,2,3], 6, 3), [1 0 0; 0 2 0; 0 0 3; 0 0 0; 0 0 0; 0 0 0]) +%!assert (diag (1, 2, 3), [1,0,0; 0,0,0]); +%!assert (diag ({1}, 2, 3), {1,[],[]; [],[],[]}); +%!assert (diag ({1,2}, 3, 4), {1,[],[],[]; [],2,[],[]; [],[],[],[]}); %% Test input validation %!error <Invalid call to diag> diag ()
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -971,7 +971,7 @@ octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - xvals[k].assign (i, rhs.xvals[k]); + xvals[k].assign (i, rhs.xvals[k], Matrix ()); if (nf > 0) dimensions = xvals[0].dims (); @@ -1014,7 +1014,7 @@ octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - xvals[k].assign (i, j, rhs.xvals[k]); + xvals[k].assign (i, j, rhs.xvals[k], Matrix ()); if (nf > 0) dimensions = xvals[0].dims (); @@ -1057,7 +1057,7 @@ octave_idx_type nf = nfields (); for (octave_idx_type k = 0; k < nf; k++) - xvals[k].assign (ia, rhs.xvals[k]); + xvals[k].assign (ia, rhs.xvals[k], Matrix ()); if (nf > 0) dimensions = xvals[0].dims (); @@ -1170,6 +1170,13 @@ setfield (k, tmp); } +/* +%!test +%! rhs.b = 1; +%! a(3) = rhs; +%! assert ({a.b}, {[], [], 1}) +*/ + void octave_map::delete_elements (const idx_vector& i) {
--- a/src/ov-base-sparse.cc +++ b/src/ov-base-sparse.cc @@ -318,7 +318,13 @@ << ", cols = " << nc << ", nnz = " << nz; - double dnel = matrix.numel (); + // Avoid calling numel here since it can easily overflow + // octave_idx_type even when there is no real problem storing the + // sparse array. + + double dnr = nr; + double dnc = nc; + double dnel = dnr * dnc; if (dnel > 0) {