comparison src/DLD-FUNCTIONS/lsode.cc @ 7562:c827f5673321

move tests to individual source files
author John W. Eaton <jwe@octave.org>
date Thu, 06 Mar 2008 02:27:55 -0500
parents a1dbe9d80eee
children 81d6ab3ac93c
comparison
equal deleted inserted replaced
7561:a938cd7869b2 7562:c827f5673321
473 473
474 return retval; 474 return retval;
475 } 475 }
476 476
477 /* 477 /*
478
479 %% dassl-1.m
480 %%
481 %% Test lsode() function
482 %%
483 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
484 %% Comalco Research and Technology
485 %% 20 May 1998
486 %%
487 %% Problem
488 %%
489 %% y1' = -y2, y1(0) = 1
490 %% y2' = y1, y2(0) = 0
491 %%
492 %% Solution
493 %%
494 %% y1(t) = cos(t)
495 %% y2(t) = sin(t)
496 %!function xdot = f (x, t)
497 %! xdot = [-x(2); x(1)];
498 %!test
499 %!
500 %! x0 = [1; 0];
501 %! xdot0 = [0; 1];
502 %! t = (0:1:10)';
503 %!
504 %! tol = 500 * lsode_options ("relative tolerance");
505 %!
506 %!
507 %! x = lsode ("f", x0, t);
508 %!
509 %! y = [cos(t), sin(t)];
510 %!
511 %! assert(all (all (abs (x - y) < tol)));
512
513 %!function xdotdot = f (x, t)
514 %! xdotdot = [x(2); -x(1)];
515 %!test
516 %!
517 %! x0 = [1; 0];
518 %! t = [0; 2*pi];
519 %! tol = 100 * dassl_options ("relative tolerance");
520 %!
521 %! x = lsode ("f", x0, t);
522 %!
523 %! y = [1, 0; 1, 0];
524 %!
525 %! assert(all (all (abs (x - y) < tol)));
526
527 %!function xdot = f (x, t)
528 %! xdot = x;
529 %!test
530 %!
531 %! x0 = 1;
532 %! t = [0; 1];
533 %! tol = 100 * dassl_options ("relative tolerance");
534 %!
535 %! x = lsode ("f", x0, t);
536 %!
537 %! y = [1; e];
538 %!
539 %! assert(all (all (abs (x - y) < tol)));
540
541 %!test
542 %! lsode_options ("absolute tolerance", eps);
543 %! assert(lsode_options ("absolute tolerance") == eps);
544
545 %!error <Invalid call to lsode_options.*> lsode_options ("foo", 1, 2);
546
547 */
548
549 /*
478 ;;; Local Variables: *** 550 ;;; Local Variables: ***
479 ;;; mode: C++ *** 551 ;;; mode: C++ ***
480 ;;; End: *** 552 ;;; End: ***
481 */ 553 */