Overview
Comment: | Declared more function arguments to be "const" - improves compiler optimisation. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7489dd518c7b55b1c9163fd88d98f761 |
User & Date: | geraint@users.sourceforge.net on 2002-07-11 13:00:23 |
Other Links: | branch diff | manifest | tags |
Context
2002-07-11
| ||
20:46:37 | Added multiplot feature allowing graphs to be overlaid. check-in: 66b3b0123f user: geraint@users.sourceforge.net tags: origin/master, trunk | |
13:00:23 | Declared more function arguments to be "const" - improves compiler optimisation. check-in: 7489dd518c user: geraint@users.sourceforge.net tags: origin/master, trunk | |
2002-07-10
| ||
17:43:05 | Added feature [ 562453 ] Optimisation of algebraic equations. check-in: 73ae553333 user: geraint@users.sourceforge.net tags: origin/master, trunk | |
Changes
Modified mttroot/mtt/bin/trans/make_ode2odes from [fa0297c797] to [f776f6771d].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #! /bin/sh ###################################### ##### Model Transformation Tools ##### ###################################### ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.79 2002/05/20 13:42:31 gawthrop ## Uses simpar.first for first printed output ## ## Revision 1.78 2002/05/11 01:14:17 geraint ## Fix for [ 553218 ] simpar.oct and simpar.m different. ## Translation added between ColumnVector in base .cc and Octave_map in .oct. ## | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #! /bin/sh ###################################### ##### Model Transformation Tools ##### ###################################### ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.80 2002/05/22 09:35:49 geraint ## Added insertor variable to stop sh-mode font-lock from getting hopelessly confused by embedded C++. ## ## Revision 1.79 2002/05/20 13:42:31 gawthrop ## Uses simpar.first for first printed output ## ## Revision 1.78 2002/05/11 01:14:17 geraint ## Fix for [ 553218 ] simpar.oct and simpar.m different. ## Translation added between ColumnVector in base .cc and Octave_map in .oct. ## |
︙ | ︙ | |||
476 477 478 479 480 481 482 | #include "mtt_${algebraic_solver}.hh" #include <fstream> #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) extern ColumnVector ${sys}_ae ( | | | | | | | | | | | | | | | | | | | | | | | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | #include "mtt_${algebraic_solver}.hh" #include <fstream> #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) extern ColumnVector ${sys}_ae ( const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); extern ColumnVector ${sys}_input ( const ColumnVector &x, const ColumnVector &y, const double &t, const ColumnVector &par); extern ColumnVector ${sys}_logic ( const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); extern ColumnVector ${sys}_numpar ( void); extern ColumnVector ${sys}_simpar ( void); extern ColumnVector ${sys}_state ( const ColumnVector &par); extern ColumnVector ${sys}_${ode} ( const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); extern ColumnVector ${sys}_${odeo} ( const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); EOF case "$method" in "implicit") cat <<EOF >> $filename extern ColumnVector Fmtt_implicit ( ColumnVector &x, ColumnVector &dx, Matrix &AA, ColumnVector &AAx, const double &ddt, const int &nx, const ColumnVector &open_switches); extern Matrix ${sys}_smxa ( const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); extern ColumnVector ${sys}_smxax ( const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); EOF ;; "dassl") cat <<EOF >> $filename extern ColumnVector Fmtt_dassl ( ColumnVector &x, |
︙ | ︙ | |||
573 574 575 576 577 578 579 | ;; esac cat <<EOF >> $filename #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) ColumnVector | | | | | | | | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | ;; esac cat <<EOF >> $filename #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) ColumnVector mtt_ae (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_ae(x,u,t,par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_ae", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline ColumnVector mtt_input (const ColumnVector &x, const ColumnVector &y, const double &t, const ColumnVector &par) { static MTT::${algebraic_solver} ae(MTTNPAR,MTTNU,MTTNX,MTTNY,MTTNYZ); static ColumnVector u (MTTNU); #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) u = ${sys}_input (x, y, t, par); #elif (CODEGENTARGET == OCTAVEDLD) |
︙ | ︙ | |||
622 623 624 625 626 627 628 | else { return ae.solve(x,u,t,par); } } inline ColumnVector | | | | | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | else { return ae.solve(x,u,t,par); } } inline ColumnVector mtt_logic (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_logic (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); |
︙ | ︙ | |||
665 666 667 668 669 670 671 | static octave_value_list args, f; f = feval ("${sys}_simpar", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline ColumnVector | | | | | | | | | | 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | static octave_value_list args, f; f = feval ("${sys}_simpar", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline ColumnVector mtt_state (const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_state (par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (par); f = feval ("${sys}_state", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline ColumnVector mtt_rate (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_${ode} (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_${ode}", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline ColumnVector mtt_output (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_${odeo} (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); |
︙ | ︙ | |||
745 746 747 748 749 750 751 | args (6) = octave_value (open_switches); f = feval ("mtt_implicit", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline Matrix | | | | | | | | 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | args (6) = octave_value (open_switches); f = feval ("mtt_implicit", args, 1); return f(0).${vector_value} (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline Matrix mtt_smxa (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_smxa (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); args (2) = octave_value (t); args (3) = octave_value (par); f = feval ("${sys}_smxa", args, 1); return f(0).matrix_value (); #endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) } inline ColumnVector mtt_smxax (const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par) { #if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX)) return ${sys}_smxax (x, u, t, par); #elif (CODEGENTARGET == OCTAVEDLD) static octave_value_list args, f; args (0) = octave_value (x); args (1) = octave_value (u); |
︙ | ︙ | |||
941 942 943 944 945 946 947 | EOF ;; esac cat <<EOF >> $filename inline void mtt_write (const double &t, | | | | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 | EOF ;; esac cat <<EOF >> $filename inline void mtt_write (const double &t, const ColumnVector &x, const ColumnVector &y, const double &first, const int &nrows, const bool dump_data = false, std::ostream &file = std::cout) { static Matrix data; static int row; |
︙ | ︙ | |||
1010 1011 1012 1013 1014 1015 1016 | #endif // (CODEGENTARGET == STANDALONE) row = 0; fcputime.close(); } } void | > | > | 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | #endif // (CODEGENTARGET == STANDALONE) row = 0; fcputime.close(); } } void ${sys}_ode2odes (const ColumnVector &state0, const ColumnVector &numpar, const ColumnVector &simpar) { static double first, dt, last, stepfactor; first = simpar (0); last = simpar (1); dt = simpar (2); stepfactor = simpar (3); |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/mtt_header from [a3ab0a20ce] to [0c3e517ae2].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Copyright (C) 2000 by Peter J. Gawthrop ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.52 2002/05/27 14:52:15 geraint ## Parameters in sfun reps are now declared using sympar.h at the top of the ## sfun*.c file instead of in individual functions. This causes the optimisation ## variables (mtt_tmp*) to be declared correctly without causing conflicts in the ## scope of parameter declarations. ## ## Revision 1.51 2002/05/19 13:01:21 geraint | > > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Copyright (C) 2000 by Peter J. Gawthrop ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.53 2002/06/10 23:22:16 geraint ## Fixed problem with Matlab fsolve failing because of "user function returned Inf or Nan" (fsolve.m, line 245). ## ## Revision 1.52 2002/05/27 14:52:15 geraint ## Parameters in sfun reps are now declared using sympar.h at the top of the ## sfun*.c file instead of in individual functions. This causes the optimisation ## variables (mtt_tmp*) to be declared correctly without causing conflicts in the ## scope of parameter declarations. ## ## Revision 1.51 2002/05/19 13:01:21 geraint |
︙ | ︙ | |||
730 731 732 733 734 735 736 | arg_init="(MTTNYZ,0.0)" ;; mtty) arg_type="ColumnVector" arg_init="(MTTNY,0.0)" ;; mttt) | | | 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | arg_init="(MTTNYZ,0.0)" ;; mtty) arg_type="ColumnVector" arg_init="(MTTNY,0.0)" ;; mttt) arg_type="double" arg_init="" ;; nil) arg_type="void *" arg_init="(0x0)" ;; *) |
︙ | ︙ | |||
828 829 830 831 832 833 834 | if [ ${i} -lt ${c} ]; then comma="," else comma="" fi w=`get_field ${args} ${i}` get_arg_specific_stuff ${w} | | | 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | if [ ${i} -lt ${c} ]; then comma="," else comma="" fi w=`get_field ${args} ${i}` get_arg_specific_stuff ${w} printf "\tconst ${arg_type}\t&${w}${comma}\n" done fi get_arg_specific_stuff ${output} cat <<EOF ) { static ${arg_type} ${output} ${arg_init}; |
︙ | ︙ | |||
866 867 868 869 870 871 872 | printf " if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n" while [ ${i} -lt ${c} ]; do j=${i} i=`expr ${i} + 1` w=`get_field ${s} ${i}` # argument name get_arg_specific_stuff ${w} case ${arg_type} in | | | | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | printf " if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n" while [ ${i} -lt ${c} ]; do j=${i} i=`expr ${i} + 1` w=`get_field ${s} ${i}` # argument name get_arg_specific_stuff ${w} case ${arg_type} in "double") printf " const ${arg_type}\t${w}\t= args(${j}).double_value ();\n" ;; ColumnVector | Matrix | *) printf " const ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value} ;; esac done } map_mex_cc_inputs () { |
︙ | ︙ |
Modified mttroot/mtt/lib/cc/mtt_AlgebraicSolver.hh from [6b5fc39cda] to [83ec09b7aa].
︙ | ︙ | |||
36 37 38 39 40 41 42 | virtual void Solve (void) = 0; }; } extern ColumnVector | | | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | virtual void Solve (void) = 0; }; } extern ColumnVector mtt_ae(const ColumnVector &x, const ColumnVector &u, const double &t, const ColumnVector &par); #endif // MTT_ALGEBRAICSOLVER |