Mercurial > hg > octave-nkf
diff liboctave/array/DiagArray2.cc @ 18145:a86d608c413c
Return empty matrix rather than issuing error when requested diagonal is out of range.
* data.cc: Add %!tests for new behavior.
* Array.cc (diag): Return 0x1 empty matrix when diagonal is out of range.
* DiagArray2.cc (extract_diag): Return 0x1 empty matrix when diagonal is out of
range.
* Sparse.cc (diag): Return 0x1 empty matrix when diagonal is out of range.
author | Marco Caliari <marco.caliari@univr.it> |
---|---|
date | Tue, 17 Dec 2013 09:00:34 -0800 |
parents | d63878346099 |
children | 4197fc428c7d |
line wrap: on
line diff
--- a/liboctave/array/DiagArray2.cc +++ b/liboctave/array/DiagArray2.cc @@ -66,9 +66,8 @@ d = Array<T> (dim_vector (std::min (cols () - k, rows ()), 1), T ()); else if (k < 0 && -k < rows ()) d = Array<T> (dim_vector (std::min (rows () + k, cols ()), 1), T ()); - else - (*current_liboctave_error_handler) - ("diag: requested diagonal out of range"); + else // Matlab returns [] 0x1 for out-of-range diagonal + d.resize (dim_vector (0, 1)); return d; }