Overview
Comment:Added mex support for ode2odes: mtt sys ode2odes mexglx.
This mex stuff seems to require octave2.1-headers.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 20ae5bf7e06cdb4dd9992b3a14170e757e0bf366509742b927cab907d4f1780d
User & Date: geraint@users.sourceforge.net on 2002-05-08 16:03:32
Other Links: branch diff | manifest | tags
Context
2002-05-08
21:32:26
Tidied up $1_ode2odes_*.* targets and renamed dummies as *.stamp. check-in: dc8f84a4a1 user: geraint@users.sourceforge.net tags: origin/master, trunk
16:03:32
Added mex support for ode2odes: mtt sys ode2odes mexglx.
This mex stuff seems to require octave2.1-headers.
check-in: 20ae5bf7e0 user: geraint@users.sourceforge.net tags: origin/master, trunk
14:51:04
Moved matlab/octave data type conversion functions to a separate file. check-in: cdb81663cf user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/mtt from [570aa6b93c] to [7e8ccc92a7].

13
14
15
16
17
18
19



20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+







# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.337  2002/05/08 14:51:03  geraint
## Moved matlab/octave data type conversion functions to a separate file.
##
## Revision 1.336  2002/05/07 23:50:34  geraint
## Preliminary support for Matlab dynamically linked shared objects:
## invoke with: mtt -cc sys rep mexglx
## ode2odes support is not yet included.
##
## Revision 1.335  2002/05/01 17:30:55  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
2791
2792
2793
2794
2795
2796
2797








2798
2799
2800
2801
2802
2803
2804
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815







+
+
+
+
+
+
+
+







	echo Creating $1_ode2odes.o
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DCODEGENTARGET=STANDALONE

$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common.oct $1_ode2odes_${integration_method}.oct $1_ode2odes_${algebraic_solver}.o
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.oct
	$MKOCTFILE -DCODEGENTARGET=OCTAVEDLD $1_ode2odes.cc mtt_${algebraic_solver}.cc mtt_Solver.cc mtt_AlgebraicSolver.cc

$1_ode2odes.mexglx: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.mexglx
	${MTT_CXX} -DCODEGENTARGET=MATLABMEX -o $1_ode2odes.mexglx $1_ode2odes.cc \
	$1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o \
	${MTT_MATLAB_FLAGS} ${MTT_CXXINCS} ${MTT_CXXLIBS} ${MTT_CXXFLAGS} \
	${MTT_LIB}/cc/mtt_kpathsea.cc ${MTT_LIB}/cc/mtt_matlab_octave.cc

$1_ode2odes.cc: $1_def.r $1_sympars.txt\
		$1_ode2odes_common.m $1_ode2odes_common.cc\
		$1_ode2odes_${integration_method}.m $1_ode2odes_${integration_method}.cc\
		mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.cc mtt_${algebraic_solver}.hh
	touch $1_ode2odes.m
	make_ode2odes $1 cc $integration_method $algebraic_solver

Modified mttroot/mtt/bin/trans/make_ode2odes from [1c01822bdf] to [e5d0e1820f].

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.76  2002/05/08 14:14:55  geraint
## Tidied up ode2odes code - reduced interweaving of STANDALONE/OCTAVEDLD sections
##
## Revision 1.75  2002/05/07 13:48:42  geraint
## Improved clarity of code generated for -cc and -oct (except ode2odes).
## Octave DEFUN_DLDs now call (rather than replace) their .cc equivalents.
##
## Revision 1.74  2002/05/01 17:30:56  geraint
## Improved pre-processor directives to better accommodate future alternatives (matlab)
## if necessary.
438
439
440
441
442
443
444

445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463

464
465
466
467
468
469
470
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466

467
468
469
470
471
472
473
474







+


















-
+







esac

cat <<EOF  > $filename

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#define MATLABMEX  2
#if (! defined (CODEGENTARGET))
#define CODEGENTARGET STANDALONE
#endif // (! defined (CODEGENTARGET))

#include <octave/oct.h>
#include <octave/lo-mappers.h>
#include <octave/variables.h>

#if (CODEGENTARGET == OCTAVEDLD)
#include <octave/${feval_header}>
#endif // (CODEGENTARGET == OCTAVEDLD)

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#include "mtt_${algebraic_solver}.hh"

#include <fstream>
#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))

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

553
554
555
556
557
558
559
560

561
562
563
564
565
566
567
568

569
570
571
572
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
610
611
612
613
614
615
616
617

618
619
620
621
622
623
624
625
626
627

628
629
630
631
632
633

634
635
636
637
638
639

640
641
642
643
644
645

646
647
648
649
650
651

652
653
654
655
656
657

658
659
660
661
662
663
664

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
715
716
717
718

719
720
721
722
723
724
725
726
727
728
729
730
731

732
733
734
735
736
737
738
739
740

741
742
743
744
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
782
783
784
785
786
787

788
789
790
791
792
793
794
795
796
797
798
799
800
801
802

