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: 7489dd518c7b55b1c9163fd88d98f7610c12212898646ec1bf0be25808206a3c
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
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
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
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 (
	ColumnVector &x,
	ColumnVector &u,
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par);
	const ColumnVector &par);

extern ColumnVector ${sys}_input (
	ColumnVector &x,
	ColumnVector &y,
	const ColumnVector &x,
	const ColumnVector &y,
	const double &t,
	ColumnVector &par);
	const ColumnVector &par);

extern ColumnVector ${sys}_logic (
	ColumnVector &x,
	ColumnVector &u,
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par);
	const ColumnVector &par);

extern ColumnVector ${sys}_numpar (
	void);

extern ColumnVector ${sys}_simpar (
     	void);

extern ColumnVector ${sys}_state (
	ColumnVector &par);
	const ColumnVector &par);

extern ColumnVector ${sys}_${ode} (
	ColumnVector &x,
	ColumnVector &u,
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par);
	const ColumnVector &par);

extern ColumnVector ${sys}_${odeo} (
	ColumnVector &x,
	ColumnVector &u,
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par);
	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 (
	ColumnVector &x,
	ColumnVector &u,
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par);
	const ColumnVector &par);

extern ColumnVector ${sys}_smxax (
	ColumnVector &x,
	ColumnVector &u,
	const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par);
	const ColumnVector &par);
 
EOF
    ;;
    "dassl")
	cat <<EOF >> $filename
extern ColumnVector Fmtt_dassl (
	ColumnVector &x,
573
574
575
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
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 (ColumnVector &x,
	ColumnVector &u,
mtt_ae (const ColumnVector &x,
	const ColumnVector &u,
	const double &t,
	ColumnVector &par)
	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 (ColumnVector &x,
	   ColumnVector &y,
mtt_input (const ColumnVector &x,
	   const ColumnVector &y,
	   const double &t,
	   ColumnVector &par)
	   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
629
630


631
632

633
634
635
636
637
638
639
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 (ColumnVector &x,
	   ColumnVector &u,
mtt_logic (const ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
	   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
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
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 (ColumnVector &par)
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 (ColumnVector &x,
	  ColumnVector &u,
mtt_rate (const ColumnVector &x,
	  const ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
	  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 (ColumnVector &x,
	     ColumnVector &u,
	     const double &t,
	     ColumnVector &par)
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
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
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 (ColumnVector &x,
	  ColumnVector &u,
mtt_smxa (const ColumnVector &x,
	  const ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
	  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 (ColumnVector &x,
	   ColumnVector &u,
mtt_smxax (const ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
	   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
948
949


950
951
952
953
954
955
956
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,
	   ColumnVector &x,
	   ColumnVector &y,
	   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

1017


1018
1019
1020
1021
1022
1023
1024
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,
${sys}_ode2odes (ColumnVector &state0, ColumnVector &numpar, ColumnVector &simpar)
		 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
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
737

738
739
740
741
742
743
744
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="const double"
	    arg_type="double"
	    arg_init=""
	    ;;
	nil)
	    arg_type="void *"
	    arg_init="(0x0)"
	    ;;
	*)
828
829
830
831
832
833
834
835

836
837
838
839
840
841
842
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 "\t${arg_type}\t&${w}${comma}\n"
	    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
873
874


875
876
877

878
879
880
881
882
883
884
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
	    "const double")
		printf "  ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
	    "double")
		printf "  const ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
		;;
	    ColumnVector | Matrix | *)
		printf "  ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
		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
43
44
45
46




47
48
49
36
37
38
39
40
41
42




43
44
45
46
47
48
49







-
-
-
-
+
+
+
+



    virtual void
    Solve (void) = 0;
  };
}


extern ColumnVector
mtt_ae(ColumnVector	&x,
       ColumnVector	&u,
       const double	&t,
       ColumnVector	&par);
mtt_ae(const ColumnVector	&x,
       const ColumnVector	&u,
       const double		&t,
       const ColumnVector	&par);


#endif // MTT_ALGEBRAICSOLVER


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]