Mercurial > hg > octave-avbm
changeset 12550:ea3a4bf39048
Treat empty vector (1x0 or 0x1) as valid input to diag().
Bug #32901
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 29 Mar 2011 17:47:26 -0700 |
parents | 570193964185 |
children | e4a1ede4e832 |
files | liboctave/Array.cc liboctave/ChangeLog |
diffstat | 2 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2447,10 +2447,11 @@ octave_idx_type nnr = dv (0); octave_idx_type nnc = dv (1); - if (nnr == 0 || nnc == 0) - ; // do nothing + if (nnr == 0 && nnc == 0) + ; // do nothing for empty matrix else if (nnr != 1 && nnc != 1) { + // Extract diag from matrix if (k > 0) nnc -= k; else if (k < 0) @@ -2482,8 +2483,9 @@ (*current_liboctave_error_handler) ("diag: requested diagonal out of range"); } - else if (nnr != 0 && nnc != 0) + else { + // Create diag matrix from vector octave_idx_type roff = 0; octave_idx_type coff = 0; if (k > 0)
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Rik <octave@nomad.inbox5.com> + + * Array.cc (diag): Treat empty vector (1x0 or 0x1) as valid input. + Improves Matlab compatibility (bug #32901). + 2011-02-13 David Bateman <dbateman@free.fr> * Sparse-perm-op-defs.h (template <typename SM>