Mercurial > octave
diff libinterp/corefcn/sparse.cc @ 20555:f90c8372b7ba
eliminate many more simple uses of error_state
* Cell.cc, __ichol__.cc, __ilu__.cc, balance.cc, bsxfun.cc, colloc.cc,
det.cc, dlmread.cc, dynamic-ld.cc, eig.cc, fft.cc, fft2.cc, fftn.cc,
gcd.cc, getgrent.cc, getpwent.cc, givens.cc, hess.cc, input.cc,
levenshtein.cc, load-path.cc, lookup.cc, ls-mat-ascii.cc, ls-mat4.cc,
lsode.cc, lu.cc, max.cc, md5sum.cc, mex.cc, pager.cc, pinv.cc,
pr-output.cc, qz.cc, schur.cc, sparse.cc, sqrtm.cc, str2double.cc,
strfns.cc, sub2ind.cc, sysdep.cc, time.cc, toplev.cc, tril.cc,
tsearch.cc, typecast.cc, __init_gnuplot__.cc, __magick_read__.cc,
__osmesa_print__.cc, amd.cc, audiodevinfo.cc, dmperm.cc, fftw.cc,
symrcm.cc, ov-base-diag.cc, ov-base-sparse.cc, ov-base.cc,
ov-bool-sparse.cc, ov-builtin.cc, ov-complex.cc, ov-cx-diag.cc,
ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc,
ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc,
ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-lazy-idx.cc, ov-mex-fcn.cc,
ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc,
ov-scalar.cc, ov-str-mat.cc, op-bm-b.cc, op-bm-bm.cc, op-sbm-b.cc,
op-sbm-bm.cc, op-str-m.cc, op-str-s.cc, oct-parse.in.yy, pt-cbinop.cc,
pt-colon.cc, pt-decl.cc, pt-exp.cc, pt-id.cc, pt-misc.cc,
pt-select.cc, pt-unop.cc: Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 05 Oct 2015 19:29:36 -0400 |
parents | dd6345fd8a97 |
children | 8742e0b1cc49 |
line wrap: on
line diff
--- a/libinterp/corefcn/sparse.cc Mon Oct 05 12:03:16 2015 -0700 +++ b/libinterp/corefcn/sparse.cc Mon Oct 05 19:29:36 2015 -0400 @@ -152,13 +152,10 @@ get_dimensions (args(0), args(1), "sparse", m, n); - if (! error_state) - { - if (m >= 0 && n >= 0) - retval = SparseMatrix (m, n); - else - error ("sparse: dimensions must be non-negative"); - } + if (m >= 0 && n >= 0) + retval = SparseMatrix (m, n); + else + error ("sparse: dimensions must be non-negative"); } else if (nargin >= 3) { @@ -176,55 +173,48 @@ nargin -= 1; } - if (! error_state) + octave_idx_type m, n, nzmax; + m = n = nzmax = -1; + if (nargin == 6) { - octave_idx_type m, n, nzmax; - m = n = nzmax = -1; - if (nargin == 6) - { - nzmax = args(5).idx_type_value (); - nargin --; - } + nzmax = args(5).idx_type_value (); + nargin --; + } - if (nargin == 5) - { - get_dimensions (args(3), args(4), "sparse", m, n); + if (nargin == 5) + { + get_dimensions (args(3), args(4), "sparse", m, n); - if (! error_state && (m < 0 || n < 0)) - error ("sparse: dimensions must be non-negative"); - } - else if (nargin != 3) - print_usage (); + if (! error_state && (m < 0 || n < 0)) + error ("sparse: dimensions must be non-negative"); + } + else if (nargin != 3) + print_usage (); - if (! error_state) - { - int k = 0; // index we're checking when index_vector throws - try - { - idx_vector i = args(0).index_vector (); - k = 1; - idx_vector j = args(1).index_vector (); + int k = 0; // index we're checking when index_vector throws + try + { + idx_vector i = args(0).index_vector (); + k = 1; + idx_vector j = args(1).index_vector (); - if (args(2).is_bool_type ()) - retval = SparseBoolMatrix (args(2).bool_array_value (), i,j, - m, n, summation, nzmax); - else if (args(2).is_complex_type ()) - retval = SparseComplexMatrix (args(2).complex_array_value(), - i, j, m, n, summation, nzmax); - else if (args(2).is_numeric_type ()) - retval = SparseMatrix (args(2).array_value (), i, j, - m, n, summation, nzmax); - else - gripe_wrong_type_arg ("sparse", args(2)); - } - catch (index_exception& e) - { - // Rethrow to allow more info to be reported later. - e.set_pos_if_unset (2, k+1); - throw; - } - } - + if (args(2).is_bool_type ()) + retval = SparseBoolMatrix (args(2).bool_array_value (), i,j, + m, n, summation, nzmax); + else if (args(2).is_complex_type ()) + retval = SparseComplexMatrix (args(2).complex_array_value(), + i, j, m, n, summation, nzmax); + else if (args(2).is_numeric_type ()) + retval = SparseMatrix (args(2).array_value (), i, j, + m, n, summation, nzmax); + else + gripe_wrong_type_arg ("sparse", args(2)); + } + catch (index_exception& e) + { + // Rethrow to allow more info to be reported later. + e.set_pos_if_unset (2, k+1); + throw; } } @@ -277,11 +267,11 @@ octave_idx_type m = args(0).idx_type_value (); octave_idx_type n = args(1).idx_type_value (); octave_idx_type nz = 0; + if (nargin == 3) nz = args(2).idx_type_value (); - if (error_state) - ; - else if (m >= 0 && n >= 0 && nz >= 0) + + if (m >= 0 && n >= 0 && nz >= 0) retval = SparseMatrix (dim_vector (m, n), nz); else error ("spalloc: M,N,NZ must be non-negative");