Mercurial > hg > octave-lyh
changeset 6771:ffaac3c723ac
[project @ 2007-07-10 09:15:58 by dbateman]
author | dbateman |
---|---|
date | Tue, 10 Jul 2007 09:15:59 +0000 |
parents | babcbcc11ab6 |
children | 315bc7c8f9b5 |
files | src/ChangeLog src/DLD-FUNCTIONS/sparse.cc |
diffstat | 2 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-06-27 David Bateman <dbateman@free.fr> + + * DLD-FUNCTIONS/sparse.cc (Fspdiag): Ensure spdiag(zeros(1,0)) returns + 0x0 matrix. + 2007-06-28 John W. Eaton <jwe@octave.org> * ov-cell.cc (octave_cell::subsasgn): Given x = {}, convert to
--- a/src/DLD-FUNCTIONS/sparse.cc +++ b/src/DLD-FUNCTIONS/sparse.cc @@ -1026,6 +1026,21 @@ return retval; } +static octave_value +make_spdiag (const octave_value& a) +{ + octave_value retval; + octave_idx_type nr = a.rows (); + octave_idx_type nc = a.columns (); + + if (nr == 0 || nc == 0) + retval = SparseMatrix (); + else + retval = make_spdiag (a, octave_value (0.)); + + return retval; +} + // PKG_ADD: dispatch ("diag", "spdiag", "sparse matrix"); // PKG_ADD: dispatch ("diag", "spdiag", "sparse complex matrix"); // PKG_ADD: dispatch ("diag", "spdiag", "sparse bool matrix"); @@ -1055,7 +1070,7 @@ int nargin = args.length (); if (nargin == 1 && args(0).is_defined ()) - retval = make_spdiag (args(0), octave_value(0.)); + retval = make_spdiag (args(0)); else if (nargin == 2 && args(0).is_defined () && args(1).is_defined ()) retval = make_spdiag (args(0), args(1)); else