803
804
805

806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824

825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843

844
845
846
847
848
849
850
851
852
853

854
855
856
857
858
859

860
861
862
863
864
865
866

867
868
869
870
871
872
873
557
558
559
560
561
562
563

564
565
566
567
568
569
570
571

572
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
610
611
612
613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
628
629
630

631
632
633
634
635
636

637
638
639
640
641
642

643
644
645
646
647
648

649
650
651
652
653
654

655
656
657
658
659
660

661
662
663
664
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
715
716
717
718
719
720
721

722
723
724
725
726
727
728
729
730
731
732
733
734

735
736
737
738
739
740
741
742
743

744
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
782
783
784
785
786
787
788
789
790

791
792
793
794
795
796
797
798
799
800
801
802
803
804
805

806
807
808

809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827

828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846

847
848
849
850
851
852
853
854
855
856

857
858
859
860
861
862

863
864
865
866
867
868
869

870
871
872
873
874
875
876
877







-
+







-
+









-
+











-
+









-
+
















-
+









-
+





-
+





-
+





-
+





-
+





-
+






-
+








-
+









-
+








-
+









-
+















-
+












-
+








-
+









-
+








-
+









-
+

















-
+














-
+


-
+


















-
+


















-
+









-
+





-
+






-
+







	const ColumnVector &open_switches);
 
EOF
    ;;
esac
cat <<EOF >> $filename

#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))

