Mercurial > hg > octave-shane
changeset 7246:f81e80674b9b
[project @ 2007-12-04 15:49:12 by jwe]
author | jwe |
---|---|
date | Tue, 04 Dec 2007 15:49:12 +0000 |
parents | d65670971cbc |
children | b689a67dbe88 |
files | liboctave/Array-util.h liboctave/ChangeLog liboctave/Sparse.cc |
diffstat | 3 files changed, 43 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array-util.h +++ b/liboctave/Array-util.h @@ -85,7 +85,7 @@ octave_idx_type iidx; }; -extern int permute_vector_compare (const void *a, const void *b); +extern int OCTAVE_API permute_vector_compare (const void *a, const void *b); extern void OCTAVE_API gripe_nonconformant (const char *op, int op1_len, int op2_len);
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,16 @@ +2007-12-04 David Bateman <dbateman@free.fr> + + * Sparse.cc (assign (Sparse<LT>&, const Sparse<RT>&)): + Resize matrix as well if one dimension of lhs is zero and the rhs + index exceeds the lhs index. + * Sparse.cc (assign1 (Sparse<LT>&, const Sparse<RT>&)): + Don't resize to a smaller matrix for empty matrices with a max rhs + index smaller than the non zero lhs index. + +2007-12-04 Michael Goffioul <michael.goffioul@gmail.com> + + * Array-util.h: Tag permute_vector_compare with OCTAVE_API. + 2007-12-03 Moritz Borgmann <octave@moriborg.de> * Array-util.cc (permute_vector_compare): Move here from Array.cc.
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -2162,7 +2162,7 @@ if (nr > 1) { - Sparse<LT> tmp (max_idx, 1, new_nzmx); + Sparse<LT> tmp ((max_idx > nr ? max_idx : nr), 1, new_nzmx); tmp.cidx(0) = 0; tmp.cidx(1) = new_nzmx; @@ -2206,7 +2206,7 @@ } else { - Sparse<LT> tmp (1, max_idx, new_nzmx); + Sparse<LT> tmp (1, (max_idx > nc ? max_idx : nc), new_nzmx); octave_idx_type i = 0; octave_idx_type ii = 0; @@ -2281,7 +2281,7 @@ if (nr > 1) { - Sparse<LT> tmp (max_idx, 1, new_nzmx); + Sparse<LT> tmp ((max_idx > nr ? max_idx : nr), 1, new_nzmx); tmp.cidx(0) = 0; tmp.cidx(1) = new_nzmx; @@ -2324,7 +2324,7 @@ } else { - Sparse<LT> tmp (1, max_idx, new_nzmx); + Sparse<LT> tmp (1, (max_idx > nc ? max_idx : nc), new_nzmx); octave_idx_type i = 0; octave_idx_type ii = 0; @@ -2490,9 +2490,6 @@ { if (rhs_nr == 1 && rhs_nc == 1 && n >= 0 && m >= 0) { - // No need to do anything if either of the indices - // are empty. - if (n > 0 && m > 0) { idx_i.sort (true); @@ -2597,6 +2594,31 @@ lhs = stmp; } + else + { + // No need to do anything if either of the indices + // are empty. + if (n > 0) + { + octave_idx_type max_row_idx = idx_i_is_colon ? + rhs_nr : idx_i.max () + 1; + octave_idx_type new_nr = max_row_idx > lhs_nr ? + max_row_idx : lhs_nr; + octave_idx_type new_nc = lhs_nc; + + lhs = Sparse<LT> (new_nr, new_nc); + } + else if (m > 0) + { + octave_idx_type max_col_idx = idx_j_is_colon ? + rhs_nc : idx_j.max () + 1; + octave_idx_type new_nr = lhs_nr; + octave_idx_type new_nc = max_col_idx > lhs_nc ? + max_col_idx : lhs_nc; + + lhs = Sparse<LT> (new_nr, new_nc); + } + } } else if (n == rhs_nr && m == rhs_nc) {