# HG changeset patch # User Rik # Date 1452711742 28800 # Node ID 5e00ed38a58bd2d6cce46554210016e44ee23fb8 # Parent 221847e5f4880a72117fe9d11f29508ebd3e6b4a maint: Replace if/error/else paradigm with just if/error. * __ilu__.cc, data.cc, file-io.cc, graphics.cc, graphics.in.h, ls-mat5.cc, lu.cc, octave-link.cc, regexp.cc, schur.cc, spparms.cc, sub2ind.cc, syscalls.cc, toplev.cc, variables.cc, xpow.cc, audiodevinfo.cc, ccolamd.cc, ov-builtin.cc, ov-classdef.cc, ov-intx.h, ov-lazy-idx.cc, ov-mex-fcn.cc, op-int.h, lex.ll, oct-parse.in.yy, pt-binop.cc, pt-cbinop.cc, pt-const.cc, pt-decl.h, pt-fcn-handle.cc, pt-unop.cc, CollocWt.cc: Replace if/error/else paradigm with just if/error. diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/__ilu__.cc --- a/libinterp/corefcn/__ilu__.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/__ilu__.cc Wed Jan 13 11:02:22 2016 -0800 @@ -361,6 +361,7 @@ // octave_idx_type type due to fill-in during the process. if (total_len_l < 0 || total_len_u < 0) error ("ilu: integer overflow. Too many fill-in elements in L or U"); + cidx_u[k+1] = cidx_u[k] - cidx_u[0] + w_len_u; cidx_l[k+1] = cidx_l[k] - cidx_l[0] + w_len_l; diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/data.cc Wed Jan 13 11:02:22 2016 -0800 @@ -926,6 +926,8 @@ %!assert (mod (0.94, 0.01), 0.0) */ +// FIXME: Macros NATIVE_REDUCTION_1 and NATIVE_REDUCTION seem to be unused. +// Checked 1/23/2016. They should probably be removed for clarity. // FIXME: Need to convert reduction functions of this file for single precision #define NATIVE_REDUCTION_1(FCN, TYPE, DIM) \ @@ -953,7 +955,8 @@ isdouble = true; \ else \ error ("sum: unrecognized string argument"); \ - nargin --; \ + \ + nargin--; \ } \ \ if (nargin < 1 || nargin > 2) \ @@ -1234,6 +1237,7 @@ isdouble = true; else error ("cumsum: unrecognized string argument"); + nargin --; } @@ -1519,6 +1523,7 @@ isdouble = true; else error ("prod: unrecognized type argument '%s'", str.c_str ()); + nargin --; } @@ -2117,6 +2122,7 @@ { if (j > 1) error ("%s: indexing error", fname.c_str ()); + break; } else @@ -2994,6 +3000,7 @@ isextra = true; else error ("sum: unrecognized type argument '%s'", str.c_str ()); + nargin --; } @@ -5615,6 +5622,7 @@ strflag = sfinf; else error ("norm: unrecognized option: %s", str.c_str ()); + // we've handled the last parameter, so act as if it was removed nargin --; } @@ -7262,47 +7270,44 @@ bool tscl = tval.numel () == 1; bool fscl = fval.numel () == 1; - if ((! tscl && tval.dims () != dv) - || (! fscl && fval.dims () != dv)) + if ((! tscl && tval.dims () != dv) || (! fscl && fval.dims () != dv)) error ("merge: MASK, TVAL, and FVAL dimensions must match"); - else + + T *rv = retval.fortran_vec (); + octave_idx_type n = retval.numel (); + + const T *tv = tval.data (); + const T *fv = fval.data (); + const bool *mv = mask.data (); + + if (tscl) { - T *rv = retval.fortran_vec (); - octave_idx_type n = retval.numel (); - - const T *tv = tval.data (); - const T *fv = fval.data (); - const bool *mv = mask.data (); - - if (tscl) + if (fscl) { - if (fscl) - { - T ts = tv[0]; - T fs = fv[0]; - for (octave_idx_type i = 0; i < n; i++) - rv[i] = mv[i] ? ts : fs; - } - else - { - T ts = tv[0]; - for (octave_idx_type i = 0; i < n; i++) - rv[i] = mv[i] ? ts : fv[i]; - } + T ts = tv[0]; + T fs = fv[0]; + for (octave_idx_type i = 0; i < n; i++) + rv[i] = mv[i] ? ts : fs; } else { - if (fscl) - { - T fs = fv[0]; - for (octave_idx_type i = 0; i < n; i++) - rv[i] = mv[i] ? tv[i] : fs; - } - else - { - for (octave_idx_type i = 0; i < n; i++) - rv[i] = mv[i] ? tv[i] : fv[i]; - } + T ts = tv[0]; + for (octave_idx_type i = 0; i < n; i++) + rv[i] = mv[i] ? ts : fv[i]; + } + } + else + { + if (fscl) + { + T fs = fv[0]; + for (octave_idx_type i = 0; i < n; i++) + rv[i] = mv[i] ? tv[i] : fs; + } + else + { + for (octave_idx_type i = 0; i < n; i++) + rv[i] = mv[i] ? tv[i] : fv[i]; } } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/file-io.cc --- a/libinterp/corefcn/file-io.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/file-io.cc Wed Jan 13 11:02:22 2016 -0800 @@ -1871,18 +1871,18 @@ if (tmp > ibase - 1) error ("umask: invalid digit"); - else + + retval = tmp; + int mult = ibase; + while ((x = (x - tmp) / obase)) { - retval = tmp; - int mult = ibase; - while ((x = (x - tmp) / obase)) - { - tmp = x % obase; - if (tmp > ibase - 1) - error ("umask: invalid digit"); - retval += mult * tmp; - mult *= ibase; - } + tmp = x % obase; + + if (tmp > ibase - 1) + error ("umask: invalid digit"); + + retval += mult * tmp; + mult *= ibase; } return retval; diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/graphics.cc Wed Jan 13 11:02:22 2016 -0800 @@ -8729,6 +8729,7 @@ { if (! get___object__ ().is_empty ()) error ("set: cannot change the style of a uicontrol object after creation."); + style = st; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/graphics.in.h Wed Jan 13 11:02:22 2016 -0800 @@ -2730,6 +2730,7 @@ { if (! valid_object ()) error ("base_graphics_object::get_defaults_list: invalid graphics object"); + return property_list (); } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/ls-mat5.cc --- a/libinterp/corefcn/ls-mat5.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/ls-mat5.cc Wed Jan 13 11:02:22 2016 -0800 @@ -1494,6 +1494,7 @@ { if (! quiet) error ("load: can't read binary file"); + return -1; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/lu.cc --- a/libinterp/corefcn/lu.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/lu.cc Wed Jan 13 11:02:22 2016 -0800 @@ -167,8 +167,8 @@ { if (! issparse) error ("lu: can not define pivoting threshold THRES for full matrices"); + Matrix tmp = args(n++).matrix_value (); - if (tmp.numel () == 1) { thres.resize (1,2); diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/octave-link.cc --- a/libinterp/corefcn/octave-link.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/octave-link.cc Wed Jan 13 11:02:22 2016 -0800 @@ -74,8 +74,8 @@ { if (obj && instance) error ("octave_link is already linked!"); - else - instance = obj; + + instance = obj; } void diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/regexp.cc --- a/libinterp/corefcn/regexp.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/regexp.cc Wed Jan 13 11:02:22 2016 -0800 @@ -575,25 +575,22 @@ } else if (cellstr.numel () == cellpat.numel ()) { - if (cellstr.dims () != cellpat.dims ()) error ("%s: inconsistent cell array dimensions", who.c_str ()); - else - { - for (int j = 0; j < nargout; j++) - newretval[j].resize (cellstr.dims ()); + + for (int j = 0; j < nargout; j++) + newretval[j].resize (cellstr.dims ()); - for (octave_idx_type i = 0; i < cellstr.numel (); i++) - { - new_args(0) = cellstr(i); - new_args(1) = cellpat(i); + for (octave_idx_type i = 0; i < cellstr.numel (); i++) + { + new_args(0) = cellstr(i); + new_args(1) = cellpat(i); - octave_value_list tmp = octregexp (new_args, nargout, who, - case_insensitive); + octave_value_list tmp = octregexp (new_args, nargout, who, + case_insensitive); - for (int j = 0; j < nargout; j++) - newretval[j](i) = tmp(j); - } + for (int j = 0; j < nargout; j++) + newretval[j](i) = tmp(j); } } else diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/schur.cc --- a/libinterp/corefcn/schur.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/schur.cc Wed Jan 13 11:02:22 2016 -0800 @@ -301,7 +301,6 @@ error ("rsf2csf: UR and TR must be real matrices"); else { - if (args(0).is_single_type () || args(1).is_single_type ()) { FloatMatrix u = args(0).float_matrix_value (); diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/spparms.cc --- a/libinterp/corefcn/spparms.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/spparms.cc Wed Jan 13 11:02:22 2016 -0800 @@ -147,18 +147,17 @@ double val = octave_sparse_params::get_key (str); if (xisnan (val)) error ("spparms: KEY not recognized"); - else - retval = ovl (val); + + retval = ovl (val); } } else { NDArray vals = args(0).xarray_value ("spparms: input must be a string or a vector"); - if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE) error ("spparms: too many elements in vector VALS"); - else - octave_sparse_params::set_vals (vals); + + octave_sparse_params::set_vals (vals); } } else if (nargin == 2) diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/sub2ind.cc --- a/libinterp/corefcn/sub2ind.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/sub2ind.cc Wed Jan 13 11:02:22 2016 -0800 @@ -43,18 +43,16 @@ if (n < 1) error ("%s: dimension vector DIMS must not be empty", name); - else + + dv.resize (std::max (n, static_cast (2))); + dv(1) = 1; + for (octave_idx_type i = 0; i < n; i++) { - dv.resize (std::max (n, static_cast (2))); - dv(1) = 1; - for (octave_idx_type i = 0; i < n; i++) - { - octave_idx_type ii = dimsv(i); - if (ii == dimsv(i) && ii >= 0) - dv(i) = ii; - else - error ("%s: dimension vector DIMS must contain integers", name); - } + octave_idx_type ii = dimsv(i); + if (ii == dimsv(i) && ii >= 0) + dv(i) = ii; + else + error ("%s: dimension vector DIMS must contain integers", name); } return dv; diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/syscalls.cc --- a/libinterp/corefcn/syscalls.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/syscalls.cc Wed Jan 13 11:02:22 2016 -0800 @@ -640,18 +640,18 @@ if (tmp > ibase - 1) error ("mkfifo: invalid digit"); - else + + retval = tmp; + int mult = ibase; + while ((x = (x - tmp) / obase)) { - retval = tmp; - int mult = ibase; - while ((x = (x - tmp) / obase)) - { - tmp = x % obase; - if (tmp > ibase - 1) - error ("mkfifo: invalid digit"); - retval += mult * tmp; - mult *= ibase; - } + tmp = x % obase; + + if (tmp > ibase - 1) + error ("mkfifo: invalid digit"); + + retval += mult * tmp; + mult *= ibase; } return retval; diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/toplev.cc Wed Jan 13 11:02:22 2016 -0800 @@ -838,27 +838,25 @@ if (! quit_allowed) error ("quit: not supported in embedded mode"); - else + + if (args.length () > 0) { - if (args.length () > 0) - { - int tmp = args(0).nint_value (); + int tmp = args(0).nint_value (); - exit_status = tmp; - } + exit_status = tmp; + } - // Instead of simply calling exit, we simulate an interrupt - // with a request to exit cleanly so that no matter where the - // call to quit occurs, we will run the unwind_protect stack, - // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before - // exiting. + // Instead of simply calling exit, we simulate an interrupt + // with a request to exit cleanly so that no matter where the + // call to quit occurs, we will run the unwind_protect stack, + // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before + // exiting. - quitting_gracefully = true; + quitting_gracefully = true; - octave_interrupt_state = -1; + octave_interrupt_state = -1; - octave_throw_interrupt_exception (); - } + octave_throw_interrupt_exception (); return retval; } @@ -1078,9 +1076,7 @@ error ("system: fork failed -- can't create child process"); else if (pid == 0) { - // FIXME: should probably replace this - // call with something portable. - + // FIXME: should probably replace this call with something portable. execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (), static_cast (0)); @@ -1098,12 +1094,10 @@ if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi)) error ("system: CreateProcess failed -- can't create child process"); - else - { - retval(0) = pi.dwProcessId; - CloseHandle (pi.hProcess); - CloseHandle (pi.hThread); - } + + retval(0) = pi.dwProcessId; + CloseHandle (pi.hProcess); + CloseHandle (pi.hThread); #else error ("system: asynchronous system calls are not supported"); #endif diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/variables.cc Wed Jan 13 11:02:22 2016 -0800 @@ -844,8 +844,7 @@ if (ival < minval) error ("%s: arg must be greater than %d", nm, minval); else if (ival > maxval) - error ("%s: arg must be less than or equal to %d", - nm, maxval); + error ("%s: arg must be less than or equal to %d", nm, maxval); else var = ival; } @@ -1611,31 +1610,29 @@ // stored at all. if (i == argc - 1) error ("whos: -file argument must be followed by a filename"); - else - { - std::string nm = argv[i + 1]; - - unwind_protect frame; - - // Set up temporary scope. - - symbol_table::scope_id tmp_scope = symbol_table::alloc_scope (); - frame.add_fcn (symbol_table::erase_scope, tmp_scope); - - symbol_table::set_scope (tmp_scope); - - octave_call_stack::push (tmp_scope, 0); - frame.add_fcn (octave_call_stack::pop); - - frame.add_fcn (symbol_table::clear_variables); - - feval ("load", octave_value (nm), 0); - - std::string newmsg = std::string ("Variables in the file ") - + nm + ":\n\n"; - - retval = do_who (i, argv, return_list, verbose, newmsg); - } + + std::string nm = argv[i + 1]; + + unwind_protect frame; + + // Set up temporary scope. + + symbol_table::scope_id tmp_scope = symbol_table::alloc_scope (); + frame.add_fcn (symbol_table::erase_scope, tmp_scope); + + symbol_table::set_scope (tmp_scope); + + octave_call_stack::push (tmp_scope, 0); + frame.add_fcn (octave_call_stack::pop); + + frame.add_fcn (symbol_table::clear_variables); + + feval ("load", octave_value (nm), 0); + + std::string newmsg = std::string ("Variables in the file ") + + nm + ":\n\n"; + + retval = do_who (i, argv, return_list, verbose, newmsg); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/corefcn/xpow.cc --- a/libinterp/corefcn/xpow.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/corefcn/xpow.cc Wed Jan 13 11:02:22 2016 -0800 @@ -110,35 +110,33 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + try { - try + EIG b_eig (b); + + ComplexColumnVector lambda (b_eig.eigenvalues ()); + ComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - EIG b_eig (b); - - ComplexColumnVector lambda (b_eig.eigenvalues ()); - ComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - Complex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - ComplexDiagMatrix D (lambda); - - ComplexMatrix C = Q * D * Q.inverse (); - if (a > 0) - retval = real (C); + Complex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); else - retval = C; + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + ComplexDiagMatrix D (lambda); + + ComplexMatrix C = Q * D * Q.inverse (); + if (a > 0) + retval = real (C); + else + retval = C; + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -163,31 +161,29 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + EIG b_eig (b); + + try { - EIG b_eig (b); - - try + ComplexColumnVector lambda (b_eig.eigenvalues ()); + ComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - ComplexColumnVector lambda (b_eig.eigenvalues ()); - ComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - Complex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - ComplexDiagMatrix D (lambda); - - retval = ComplexMatrix (Q * D * Q.inverse ()); + Complex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); + else + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + ComplexDiagMatrix D (lambda); + + retval = ComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -204,76 +200,74 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else + + if (static_cast (b) == b) { - if (static_cast (b) == b) + int btmp = static_cast (b); + if (btmp == 0) { - int btmp = static_cast (b); - if (btmp == 0) - { - retval = DiagMatrix (nr, nr, 1.0); - } - else - { - // Too much copying? - // FIXME: we shouldn't do this if the exponent is large... - - Matrix atmp; - if (btmp < 0) - { - btmp = -btmp; - - octave_idx_type info; - double rcond = 0.0; - MatrixType mattype (a); - - atmp = a.inverse (mattype, info, rcond, 1); - - if (info == -1) - warning ("inverse: matrix singular to machine\ - precision, rcond = %g", rcond); - } - else - atmp = a; - - Matrix result (atmp); - - btmp--; - - while (btmp > 0) - { - if (btmp & 1) - result = result * atmp; - - btmp >>= 1; - - if (btmp > 0) - atmp = atmp * atmp; - } - - retval = result; - } + retval = DiagMatrix (nr, nr, 1.0); } else { - EIG a_eig (a); - - try + // Too much copying? + // FIXME: we shouldn't do this if the exponent is large... + + Matrix atmp; + if (btmp < 0) + { + btmp = -btmp; + + octave_idx_type info; + double rcond = 0.0; + MatrixType mattype (a); + + atmp = a.inverse (mattype, info, rcond, 1); + + if (info == -1) + warning ("inverse: matrix singular to machine\ +precision, rcond = %g", rcond); + } + else + atmp = a; + + Matrix result (atmp); + + btmp--; + + while (btmp > 0) { - ComplexColumnVector lambda (a_eig.eigenvalues ()); - ComplexMatrix Q (a_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - lambda(i) = std::pow (lambda(i), b); - - ComplexDiagMatrix D (lambda); - - retval = ComplexMatrix (Q * D * Q.inverse ()); + if (btmp & 1) + result = result * atmp; + + btmp >>= 1; + + if (btmp > 0) + atmp = atmp * atmp; } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + + retval = result; + } + } + else + { + EIG a_eig (a); + + try + { + ComplexColumnVector lambda (a_eig.eigenvalues ()); + ComplexMatrix Q (a_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) + lambda(i) = std::pow (lambda(i), b); + + ComplexDiagMatrix D (lambda); + + retval = ComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } } @@ -291,22 +285,20 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); + + if (static_cast (b) == b) + { + DiagMatrix r (nr, nc); + for (octave_idx_type i = 0; i < nc; i++) + r.dgelem (i) = std::pow (a.dgelem (i), b); + retval = r; + } else { - if (static_cast (b) == b) - { - DiagMatrix r (nr, nc); - for (octave_idx_type i = 0; i < nc; i++) - r.dgelem (i) = std::pow (a.dgelem (i), b); - retval = r; - } - else - { - ComplexDiagMatrix r (nr, nc); - for (octave_idx_type i = 0; i < nc; i++) - r.dgelem (i) = std::pow (static_cast (a.dgelem (i)), b); - retval = r; - } + ComplexDiagMatrix r (nr, nc); + for (octave_idx_type i = 0; i < nc; i++) + r.dgelem (i) = std::pow (static_cast (a.dgelem (i)), b); + retval = r; } return retval; @@ -335,26 +327,24 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else + + EIG a_eig (a); + + try { - EIG a_eig (a); - - try - { - ComplexColumnVector lambda (a_eig.eigenvalues ()); - ComplexMatrix Q (a_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - lambda(i) = std::pow (lambda(i), b); - - ComplexDiagMatrix D (lambda); - - retval = ComplexMatrix (Q * D * Q.inverse ()); - } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + ComplexColumnVector lambda (a_eig.eigenvalues ()); + ComplexMatrix Q (a_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) + lambda(i) = std::pow (lambda(i), b); + + ComplexDiagMatrix D (lambda); + + retval = ComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -385,31 +375,29 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + EIG b_eig (b); + + try { - EIG b_eig (b); - - try + ComplexColumnVector lambda (b_eig.eigenvalues ()); + ComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - ComplexColumnVector lambda (b_eig.eigenvalues ()); - ComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - Complex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - ComplexDiagMatrix D (lambda); - - retval = ComplexMatrix (Q * D * Q.inverse ()); + Complex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); + else + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + ComplexDiagMatrix D (lambda); + + retval = ComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -435,31 +423,29 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + EIG b_eig (b); + + try { - EIG b_eig (b); - - try + ComplexColumnVector lambda (b_eig.eigenvalues ()); + ComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - ComplexColumnVector lambda (b_eig.eigenvalues ()); - ComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - Complex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - ComplexDiagMatrix D (lambda); - - retval = ComplexMatrix (Q * D * Q.inverse ()); + Complex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); + else + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + ComplexDiagMatrix D (lambda); + + retval = ComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -476,93 +462,55 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else + + if (static_cast (b) == b) { - if (static_cast (b) == b) + int btmp = static_cast (b); + if (btmp == 0) { - int btmp = static_cast (b); - if (btmp == 0) - { - retval = DiagMatrix (nr, nr, 1.0); - } - else - { - // Too much copying? - // FIXME: we shouldn't do this if the exponent is large... - - ComplexMatrix atmp; - if (btmp < 0) - { - btmp = -btmp; - - octave_idx_type info; - double rcond = 0.0; - MatrixType mattype (a); - - atmp = a.inverse (mattype, info, rcond, 1); - - if (info == -1) - warning ("inverse: matrix singular to machine\ - precision, rcond = %g", rcond); - } - else - atmp = a; - - ComplexMatrix result (atmp); - - btmp--; - - while (btmp > 0) - { - if (btmp & 1) - result = result * atmp; - - btmp >>= 1; - - if (btmp > 0) - atmp = atmp * atmp; - } - - retval = result; - } + retval = DiagMatrix (nr, nr, 1.0); } else { - EIG a_eig (a); - - try + // Too much copying? + // FIXME: we shouldn't do this if the exponent is large... + + ComplexMatrix atmp; + if (btmp < 0) { - ComplexColumnVector lambda (a_eig.eigenvalues ()); - ComplexMatrix Q (a_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - lambda(i) = std::pow (lambda(i), b); - - ComplexDiagMatrix D (lambda); - - retval = ComplexMatrix (Q * D * Q.inverse ()); + btmp = -btmp; + + octave_idx_type info; + double rcond = 0.0; + MatrixType mattype (a); + + atmp = a.inverse (mattype, info, rcond, 1); + + if (info == -1) + warning ("inverse: matrix singular to machine\ +precision, rcond = %g", rcond); } - catch (const octave_execution_exception&) + else + atmp = a; + + ComplexMatrix result (atmp); + + btmp--; + + while (btmp > 0) { - gripe_failed_diagonalization (); + if (btmp & 1) + result = result * atmp; + + btmp >>= 1; + + if (btmp > 0) + atmp = atmp * atmp; } + + retval = result; } } - - return retval; -} - -// -*- 12 -*- -octave_value -xpow (const ComplexMatrix& a, const Complex& b) -{ - octave_value retval; - - octave_idx_type nr = a.rows (); - octave_idx_type nc = a.cols (); - - if (nr == 0 || nc == 0 || nr != nc) - error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); else { EIG a_eig (a); @@ -588,6 +536,40 @@ return retval; } +// -*- 12 -*- +octave_value +xpow (const ComplexMatrix& a, const Complex& b) +{ + octave_value retval; + + octave_idx_type nr = a.rows (); + octave_idx_type nc = a.cols (); + + if (nr == 0 || nc == 0 || nr != nc) + error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); + + EIG a_eig (a); + + try + { + ComplexColumnVector lambda (a_eig.eigenvalues ()); + ComplexMatrix Q (a_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) + lambda(i) = std::pow (lambda(i), b); + + ComplexDiagMatrix D (lambda); + + retval = ComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); + } + + return retval; +} + // -*- 12d -*- octave_value xpow (const ComplexDiagMatrix& a, const Complex& b) @@ -599,13 +581,11 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else - { - ComplexDiagMatrix r (nr, nc); - for (octave_idx_type i = 0; i < nc; i++) - r(i, i) = std::pow (a(i, i), b); - retval = r; - } + + ComplexDiagMatrix r (nr, nc); + for (octave_idx_type i = 0; i < nc; i++) + r(i, i) = std::pow (a(i, i), b); + retval = r; return retval; } @@ -1547,36 +1527,34 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + FloatEIG b_eig (b); + + try { - FloatEIG b_eig (b); - - try + FloatComplexColumnVector lambda (b_eig.eigenvalues ()); + FloatComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - FloatComplexColumnVector lambda (b_eig.eigenvalues ()); - FloatComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - FloatComplex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - FloatComplexDiagMatrix D (lambda); - - FloatComplexMatrix C = Q * D * Q.inverse (); - - if (a > 0) - retval = real (C); + FloatComplex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); else - retval = C; + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + FloatComplexDiagMatrix D (lambda); + + FloatComplexMatrix C = Q * D * Q.inverse (); + + if (a > 0) + retval = real (C); + else + retval = C; + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -1601,31 +1579,29 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + FloatEIG b_eig (b); + + try { - FloatEIG b_eig (b); - - try + FloatComplexColumnVector lambda (b_eig.eigenvalues ()); + FloatComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - FloatComplexColumnVector lambda (b_eig.eigenvalues ()); - FloatComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - FloatComplex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - FloatComplexDiagMatrix D (lambda); - - retval = FloatComplexMatrix (Q * D * Q.inverse ()); + FloatComplex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); + else + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + FloatComplexDiagMatrix D (lambda); + + retval = FloatComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -1642,126 +1618,55 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else + + if (static_cast (b) == b) { - if (static_cast (b) == b) + int btmp = static_cast (b); + if (btmp == 0) { - int btmp = static_cast (b); - if (btmp == 0) - { - retval = FloatDiagMatrix (nr, nr, 1.0); - } - else - { - // Too much copying? - // FIXME: we shouldn't do this if the exponent is large... - - FloatMatrix atmp; - if (btmp < 0) - { - btmp = -btmp; - - octave_idx_type info; - float rcond = 0.0; - MatrixType mattype (a); - - atmp = a.inverse (mattype, info, rcond, 1); - - if (info == -1) - warning ("inverse: matrix singular to machine\ - precision, rcond = %g", rcond); - } - else - atmp = a; - - FloatMatrix result (atmp); - - btmp--; - - while (btmp > 0) - { - if (btmp & 1) - result = result * atmp; - - btmp >>= 1; - - if (btmp > 0) - atmp = atmp * atmp; - } - - retval = result; - } + retval = FloatDiagMatrix (nr, nr, 1.0); } else { - FloatEIG a_eig (a); - - try + // Too much copying? + // FIXME: we shouldn't do this if the exponent is large... + + FloatMatrix atmp; + if (btmp < 0) { - FloatComplexColumnVector lambda (a_eig.eigenvalues ()); - FloatComplexMatrix Q (a_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - lambda(i) = std::pow (lambda(i), b); - - FloatComplexDiagMatrix D (lambda); - - retval = FloatComplexMatrix (Q * D * Q.inverse ()); + btmp = -btmp; + + octave_idx_type info; + float rcond = 0.0; + MatrixType mattype (a); + + atmp = a.inverse (mattype, info, rcond, 1); + + if (info == -1) + warning ("inverse: matrix singular to machine\ +precision, rcond = %g", rcond); } - catch (const octave_execution_exception&) + else + atmp = a; + + FloatMatrix result (atmp); + + btmp--; + + while (btmp > 0) { - gripe_failed_diagonalization (); + if (btmp & 1) + result = result * atmp; + + btmp >>= 1; + + if (btmp > 0) + atmp = atmp * atmp; } + + retval = result; } } - - return retval; -} - -// -*- 5d -*- -octave_value -xpow (const FloatDiagMatrix& a, float b) -{ - octave_value retval; - - octave_idx_type nr = a.rows (); - octave_idx_type nc = a.cols (); - - if (nr == 0 || nc == 0 || nr != nc) - error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else - { - if (static_cast (b) == b) - { - FloatDiagMatrix r (nr, nc); - for (octave_idx_type i = 0; i < nc; i++) - r.dgelem (i) = std::pow (a.dgelem (i), b); - retval = r; - } - else - { - FloatComplexDiagMatrix r (nr, nc); - for (octave_idx_type i = 0; i < nc; i++) - r.dgelem (i) = std::pow (static_cast (a.dgelem (i)), - b); - retval = r; - } - } - - return retval; -} - -// -*- 6 -*- -octave_value -xpow (const FloatMatrix& a, const FloatComplex& b) -{ - octave_value retval; - - octave_idx_type nr = a.rows (); - octave_idx_type nc = a.cols (); - - if (nr == 0 || nc == 0 || nr != nc) - error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); else { FloatEIG a_eig (a); @@ -1787,6 +1692,71 @@ return retval; } +// -*- 5d -*- +octave_value +xpow (const FloatDiagMatrix& a, float b) +{ + octave_value retval; + + octave_idx_type nr = a.rows (); + octave_idx_type nc = a.cols (); + + if (nr == 0 || nc == 0 || nr != nc) + error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); + + if (static_cast (b) == b) + { + FloatDiagMatrix r (nr, nc); + for (octave_idx_type i = 0; i < nc; i++) + r.dgelem (i) = std::pow (a.dgelem (i), b); + retval = r; + } + else + { + FloatComplexDiagMatrix r (nr, nc); + for (octave_idx_type i = 0; i < nc; i++) + r.dgelem (i) = std::pow (static_cast (a.dgelem (i)), + b); + retval = r; + } + + return retval; +} + +// -*- 6 -*- +octave_value +xpow (const FloatMatrix& a, const FloatComplex& b) +{ + octave_value retval; + + octave_idx_type nr = a.rows (); + octave_idx_type nc = a.cols (); + + if (nr == 0 || nc == 0 || nr != nc) + error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); + + FloatEIG a_eig (a); + + try + { + FloatComplexColumnVector lambda (a_eig.eigenvalues ()); + FloatComplexMatrix Q (a_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) + lambda(i) = std::pow (lambda(i), b); + + FloatComplexDiagMatrix D (lambda); + + retval = FloatComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); + } + + return retval; +} + // -*- 7 -*- octave_value xpow (const FloatComplex& a, float b) @@ -1812,31 +1782,29 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + FloatEIG b_eig (b); + + try { - FloatEIG b_eig (b); - - try + FloatComplexColumnVector lambda (b_eig.eigenvalues ()); + FloatComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - FloatComplexColumnVector lambda (b_eig.eigenvalues ()); - FloatComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - FloatComplex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - FloatComplexDiagMatrix D (lambda); - - retval = FloatComplexMatrix (Q * D * Q.inverse ()); + FloatComplex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); + else + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + FloatComplexDiagMatrix D (lambda); + + retval = FloatComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -1862,31 +1830,29 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for x^A, A must be a square matrix. Use .^ for elementwise power."); - else + + FloatEIG b_eig (b); + + try { - FloatEIG b_eig (b); - - try + FloatComplexColumnVector lambda (b_eig.eigenvalues ()); + FloatComplexMatrix Q (b_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) { - FloatComplexColumnVector lambda (b_eig.eigenvalues ()); - FloatComplexMatrix Q (b_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - { - FloatComplex elt = lambda(i); - if (std::imag (elt) == 0.0) - lambda(i) = std::pow (a, std::real (elt)); - else - lambda(i) = std::pow (a, elt); - } - FloatComplexDiagMatrix D (lambda); - - retval = FloatComplexMatrix (Q * D * Q.inverse ()); + FloatComplex elt = lambda(i); + if (std::imag (elt) == 0.0) + lambda(i) = std::pow (a, std::real (elt)); + else + lambda(i) = std::pow (a, elt); } - catch (const octave_execution_exception&) - { - gripe_failed_diagonalization (); - } + FloatComplexDiagMatrix D (lambda); + + retval = FloatComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); } return retval; @@ -1903,93 +1869,55 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else + + if (static_cast (b) == b) { - if (static_cast (b) == b) + int btmp = static_cast (b); + if (btmp == 0) { - int btmp = static_cast (b); - if (btmp == 0) - { - retval = FloatDiagMatrix (nr, nr, 1.0); - } - else - { - // Too much copying? - // FIXME: we shouldn't do this if the exponent is large... - - FloatComplexMatrix atmp; - if (btmp < 0) - { - btmp = -btmp; - - octave_idx_type info; - float rcond = 0.0; - MatrixType mattype (a); - - atmp = a.inverse (mattype, info, rcond, 1); - - if (info == -1) - warning ("inverse: matrix singular to machine\ - precision, rcond = %g", rcond); - } - else - atmp = a; - - FloatComplexMatrix result (atmp); - - btmp--; - - while (btmp > 0) - { - if (btmp & 1) - result = result * atmp; - - btmp >>= 1; - - if (btmp > 0) - atmp = atmp * atmp; - } - - retval = result; - } + retval = FloatDiagMatrix (nr, nr, 1.0); } else { - FloatEIG a_eig (a); - - try + // Too much copying? + // FIXME: we shouldn't do this if the exponent is large... + + FloatComplexMatrix atmp; + if (btmp < 0) { - FloatComplexColumnVector lambda (a_eig.eigenvalues ()); - FloatComplexMatrix Q (a_eig.eigenvectors ()); - - for (octave_idx_type i = 0; i < nr; i++) - lambda(i) = std::pow (lambda(i), b); - - FloatComplexDiagMatrix D (lambda); - - retval = FloatComplexMatrix (Q * D * Q.inverse ()); + btmp = -btmp; + + octave_idx_type info; + float rcond = 0.0; + MatrixType mattype (a); + + atmp = a.inverse (mattype, info, rcond, 1); + + if (info == -1) + warning ("inverse: matrix singular to machine\ +precision, rcond = %g", rcond); } - catch (const octave_execution_exception&) + else + atmp = a; + + FloatComplexMatrix result (atmp); + + btmp--; + + while (btmp > 0) { - gripe_failed_diagonalization (); + if (btmp & 1) + result = result * atmp; + + btmp >>= 1; + + if (btmp > 0) + atmp = atmp * atmp; } + + retval = result; } } - - return retval; -} - -// -*- 12 -*- -octave_value -xpow (const FloatComplexMatrix& a, const FloatComplex& b) -{ - octave_value retval; - - octave_idx_type nr = a.rows (); - octave_idx_type nc = a.cols (); - - if (nr == 0 || nc == 0 || nr != nc) - error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); else { FloatEIG a_eig (a); @@ -2015,6 +1943,40 @@ return retval; } +// -*- 12 -*- +octave_value +xpow (const FloatComplexMatrix& a, const FloatComplex& b) +{ + octave_value retval; + + octave_idx_type nr = a.rows (); + octave_idx_type nc = a.cols (); + + if (nr == 0 || nc == 0 || nr != nc) + error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); + + FloatEIG a_eig (a); + + try + { + FloatComplexColumnVector lambda (a_eig.eigenvalues ()); + FloatComplexMatrix Q (a_eig.eigenvectors ()); + + for (octave_idx_type i = 0; i < nr; i++) + lambda(i) = std::pow (lambda(i), b); + + FloatComplexDiagMatrix D (lambda); + + retval = FloatComplexMatrix (Q * D * Q.inverse ()); + } + catch (const octave_execution_exception&) + { + gripe_failed_diagonalization (); + } + + return retval; +} + // -*- 12d -*- octave_value xpow (const FloatComplexDiagMatrix& a, const FloatComplex& b) @@ -2026,13 +1988,11 @@ if (nr == 0 || nc == 0 || nr != nc) error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); - else - { - FloatComplexDiagMatrix r (nr, nc); - for (octave_idx_type i = 0; i < nc; i++) - r(i, i) = std::pow (a(i, i), b); - retval = r; - } + + FloatComplexDiagMatrix r (nr, nc); + for (octave_idx_type i = 0; i < nc; i++) + r(i, i) = std::pow (a(i, i), b); + retval = r; return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/dldfcn/audiodevinfo.cc --- a/libinterp/dldfcn/audiodevinfo.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/dldfcn/audiodevinfo.cc Wed Jan 13 11:02:22 2016 -0800 @@ -2168,9 +2168,8 @@ if (is_function) error ("audioplayer: callbacks not yet implemented"); - else - recorder->set_y (args(0)); - + + recorder->set_y (args(0)); recorder->set_fs (args(1).int_value ()); switch (nargin) diff -r 221847e5f488 -r 5e00ed38a58b libinterp/dldfcn/ccolamd.cc --- a/libinterp/dldfcn/ccolamd.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/dldfcn/ccolamd.cc Wed Jan 13 11:02:22 2016 -0800 @@ -280,15 +280,14 @@ if (cslen != n_col) error ("ccolamd: CMEMBER must be of length equal to #cols of A"); - else - // Order the columns (destroys A) - if (! CCOLAMD_NAME () (n_row, n_col, Alen, A, p, - knobs, stats, cmember)) - { - CCOLAMD_NAME (_report) (stats) ; - error ("ccolamd: internal error!"); - } + // Order the columns (destroys A) + if (! CCOLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats, cmember)) + { + CCOLAMD_NAME (_report) (stats) ; + + error ("ccolamd: internal error!"); + } } else { @@ -513,8 +512,9 @@ if (cslen != n_col) error ("csymamd: CMEMBER must be of length equal to #cols of A"); - else if (! CSYMAMD_NAME () (n_col, ridx, cidx, perm, knobs, stats, - &calloc, &free, cmember, -1)) + + if (! CSYMAMD_NAME () (n_col, ridx, cidx, perm, knobs, stats, + &calloc, &free, cmember, -1)) { CSYMAMD_NAME (_report) (stats) ; diff -r 221847e5f488 -r 5e00ed38a58b libinterp/octave-value/ov-builtin.cc --- a/libinterp/octave-value/ov-builtin.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/octave-value/ov-builtin.cc Wed Jan 13 11:02:22 2016 -0800 @@ -107,37 +107,35 @@ if (args.has_magic_colon ()) error ("invalid use of colon in function argument list"); - else - { - unwind_protect frame; + + unwind_protect frame; - octave_call_stack::push (this); + octave_call_stack::push (this); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave_call_stack::pop); - if (lvalue_list || curr_lvalue_list) - { - frame.protect_var (curr_lvalue_list); - curr_lvalue_list = lvalue_list; - } + if (lvalue_list || curr_lvalue_list) + { + frame.protect_var (curr_lvalue_list); + curr_lvalue_list = lvalue_list; + } - BEGIN_PROFILER_BLOCK (octave_builtin) + BEGIN_PROFILER_BLOCK (octave_builtin) - retval = (*f) (args, nargout); - // Do not allow null values to be returned from functions. - // FIXME: perhaps true builtins should be allowed? - retval.make_storable_values (); - // Fix the case of a single undefined value. - // This happens when a compiled function uses - // octave_value retval; - // instead of - // octave_value_list retval; - // the idiom is very common, so we solve that here. - if (retval.length () == 1 && retval.xelem (0).is_undefined ()) - retval.clear (); + retval = (*f) (args, nargout); + // Do not allow null values to be returned from functions. + // FIXME: perhaps true builtins should be allowed? + retval.make_storable_values (); + // Fix the case of a single undefined value. + // This happens when a compiled function uses + // octave_value retval; + // instead of + // octave_value_list retval; + // the idiom is very common, so we solve that here. + if (retval.length () == 1 && retval.xelem (0).is_undefined ()) + retval.clear (); - END_PROFILER_BLOCK - } + END_PROFILER_BLOCK return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/octave-value/ov-classdef.cc Wed Jan 13 11:02:22 2016 -0800 @@ -1167,8 +1167,8 @@ cname.c_str (), ctx.get_name ().c_str ()); if (! is_constructed_object (mname)) - error ("cannot call superclass constructor with " - "variable `%s'", mname.c_str ()); + error ("cannot call superclass constructor with variable `%s'", + mname.c_str ()); octave_value sym = symbol_table::varval (mname); @@ -1674,16 +1674,15 @@ is_scalar = is_scalar && iv(i).is_scalar (); if (! is_scalar) - error ("subsasgn: invalid indexing for object array " - "assignment, the index must reference a single " - "object in the array."); + error ("subsasgn: invalid indexing for object array assignment" + ", the index must reference a single object in the " + "array."); } Array a = array.index (iv, true); if (a.numel () != 1) - error ("subsasgn: invalid indexing for object array " - "assignment"); + error ("subsasgn: invalid indexing for object array assignment"); cdef_object obj = a(0); @@ -1713,8 +1712,8 @@ if (! robj.ok () || robj.is_array () || robj.get_class () != get_class ()) - error ("subasgn: invalid assignment into array of %s " - "objects", class_name ().c_str ()); + error ("subasgn: invalid assignment into array of %s objects", + class_name ().c_str ()); // Small optimization, when dealing with handle // objects, we don't need to re-assign the result diff -r 221847e5f488 -r 5e00ed38a58b libinterp/octave-value/ov-intx.h --- a/libinterp/octave-value/ov-intx.h Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/octave-value/ov-intx.h Wed Jan 13 11:02:22 2016 -0800 @@ -146,14 +146,13 @@ dim_vector dv = dims (); if (dv.length () > 2) error ("invalid conversion of %s to Matrix", type_name ().c_str ()); - else - { - retval = Matrix (dv(0), dv(1)); - double *vec = retval.fortran_vec (); - octave_idx_type nel = matrix.numel (); - for (octave_idx_type i = 0; i < nel; i++) - vec[i] = matrix(i).double_value (); - } + + retval = Matrix (dv(0), dv(1)); + double *vec = retval.fortran_vec (); + octave_idx_type nel = matrix.numel (); + for (octave_idx_type i = 0; i < nel; i++) + vec[i] = matrix(i).double_value (); + return retval; } @@ -164,14 +163,13 @@ dim_vector dv = dims (); if (dv.length () > 2) error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ()); - else - { - retval = FloatMatrix (dv(0), dv(1)); - float *vec = retval.fortran_vec (); - octave_idx_type nel = matrix.numel (); - for (octave_idx_type i = 0; i < nel; i++) - vec[i] = matrix(i).float_value (); - } + + retval = FloatMatrix (dv(0), dv(1)); + float *vec = retval.fortran_vec (); + octave_idx_type nel = matrix.numel (); + for (octave_idx_type i = 0; i < nel; i++) + vec[i] = matrix(i).float_value (); + return retval; } @@ -182,14 +180,13 @@ dim_vector dv = dims (); if (dv.length () > 2) error ("invalid conversion of %s to Matrix", type_name ().c_str ()); - else - { - retval = ComplexMatrix (dv(0), dv(1)); - Complex *vec = retval.fortran_vec (); - octave_idx_type nel = matrix.numel (); - for (octave_idx_type i = 0; i < nel; i++) - vec[i] = Complex (matrix(i).double_value ()); - } + + retval = ComplexMatrix (dv(0), dv(1)); + Complex *vec = retval.fortran_vec (); + octave_idx_type nel = matrix.numel (); + for (octave_idx_type i = 0; i < nel; i++) + vec[i] = Complex (matrix(i).double_value ()); + return retval; } @@ -200,14 +197,13 @@ dim_vector dv = dims (); if (dv.length () > 2) error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ()); - else - { - retval = FloatComplexMatrix (dv(0), dv(1)); - FloatComplex *vec = retval.fortran_vec (); - octave_idx_type nel = matrix.numel (); - for (octave_idx_type i = 0; i < nel; i++) - vec[i] = FloatComplex (matrix(i).float_value ()); - } + + retval = FloatComplexMatrix (dv(0), dv(1)); + FloatComplex *vec = retval.fortran_vec (); + octave_idx_type nel = matrix.numel (); + for (octave_idx_type i = 0; i < nel; i++) + vec[i] = FloatComplex (matrix(i).float_value ()); + return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/octave-value/ov-lazy-idx.cc --- a/libinterp/octave-value/ov-lazy-idx.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/octave-value/ov-lazy-idx.cc Wed Jan 13 11:02:22 2016 -0800 @@ -169,11 +169,10 @@ bool dummy; std::string nm = read_text_data (is, "", dummy, value, 0); - if (nm != value_save_tag) error ("lazy_index: corrupted data on load"); - else - index = value.index_vector (); + + index = value.index_vector (); return true; } @@ -191,13 +190,11 @@ bool dummy; std::string doc; - std::string nm = read_binary_data (is, swap, fmt, "", - dummy, value, doc); - + std::string nm = read_binary_data (is, swap, fmt, "", dummy, value, doc); if (nm != value_save_tag) error ("lazy_index: corrupted data on load"); - else - index = value.index_vector (); + + index = value.index_vector (); return true; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/octave-value/ov-mex-fcn.cc --- a/libinterp/octave-value/ov-mex-fcn.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/octave-value/ov-mex-fcn.cc Wed Jan 13 11:02:22 2016 -0800 @@ -134,20 +134,18 @@ if (args.has_magic_colon ()) error ("invalid use of colon in function argument list"); - else - { - unwind_protect frame; - octave_call_stack::push (this); + unwind_protect frame; + + octave_call_stack::push (this); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave_call_stack::pop); - BEGIN_PROFILER_BLOCK (octave_mex_function) + BEGIN_PROFILER_BLOCK (octave_mex_function) - retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); + retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); - END_PROFILER_BLOCK - } + END_PROFILER_BLOCK return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/operators/op-int.h --- a/libinterp/operators/op-int.h Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/operators/op-int.h Wed Jan 13 11:02:22 2016 -0800 @@ -629,8 +629,8 @@ \ if (v.ndims () > 2) \ error ("transpose not defined for N-D objects"); \ - else \ - return octave_value (v.TYPE ## _array_value ().transpose ()); \ + \ + return octave_value (v.TYPE ## _array_value ().transpose ()); \ } \ \ DEFNCUNOP_METHOD (m_incr, TYPE ## _matrix, increment) \ diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/lex.ll Wed Jan 13 11:02:22 2016 -0800 @@ -1730,6 +1730,7 @@ undo_string_escape (static_cast (c)), c, curr_lexer->input_line_number, curr_lexer->current_input_column); + // FIXME: This is no longer reachable now that error is exception based. return LEXICAL_ERROR; } } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/oct-parse.in.yy Wed Jan 13 11:02:22 2016 -0800 @@ -3740,9 +3740,9 @@ { retval = false; if (e->is_matrix ()) - bison_error ("invalid use of tilde (~) in matrix expression"); - else - bison_error ("invalid use of tilde (~) in cell expression"); + bison_error ("invalid use of tilde (~) in matrix expression"); + else + bison_error ("invalid use of tilde (~) in cell expression"); break; } } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/pt-binop.cc --- a/libinterp/parse-tree/pt-binop.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/pt-binop.cc Wed Jan 13 11:02:22 2016 -0800 @@ -47,9 +47,9 @@ if (nargout > 1) error ("binary operator '%s': invalid number of output arguments", - oper () . c_str ()); - else - retval = rvalue1 (nargout); + oper ().c_str ()); + + retval = rvalue1 (nargout); return retval; } @@ -177,9 +177,9 @@ if (nargout > 1) error ("binary operator '%s': invalid number of output arguments", - oper () . c_str ()); - else - retval = rvalue1 (nargout); + oper ().c_str ()); + + retval = rvalue1 (nargout); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/pt-cbinop.cc --- a/libinterp/parse-tree/pt-cbinop.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/pt-cbinop.cc Wed Jan 13 11:02:22 2016 -0800 @@ -39,9 +39,9 @@ if (nargout > 1) error ("binary operator '%s': invalid number of output arguments", - oper () . c_str ()); - else - retval = rvalue1 (nargout); + oper ().c_str ()); + + retval = rvalue1 (nargout); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/pt-const.cc --- a/libinterp/parse-tree/pt-const.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/pt-const.cc Wed Jan 13 11:02:22 2016 -0800 @@ -62,8 +62,8 @@ if (nargout > 1) error ("invalid number of output arguments for constant expression"); - else - retval = rvalue1 (nargout); + + retval = rvalue1 (nargout); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/pt-decl.h --- a/libinterp/parse-tree/pt-decl.h Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/pt-decl.h Wed Jan 13 11:02:22 2016 -0800 @@ -74,8 +74,8 @@ if (nargout > 1) error ("invalid number of output arguments in declaration list"); - else - retval = rvalue1 (nargout); + + retval = rvalue1 (nargout); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/pt-fcn-handle.cc --- a/libinterp/parse-tree/pt-fcn-handle.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/pt-fcn-handle.cc Wed Jan 13 11:02:22 2016 -0800 @@ -62,8 +62,8 @@ if (nargout > 1) error ("invalid number of output arguments for function handle expression"); - else - retval = rvalue1 (nargout); + + retval = rvalue1 (nargout); return retval; } @@ -181,8 +181,8 @@ if (nargout > 1) error ("invalid number of output arguments for anonymous function handle expression"); - else - retval = rvalue1 (nargout); + + retval = rvalue1 (nargout); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b libinterp/parse-tree/pt-unop.cc --- a/libinterp/parse-tree/pt-unop.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/libinterp/parse-tree/pt-unop.cc Wed Jan 13 11:02:22 2016 -0800 @@ -50,9 +50,9 @@ if (nargout > 1) error ("prefix operator '%s': invalid number of output arguments", - oper () . c_str ()); - else - retval = rvalue1 (nargout); + oper ().c_str ()); + + retval = rvalue1 (nargout); return retval; } @@ -127,9 +127,9 @@ if (nargout > 1) error ("postfix operator '%s': invalid number of output arguments", - oper () . c_str ()); - else - retval = rvalue1 (nargout); + oper ().c_str ()); + + retval = rvalue1 (nargout); return retval; } diff -r 221847e5f488 -r 5e00ed38a58b liboctave/numeric/CollocWt.cc --- a/liboctave/numeric/CollocWt.cc Tue Jan 12 21:45:58 2016 +0100 +++ b/liboctave/numeric/CollocWt.cc Wed Jan 13 11:02:22 2016 -0800 @@ -382,10 +382,7 @@ CollocWt::set_left (double val) { if (val >= rb) - { - error ("CollocWt: left bound greater than right bound"); - return *this; - } + error ("CollocWt: left bound greater than right bound"); lb = val; initialized = 0; @@ -396,10 +393,7 @@ CollocWt::set_right (double val) { if (val <= lb) - { - error ("CollocWt: right bound less than left bound"); - return *this; - } + error ("CollocWt: right bound less than left bound"); rb = val; initialized = 0; @@ -421,10 +415,7 @@ octave_idx_type nt = n + inc_left + inc_right; if (nt < 0) - { - error ("CollocWt: total number of collocation points less than zero"); - return; - } + error ("CollocWt: total number of collocation points less than zero"); else if (nt == 0) return;