Mercurial > octave
diff libinterp/octave-value/ov-flt-cx-mat.cc @ 20979:0963ed389012
maint: invert if/else/error instances.
* ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc,
ov-cx-mat.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-perm.cc,
ov-re-mat.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.cc:
Invert if/else/error instances.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 24 Dec 2015 12:50:28 -0500 |
parents | 3aa293be0e8d |
children | 7f4c6d594e3d |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-flt-cx-mat.cc Thu Dec 24 12:06:27 2015 -0500 +++ b/libinterp/octave-value/ov-flt-cx-mat.cc Thu Dec 24 12:50:28 2015 -0500 @@ -285,19 +285,13 @@ octave_value octave_float_complex_matrix::diag (octave_idx_type m, octave_idx_type n) const { - octave_value retval; - - if (matrix.ndims () == 2 - && (matrix.rows () == 1 || matrix.columns () == 1)) - { - FloatComplexMatrix mat (matrix); - - retval = mat.diag (m, n); - } - else + if (matrix.ndims () != 2 + || (matrix.rows () != 1 && matrix.columns () != 1)) error ("diag: expecting vector argument"); - return retval; + FloatComplexMatrix mat (matrix); + + return mat.diag (m, n); } bool @@ -348,52 +342,48 @@ { int mdims = static_cast<int> (val); - if (mdims >= 0) - { - dim_vector dv; - dv.resize (mdims); + if (mdims < 0) + error ("load: failed to extract number of dimensions"); - for (int i = 0; i < mdims; i++) - is >> dv(i); + dim_vector dv; + dv.resize (mdims); - if (! is) - error ("load: failed to read dimensions"); + for (int i = 0; i < mdims; i++) + is >> dv(i); - FloatComplexNDArray tmp(dv); + if (! is) + error ("load: failed to read dimensions"); - is >> tmp; + FloatComplexNDArray tmp(dv); - if (is) - matrix = tmp; - else - error ("load: failed to load matrix constant"); - } - else - error ("load: failed to extract number of dimensions"); + is >> tmp; + + if (! is) + error ("load: failed to load matrix constant"); + + matrix = tmp; } else if (kw == "rows") { octave_idx_type nr = val; octave_idx_type nc = 0; - if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0) + if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0) + error ("load: failed to extract number of rows and columns"); + + if (nr > 0 && nc > 0) { - if (nr > 0 && nc > 0) - { - FloatComplexMatrix tmp (nr, nc); - is >> tmp; - if (is) - matrix = tmp; - else - error ("load: failed to load matrix constant"); - } - else if (nr == 0 || nc == 0) - matrix = FloatComplexMatrix (nr, nc); - else - panic_impossible (); + FloatComplexMatrix tmp (nr, nc); + is >> tmp; + if (! is) + error ("load: failed to load matrix constant"); + + matrix = tmp; } + else if (nr == 0 || nc == 0) + matrix = FloatComplexMatrix (nr, nc); else - error ("load: failed to extract number of rows and columns"); + panic_impossible (); } else panic_impossible ();