ColumnVector
mtt_ae (ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_input (ColumnVector &x,
	   ColumnVector &y,
	   const double &t,
	   ColumnVector &par)
{
  static MTT::${algebraic_solver} ae(MTTNPAR,MTTNU,MTTNX,MTTNY,MTTNYZ);
  static ColumnVector u  (MTTNU);

#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  u = ${sys}_input (x, y, t, par);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (y);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_input", args, 1);
  u = f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  if (MTTNYZ == 0)
    {
      return u;
    }
  else
    {
      return ae.solve(x,u,t,par);
    }
}

inline ColumnVector
mtt_logic (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_logic", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_numpar (void)
{
#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  return ${sys}_numpar ();
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_simpar (void)
{
#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  return ${sys}_simpar ();
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  f = feval ("${sys}_simpar", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_state (ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_rate (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_output (ColumnVector &x,
	     ColumnVector &u,
	     const double &t,
	     ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${odeo}", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

EOF
case "$method" in
    "implicit")
	cat <<EOF >> $filename
inline ColumnVector
mtt_implicit (ColumnVector &x,
	      ColumnVector &dx,
	      Matrix &AA,
	      ColumnVector &AAx,
	      const double &ddt,
	      const int &nx,
	      const ColumnVector &open_switches)
{
#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  return Fmtt_implicit (x, dx, AA, AAx, ddt, nx, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (AA);
  args (3) = octave_value (AAx);
  args (4) = octave_value (ddt);
  args (5) = octave_value ((double)nx);
  args (6) = octave_value (open_switches);
  f = feval ("mtt_implicit", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline Matrix
mtt_smxa (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

inline ColumnVector
mtt_smxax (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
#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);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxax", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

EOF
    ;;
    "dassl")
cat <<EOF >> $filename
inline ColumnVector
mtt_dassl (ColumnVector &x,
	   const ColumnVector &u,
	   const double &t,
	   const ColumnVector &par,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const int &nyz,
	   const ColumnVector &open_switches)
{
#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
   return Fmtt_dassl (x, u, t, par, dx, ddt, nx, nyz, open_switches);
#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);
    args (4) = octave_value (dx);
    args (5) = octave_value (ddt);
    args (6) = octave_value (static_cast<double> (nx));
    args (7) = octave_value (static_cast<double> (nyz));
    args (8) = octave_value (open_switches);
    f = feval ("mtt_dassl", args, 1);
    return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
ColumnVector
mtt_residual (const ColumnVector &X,
	      const ColumnVector &DX,
	      double t,
	      int &ires)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_residual, args, , "mtt_residual")
{
    static ColumnVector	X  (MTTNX+MTTNYZ);
    static ColumnVector	DX (MTTNX+MTTNYZ);
    static double      	t;
    static int		&ires;

    X  = args(0).${vector_value} ();
    DX = args(1).${vector_value} ();
    t  = args(2).double_value ();
    ires = static_cast<int>(args(3).double_value ());
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))

    static ColumnVector residual (MTTNX+MTTNYZ);
    static ColumnVector U (MTTNU+MTTNYZ);
    static ColumnVector u (MTTNU);
    static ColumnVector y (MTTNY,0.0);
    static ColumnVector par (MTTNPAR);
    static ColumnVector dx(MTTNX);
    static ColumnVector yz(MTTNYZ);

    static ColumnVector x (MTTNX);
    static ColumnVector ui (MTTNYZ);

    static octave_value_list new_args;

    x = X.extract (0,MTTNX-1);
    if (MTTNYZ > 0)
      ui = X.extract (MTTNX,MTTNX+MTTNYZ-1);    

#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
    par = ${sys}_numpar();
    u = ${sys}_input(x,y,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    par = feval ("${sys}_numpar",  new_args, 1)(0).${vector_value} ();
    new_args(0) = octave_value (x);
    new_args(1) = octave_value (u);
    new_args(2) = octave_value (t);
    new_args(3) = octave_value (par);
    u = feval ("${sys}_input", new_args, 1)(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))

    U.insert (u,0);
    if (MTTNYZ > 0)
      U.insert (ui,MTTNU);

#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
    dx = ${sys}_${ode} (x,U,t,par);
    yz = ${sys}_ae (x,U,t,par);
#elif (CODEGENTARGET == OCTAVEDLD)
    new_args(1) = octave_value (U);
    dx = feval ("${sys}_${ode}", new_args, 1)(0).${vector_value} ();
    yz = feval ("${sys}_ae", new_args, 1)(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))

    for (register int i = 0; i < MTTNX; i++)
      residual (i) = dx(i) - DX(i);
    
    if (MTTNYZ > 0)
      {
	residual.insert (yz,MTTNX);
885
886
887
888
889
890
891
892

893
894
895
896

897
898
899
900
901
902
903
904
905
906
907
908
909
910

911
912
913
914
915
916
917
918
919
920
921

922
923
924
925
926
927
928
889
890
891
892
893
894
895

896
897
898
899

900
901
902
903
904
905
906
907
908
909
910
911
912
913

914
915
916
917
918
919
920
921
922
923
924

925
926
927
928
929
930
931
932







-
+



-
+













-
+










-
+







	  }
	else
	  step = t;	
	for (register int i = MTTNX; i < MTTNX+MTTNYZ; i++)
	  residual(i) += X(i) - DX(i)*step;
      }

#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
    return residual;
#elif (CODEGENTARGET == OCTAVEDLD)
    return octave_value (residual);
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}
    
EOF
    ;;
    "euler" | "rk4" | *)
cat <<EOF >> $filename
inline ColumnVector
mtt_euler (ColumnVector &x,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const ColumnVector &open_switches)
{
#if (CODEGENTARGET == STANDALONE)
#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (ddt);
  args (3) = octave_value ((double)nx);
  args (4) = octave_value (open_switches);
  f = feval ("mtt_euler", args, 1);
  return f(0).${vector_value} ();
#endif // (CODEGENTARGET == STANDALONE)
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

EOF
    ;;
esac
cat <<EOF >> $filename

981
982
983
984
985
986
987
988

989
990
991
992
993
994
995
985
986
987
988
989
990
991

992
993
994
995
996
997
998
999







-
+







#if (CODEGENTARGET == STANDALONE)
      file << "# name: mtt_dump" << std::endl
	   << "# type: matrix" << std::endl
	   << "# rows: " << data.rows () << std::endl
	   << "# columns: " << data.columns () << std::endl
	   << data;
      file.flush ();
#elif (CODEGENTARGET == OCTAVEDLD)
#elif ((CODEGENTARGET == OCTAVEDLD) || (CODEGENTARGET == MATLABMEX))
  set_global_value ("MTT_data", data);
#endif // (CODEGENTARGET == STANDALONE)
    row = 0;
    fcputime.close();
    }
}

1190
1191
1192
1193
1194
1195
1196














































1197
1198
1199
1200
1201
1202
1203
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      error("aborting.");
    }

  ${sys}_ode2odes (state0, numpar, simpar);
    
  retval = octave_value (get_global_value ("MTT_data"));
  return (retval);
}
#elif (CODEGENTARGET == MATLABMEX)
#include <mtt_matlab_octave.hh>

extern "C" {
  void
  mexFunction (int nlhs, mxArray *plhs[],
	       int nrhs, const mxArray *prhs[])
  {
    static ColumnVector	state0 (MTTNX);
    static ColumnVector	numpar (MTTNPAR);
    static ColumnVector	simpar (8);

    initialize_symbol_tables ();
    
    switch (nrhs)
      {
      case 3:
	simpar	= mtt_ColumnVector (prhs[2]);
	numpar	= mtt_ColumnVector (prhs[1]);
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 2:
	simpar	= mtt_simpar ();
	numpar	= mtt_ColumnVector (prhs[1]);
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 1:
	simpar	= mtt_simpar ();
	numpar	= mtt_numpar ();
	state0	= mtt_ColumnVector (prhs[0]);
	break;
      case 0:
	simpar	= mtt_simpar ();
	numpar	= mtt_numpar ();
	state0	= mtt_state (numpar);
	break;
      default:
	std::cerr << "usage: ${sys}_ode2odes (x par simpar)" << std::endl;
	return;
      }

    ${sys}_ode2odes (state0, numpar, simpar);

    plhs[0] = mtt_mxArray (get_global_value ("MTT_data").matrix_value ());
  }
}
#endif // (CODEGENTARGET == STANDALONE)

EOF
}

case ${lang} in


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