comparison liboctave/numeric/DASPK.cc @ 21136:7cac4e7458f2

maint: clean up code around calls to current_liboctave_error_handler. Remove statements after call to handler that are no longer reachable. Place input validation first and immediately call handler if necessary. Change if/error_handler/else to if/error_handler and re-indent code. * Array-util.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MArray.cc, PermMatrix.cc, Sparse.cc, Sparse.h, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc, CmplxQR.cc, CmplxSCHUR.cc, CmplxSVD.cc, DASPK.cc, EIG.cc, LSODE.cc, Quad.cc, SparseCmplxCHOL.cc, SparseCmplxLU.cc, SparseCmplxQR.cc, SparseQR.cc, SparsedbleCHOL.cc, SparsedbleLU.cc, base-lu.cc, bsxfun-defs.cc, dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc, fCmplxCHOL.cc, fCmplxLU.cc, fCmplxQR.cc, fCmplxSCHUR.cc, fEIG.cc, floatAEPBAL.cc, floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc, floatSCHUR.cc, floatSVD.cc, lo-specfun.cc, oct-fftw.cc, oct-rand.cc, oct-spparms.cc, sparse-base-chol.cc, sparse-dmsolve.cc, file-ops.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-syscalls.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, lo-ieee.cc, lo-regexp.cc, oct-base64.cc, oct-shlib.cc, pathsearch.cc, singleton-cleanup.cc, sparse-util.cc, unwind-prot.cc: Remove statements after call to handler that are no longer reachable. Place input validation first and immediately call handler if necessary. Change if/error_handler/else to if/error_handler and re-indent code.
author Rik <rik@octave.org>
date Sat, 23 Jan 2016 13:52:03 -0800
parents 1edf15793cac
children f7121e111991
comparison
equal deleted inserted replaced
21135:95da3bc8a281 21136:7cac4e7458f2
196 196
197 ColumnVector res = (*user_fun) (x, xdot, t, ires); 197 ColumnVector res = (*user_fun) (x, xdot, t, ires);
198 198
199 if (res.numel () != x.numel ()) 199 if (res.numel () != x.numel ())
200 { 200 {
201 // FIXME: Should this be a warning?
201 (*current_liboctave_error_handler) 202 (*current_liboctave_error_handler)
202 ("daspk: inconsistent sizes for state and residual vectors"); 203 ("daspk: inconsistent sizes for state and residual vectors");
203 204
204 integration_error = true; 205 integration_error = true;
205 return retval; 206 return retval;
206 } 207 }
207 } 208 }
208 else 209 else
209 { 210 {
211 // FIXME: Should this be a warning?
210 (*current_liboctave_error_handler) 212 (*current_liboctave_error_handler)
211 ("daspk: no user supplied RHS subroutine!"); 213 ("daspk: no user supplied RHS subroutine!");
212 214
213 integration_error = true; 215 integration_error = true;
214 return retval; 216 return retval;
251 { 253 {
252 info(1) = 1; 254 info(1) = 1;
253 } 255 }
254 else 256 else
255 { 257 {
258
259 // FIXME: Should this be a warning?
256 (*current_liboctave_error_handler) 260 (*current_liboctave_error_handler)
257 ("daspk: inconsistent sizes for tolerance arrays"); 261 ("daspk: inconsistent sizes for tolerance arrays");
258 262
259 integration_error = true; 263 integration_error = true;
260 return retval; 264 return retval;
286 info(8) = 1; 290 info(8) = 1;
287 iwork(2) = maxord; 291 iwork(2) = maxord;
288 } 292 }
289 else 293 else
290 { 294 {
295 // FIXME: Should this be a warning?
291 (*current_liboctave_error_handler) 296 (*current_liboctave_error_handler)
292 ("daspk: invalid value for maximum order"); 297 ("daspk: invalid value for maximum order");
293 integration_error = true; 298 integration_error = true;
294 return retval; 299 return retval;
295 } 300 }
307 for (octave_idx_type i = 0; i < n; i++) 312 for (octave_idx_type i = 0; i < n; i++)
308 { 313 {
309 octave_idx_type val = ict(i); 314 octave_idx_type val = ict(i);
310 if (val < -2 || val > 2) 315 if (val < -2 || val > 2)
311 { 316 {
317 // FIXME: Should this be a warning?
312 (*current_liboctave_error_handler) 318 (*current_liboctave_error_handler)
313 ("daspk: invalid value for inequality constraint type"); 319 ("daspk: invalid value for inequality constraint type");
314 integration_error = true; 320 integration_error = true;
315 return retval; 321 return retval;
316 } 322 }
317 iwork(40+i) = val; 323 iwork(40+i) = val;
318 } 324 }
319 } 325 }
320 else 326 else
321 { 327 {
328 // FIXME: Should this be a warning?
322 (*current_liboctave_error_handler) 329 (*current_liboctave_error_handler)
323 ("daspk: inequality constraint types size mismatch"); 330 ("daspk: inequality constraint types size mismatch");
324 integration_error = true; 331 integration_error = true;
325 return retval; 332 return retval;
326 } 333 }
331 case 2: 338 case 2:
332 info(9) = eiq; 339 info(9) = eiq;
333 break; 340 break;
334 341
335 default: 342 default:
343 // FIXME: Should this be a warning?
336 (*current_liboctave_error_handler) 344 (*current_liboctave_error_handler)
337 ("daspk: invalid value for enforce inequality constraints option"); 345 ("daspk: invalid value for enforce inequality constraints option");
338 integration_error = true; 346 integration_error = true;
339 return retval; 347 return retval;
340 } 348 }
360 for (octave_idx_type i = 0; i < n; i++) 368 for (octave_idx_type i = 0; i < n; i++)
361 iwork(lid+i) = av(i) ? -1 : 1; 369 iwork(lid+i) = av(i) ? -1 : 1;
362 } 370 }
363 else 371 else
364 { 372 {
373 // FIXME: Should this be a warning?
365 (*current_liboctave_error_handler) 374 (*current_liboctave_error_handler)
366 ("daspk: algebraic variables size mismatch"); 375 ("daspk: algebraic variables size mismatch");
367 integration_error = true; 376 integration_error = true;
368 return retval; 377 return retval;
369 } 378 }
370 } 379 }
371 else if (ccic != 2) 380 else if (ccic != 2)
372 { 381 {
382 // FIXME: Should this be a warning?
373 (*current_liboctave_error_handler) 383 (*current_liboctave_error_handler)
374 ("daspk: invalid value for compute consistent initial condition option"); 384 ("daspk: invalid value for compute consistent initial condition option");
375 integration_error = true; 385 integration_error = true;
376 return retval; 386 return retval;
377 } 387 }
416 rwork(13) = ich(4); 426 rwork(13) = ich(4);
417 rwork(14) = ich(5); 427 rwork(14) = ich(5);
418 } 428 }
419 else 429 else
420 { 430 {
431 // FIXME: Should this be a warning?
421 (*current_liboctave_error_handler) 432 (*current_liboctave_error_handler)
422 ("daspk: invalid initial condition heuristics option"); 433 ("daspk: invalid initial condition heuristics option");
423 integration_error = true; 434 integration_error = true;
424 return retval; 435 return retval;
425 } 436 }
435 case 2: 446 case 2:
436 info(17) = pici; 447 info(17) = pici;
437 break; 448 break;
438 449
439 default: 450 default:
451 // FIXME: Should this be a warning?
440 (*current_liboctave_error_handler) 452 (*current_liboctave_error_handler)
441 ("daspk: invalid value for print initial condition info option"); 453 ("daspk: invalid value for print initial condition info option");
442 integration_error = true; 454 integration_error = true;
443 return retval; 455 return retval;
444 break; 456 break;
516 break; 528 break;
517 529
518 default: 530 default:
519 integration_error = true; 531 integration_error = true;
520 (*current_liboctave_error_handler) 532 (*current_liboctave_error_handler)
521 ("unrecognized value of istate (= %d) returned from ddaspk", 533 ("unrecognized value of istate (= %d) returned from ddaspk", istate);
522 istate);
523 break; 534 break;
524 } 535 }
525 536
526 return retval; 537 return retval;
527 } 538 }