Overview
Comment:Improved pre-processor directives to better accommodate future alternatives (matlab)
if necessary.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 5685d298d15e2af1a53ea68597f3ea032234aad5648858c15e0de8679fbe8255
User & Date: geraint@users.sourceforge.net on 2002-05-01 17:30:56
Other Links: branch diff | manifest | tags
Context
2002-05-02
09:19:40
replaced by cxxsim_rep.make check-in: 9f60cc53cb user: geraint@users.sourceforge.net tags: origin/master, trunk
2002-05-01
17:30:56
Improved pre-processor directives to better accommodate future alternatives (matlab)
if necessary.
check-in: 5685d298d1 user: geraint@users.sourceforge.net tags: origin/master, trunk
14:26:03
Whoops! Put awk back to gawk check-in: 81205b4869 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/mtt from [b5d9f5c247] to [e0453def2b].

13
14
15
16
17
18
19



20
21
22
23
24
25
26
# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$



## Revision 1.333  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.332  2002/04/26 23:19:00  geraint
## Fixed path to info files for "mtt info".
##







>
>
>







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.334  2002/05/01 14:10:22  gawthrop
## Added -dr foo (reads from dir foo) option
##
## Revision 1.333  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.332  2002/04/26 23:19:00  geraint
## Fixed path to info files for "mtt info".
##
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files
$1_%.oct:  $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Creating $1_\$*.oct; $MKOCTFILE  $1_\$*.cc

.PRECIOUS: mtt_%.oct
mtt_%.oct: mtt_%.cc
	echo Compiling \$<
	${MKOCTFILE} $define_octave_dev \$<

## .cc files
.PRECIOUS: %.cc # Don't let mtt delete them
$1_%.cc:  $1_%.m
	mtt_m2cc.sh  $1 \$* cat 

mtt_%.cc: ${MTT_LIB}/cc/mtt_%.cc
	cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc

mtt_%.hh: ${MTT_LIB}/cc/mtt_%.hh
	cp ${MTT_LIB}/cc/mtt_\$*.hh mtt_\$*.hh

## .o files
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Compiling $1_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE

.PRECIOUS: mtt_%.o
mtt_%.o: mtt_%.cc
	echo Compiling mtt_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE $define_octave_dev

# Generates code to write reduce code
$1_ode_write.r: $1_def.m
	def2write_r  $1 $2 $computation

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")







|




|
















|




|







2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files
$1_%.oct:  $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Creating $1_\$*.oct; $MKOCTFILE -DCODEGENTARGET=OCTAVEDLD $1_\$*.cc

.PRECIOUS: mtt_%.oct
mtt_%.oct: mtt_%.cc
	echo Compiling \$<
	${MKOCTFILE} -DCODEGENTARGET=OCTAVEDLD $define_octave_dev \$<

## .cc files
.PRECIOUS: %.cc # Don't let mtt delete them
$1_%.cc:  $1_%.m
	mtt_m2cc.sh  $1 \$* cat 

mtt_%.cc: ${MTT_LIB}/cc/mtt_%.cc
	cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc

mtt_%.hh: ${MTT_LIB}/cc/mtt_%.hh
	cp ${MTT_LIB}/cc/mtt_\$*.hh mtt_\$*.hh

## .o files
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Compiling $1_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE

.PRECIOUS: mtt_%.o
mtt_%.o: mtt_%.cc
	echo Compiling mtt_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DCODEGENTARGET=STANDALONE $define_octave_dev

# Generates code to write reduce code
$1_ode_write.r: $1_def.m
	def2write_r  $1 $2 $computation

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
	echo Creating $1_ode2odes.exe
	${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
	$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o\
	${MTT_LDFLAGS} ${MTT_CXXLIBS}

$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	echo Creating $1_ode2odes.o
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DSTANDALONE

$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 $1_ode2odes.cc mtt_${algebraic_solver}.cc mtt_Solver.cc mtt_AlgebraicSolver.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







|




|







2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
	echo Creating $1_ode2odes.exe
	${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
	$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o mtt_kpathsea.o\
	${MTT_LDFLAGS} ${MTT_CXXLIBS}

$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
	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.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 [aa15487e6e] to [de3807b0bb].

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.72  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.71  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp











>
>
>







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.73  2002/05/01 12:24:41  geraint
## Removed unnecessary inclusion of load-save.h.
##
## Revision 1.72  2002/05/01 12:21:29  geraint
## No longer uses save_ascii_data_for_plotting function to write data
## - eliminates dependence on liboctinterp (and libncurses) for .cc.
##
## Revision 1.71  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
423
424
425
426
427
428
429








430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
    *)
	vector_value=column_vector_value
	feval_header=parse.h
	;;
esac

cat <<EOF  > $filename








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

#ifndef STANDALONE
#include <octave/${feval_header}>
#endif

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

#include "mtt_${algebraic_solver}.hh"

#include <fstream>
#ifdef STANDALONE
#include <csignal>

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







>
>
>
>
>
>
>
>




|

|







|







426
427
428
429
430
431
432
433
434
435
436
437
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
    *)
	vector_value=column_vector_value
	feval_header=parse.h
	;;
esac

cat <<EOF  > $filename

// Code generation directives
#define STANDALONE 0
#define OCTAVEDLD  1
#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)
#include <csignal>

extern ColumnVector F${sys}_ae (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
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
EOF
    ;;
esac
cat <<EOF >> $filename

void set_signal_handlers (void);

#endif // STANDALONE

ColumnVector
mtt_ae (ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par)
{
#ifdef STANDALONE
    return F${sys}_ae(x,u,t,par);
#else
    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
}

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);

#ifdef STANDALONE
  u = F${sys}_input (x, y, t, par);
#else
  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
  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)
{
#ifdef STANDALONE
  return F${sys}_logic (x, u, t, par);
#else
  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
}

inline ColumnVector
mtt_numpar (void)
{
#ifdef STANDALONE
  return F${sys}_numpar ();
#else
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_simpar (void)
{
#ifdef STANDALONE
  return F${sys}_simpar ();
#else
  static octave_value_list args, f;
  f = feval ("${sys}_simpar", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_state (ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_state (par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (par);
  f = feval ("${sys}_state", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_rate (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_${ode} (x, u, t, par);
#else
  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
}

inline ColumnVector
mtt_output (ColumnVector &x,
	     ColumnVector &u,
	     const double &t,
	     ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_${odeo} (x, u, t, par);
#else
  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
}

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)
{
#ifdef STANDALONE
  return Fmtt_implicit (x, dx, AA, AAx, ddt, nx, open_switches);
#else
  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
}

inline Matrix
mtt_smxa (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_smxa (x, u, t, par);
#else
  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
}

inline ColumnVector
mtt_smxax (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_smxax (x, u, t, par);
#else
  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
}

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)
{
#ifdef STANDALONE
   return Fmtt_dassl (x, u, t, par, dx, ddt, nx, nyz, open_switches);
#else
   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
}

#ifdef STANDALONE
ColumnVector
Fmtt_residual (const ColumnVector &X,
	      const ColumnVector &DX,
	      double t,
	      int &ires)
{
#else // !STANDALONE
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 // STANDALONE

    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);    

#ifdef STANDALONE
    par = F${sys}_numpar();
    u = F${sys}_input(x,y,t,par);
#else
    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

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

#ifdef STANDALONE
    dx = F${sys}_${ode} (x,U,t,par);
    yz = F${sys}_ae (x,U,t,par);
#else
    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

    for (register int i = 0; i < MTTNX; i++)
      residual (i) = dx(i) - DX(i);
    
    if (MTTNYZ > 0)
      {
	residual.insert (yz,MTTNX);







|







|

|







|











|

|







|
















|

|







|





|

|



|





|

|



|





|

|




|








|

|







|








|

|







|















|

|










|








|

|







|








|

|







|

















|

|












|


|






|











|


















|


|






|





|


|



|







548
549
550
551
552
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
EOF
    ;;
esac
cat <<EOF >> $filename

void set_signal_handlers (void);

#endif // (CODEGENTARGET == STANDALONE)

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

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)
  u = F${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)
  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)
  return F${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)
}

inline ColumnVector
mtt_numpar (void)
{
#if (CODEGENTARGET == STANDALONE)
  return F${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)
}

inline ColumnVector
mtt_simpar (void)
{
#if (CODEGENTARGET == STANDALONE)
  return F${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)
}

inline ColumnVector
mtt_state (ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
  return F${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)
}

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

inline ColumnVector
mtt_output (ColumnVector &x,
	     ColumnVector &u,
	     const double &t,
	     ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
  return F${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)
}

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)
  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)
}

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

inline ColumnVector
mtt_smxax (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
{
#if (CODEGENTARGET == STANDALONE)
  return F${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)
}

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)
   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)
}

#if (CODEGENTARGET == STANDALONE)
ColumnVector
Fmtt_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)

    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)
    par = F${sys}_numpar();
    u = F${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)

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

#if (CODEGENTARGET == STANDALONE)
    dx = F${sys}_${ode} (x,U,t,par);
    yz = F${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)

    for (register int i = 0; i < MTTNX; i++)
      residual (i) = dx(i) - DX(i);
    
    if (MTTNYZ > 0)
      {
	residual.insert (yz,MTTNX);
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
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
	  }
	else
	  step = t;	
	for (register int i = MTTNX; i < MTTNX+MTTNYZ; i++)
	  residual(i) += X(i) - DX(i)*step;
      }

#ifdef STANDALONE
    return residual;
#else // !STANDALONE
    return octave_value (residual);
#endif // STANDALONE
}
    
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)
{
#ifdef STANDALONE
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#else
  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
}

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








|

|

|













|

|








|







880
881
882
883
884
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
	  }
	else
	  step = t;	
	for (register int i = MTTNX; i < MTTNX+MTTNYZ; i++)
	  residual(i) += X(i) - DX(i)*step;
      }

#if (CODEGENTARGET == STANDALONE)
    return residual;
#elif (CODEGENTARGET == OCTAVEDLD)
    return octave_value (residual);
#endif // (CODEGENTARGET == STANDALONE)
}
    
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)
  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)
}

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

958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
  fcputime << t << '\t'
	   << static_cast <double> (cputime - cputime0) / CLOCKS_PER_SEC << '\t'
	   << static_cast <double> (cputime - cputime1) / CLOCKS_PER_SEC << std::endl;
  cputime1 = cputime;

  if (nrows == row)
    {
#ifdef STANDALONE
      file << "# name: mtt_dump" << std::endl
	   << "# type: matrix" << std::endl
	   << "# rows: " << data.rows () << std::endl
	   << "# columns: " << data.columns () << std::endl
	   << data;
      file.flush ();
#else // ! STANDALONE
  set_global_value ("MTT_data", data);
#endif
    row = 0;
    fcputime.close();
    }
}

#ifdef STANDALONE
void dump_data (std::ostream &file)
{
  ColumnVector null (0);
  mtt_write (0.0, null, null, 0, true, file);
}

void handle_signal (int signum)







|






|

|





|







969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
  fcputime << t << '\t'
	   << static_cast <double> (cputime - cputime0) / CLOCKS_PER_SEC << '\t'
	   << static_cast <double> (cputime - cputime1) / CLOCKS_PER_SEC << std::endl;
  cputime1 = cputime;

  if (nrows == row)
    {
#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)
  set_global_value ("MTT_data", data);
#endif // (CODEGENTARGET == STANDALONE)
    row = 0;
    fcputime.close();
    }
}

#if (CODEGENTARGET == STANDALONE)
void dump_data (std::ostream &file)
{
  ColumnVector null (0);
  mtt_write (0.0, null, null, 0, true, file);
}

void handle_signal (int signum)
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
  signal (SIGFPE,	handle_signal);
  signal (SIGINT,	handle_signal);
  signal (SIGQUIT,	handle_signal);
}

int main (void) {
  set_signal_handlers ();
#else
DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system with $method integration method\nUsage: mtt_data = ${sys}_ode2odes (x0, par, simpar)\n")
{
  static octave_value_list retval;
#endif // STANDALONE
  static ColumnVector	x0;
  static ColumnVector	par;
  static ColumnVector	simpar;

  static double
    first	= 0.0,
    dt		= 0.0,
    last	= 0.0,
    stepfactor	= 0.0;
#ifndef STANDALONE
  int nargin = args.length ();
  switch (nargin)
    {
    case 3:
      first		= args (2).${vector_value} ()(0);
      dt		= args (2).${vector_value} ()(1);
      last		= args (2).${vector_value} ()(2);







|




|









|







1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
  signal (SIGFPE,	handle_signal);
  signal (SIGINT,	handle_signal);
  signal (SIGQUIT,	handle_signal);
}

int main (void) {
  set_signal_handlers ();
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system with $method integration method\nUsage: mtt_data = ${sys}_ode2odes (x0, par, simpar)\n")
{
  static octave_value_list retval;
#endif // (CODEGENTARGET == STANDALONE)
  static ColumnVector	x0;
  static ColumnVector	par;
  static ColumnVector	simpar;

  static double
    first	= 0.0,
    dt		= 0.0,
    last	= 0.0,
    stepfactor	= 0.0;
#if (CODEGENTARGET == OCTAVEDLD)
  int nargin = args.length ();
  switch (nargin)
    {
    case 3:
      first		= args (2).${vector_value} ()(0);
      dt		= args (2).${vector_value} ()(1);
      last		= args (2).${vector_value} ()(2);
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
      dt		= mtt_simpar ()(1);
      last		= mtt_simpar ()(2);
      stepfactor     	= mtt_simpar ()(3);
      par    		= mtt_numpar ();
      x0      		= args (0).${vector_value} ();
      break;
    case 0:
#endif // ! STANDALONE
      first		= mtt_simpar ()(0);
      dt		= mtt_simpar ()(1);
      last		= mtt_simpar ()(2);
      stepfactor     	= mtt_simpar ()(3);
      par    		= mtt_numpar ();
      x0      		= mtt_state (par);
#ifndef STANDALONE
      break;
    default:
      usage("${sys}_ode2odes (x par simpar)", nargin);
      error("aborting.");
    }
#endif // STANDALONE
  static ColumnVector	dx (MTTNX, 0.0);
  static ColumnVector	x (MTTNX, 0.0);
  static ColumnVector	u (MTTNU, 0.0);
  static ColumnVector	y (MTTNY, 0.0);

  static Matrix	AA (MTTNX, MTTNX, 0.0);
  static ColumnVector	AAx (MTTNX, 0.0);







|






|





|







1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
      dt		= mtt_simpar ()(1);
      last		= mtt_simpar ()(2);
      stepfactor     	= mtt_simpar ()(3);
      par    		= mtt_numpar ();
      x0      		= args (0).${vector_value} ();
      break;
    case 0:
#endif // (CODEGENTARGET == OCTAVEDLD)
      first		= mtt_simpar ()(0);
      dt		= mtt_simpar ()(1);
      last		= mtt_simpar ()(2);
      stepfactor     	= mtt_simpar ()(3);
      par    		= mtt_numpar ();
      x0      		= mtt_state (par);
#if (CODEGENTARGET == OCTAVEDLD)
      break;
    default:
      usage("${sys}_ode2odes (x par simpar)", nargin);
      error("aborting.");
    }
#endif // (CODEGENTARGET == OCTAVEDLD)
  static ColumnVector	dx (MTTNX, 0.0);
  static ColumnVector	x (MTTNX, 0.0);
  static ColumnVector	u (MTTNU, 0.0);
  static ColumnVector	y (MTTNY, 0.0);

  static Matrix	AA (MTTNX, MTTNX, 0.0);
  static ColumnVector	AAx (MTTNX, 0.0);
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
      open_switches = mtt_logic (x, u, t, par);
      x =  $algorithm; 
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

#ifdef STANDALONE
  return 0;
#else
/*  
  retval (0) = octave_value (y);
  retval (1) = octave_value (x);
  retval (2) = octave_value (t);
*/
  retval = octave_value (get_global_value ("MTT_data"));
  return (retval);
#endif // STANDALONE
}
EOF
}

case ${lang} in
    m)
        make_m	







|

|







|







1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
      open_switches = mtt_logic (x, u, t, par);
      x =  $algorithm; 
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

#if (CODEGENTARGET == STANDALONE)
  return 0;
#elif (CODEGENTARGET == OCTAVEDLD)
/*  
  retval (0) = octave_value (y);
  retval (1) = octave_value (x);
  retval (2) = octave_value (t);
*/
  retval = octave_value (get_global_value ("MTT_data"));
  return (retval);
#endif // (CODEGENTARGET == STANDALONE)
}
EOF
}

case ${lang} in
    m)
        make_m	

Modified mttroot/mtt/bin/trans/make_stdin from [c1f26ffe2e] to [d2cafbc640].

69
70
71
72
73
74
75

76






77
78
79
80
81
82
83
// -*-c++-*- Put emacs into c++-mode

// 
// System ${Sys}, representation input, language oct; 
// File ${Sys}_input.oct; 
// Generated by MTT on `date`; 


#ifdef STANDALONE






#include <octave/oct.h>
#include "${Sys}_def.h"

void strip_comments (istream &str)
{
  char c;
  c = str.peek ();







>
|
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// -*-c++-*- Put emacs into c++-mode

// 
// System ${Sys}, representation input, language oct; 
// File ${Sys}_input.oct; 
// Generated by MTT on `date`; 

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

#if (CODEGENTARGET == STANDALONE)
#include <octave/oct.h>
#include "${Sys}_def.h"

void strip_comments (istream &str)
{
  char c;
  c = str.peek ();
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
ColumnVector F${Sys}_input (
	ColumnVector	&mttx,
	ColumnVector	&mtty,
	const double	&mttt,
	ColumnVector	&mttpar
)
{
#endif // STANDALONE
#ifndef STANDALONE
#include <octave/oct.h>
#include <variables.h>
#include "${Sys}_def.h"

DEFUN_DLD (${Sys}_input, args, ,
"Usage: [mttu] = ${Sys}_input()
Octave input (-stdin) representation of system ${Sys}
Generated by MTT on `date`")
{

  octave_value_list retval;
#endif // ! STANDALONE

  ColumnVector	mttu	(MTTNU);

  // Set up the mttu vector
#ifndef STANDALONE
  int MTT_input_index	= static_cast<int>(get_global_value ("MTT_input_index").double_value ());
  int MTT_input_last	= static_cast<int>(get_global_value ("MTT_input_last").double_value ());
  Matrix MTT_input 	= get_global_value ("MTT_input").matrix_value();

  mttu = MTT_input.row (MTT_input_index);

  if (MTT_input_index < (MTT_input_last - 1))
    {
      set_global_value ("MTT_input_index", static_cast<double>(++MTT_input_index));
    }
  
#else
  double t, u;
  strip_comments (cin);
  cin >> t;
  for (register int i = 0; i < MTTNU; i++)
    {      
      cin >> u;
      mttu(i) = u;
    }
#endif


#ifndef STANDALONE
  retval (0)	= octave_value (mttu);
  return (retval);
}
#endif // ! STANDALONE
#ifdef STANDALONE
  return mttu;
}
#endif // STANDALONE
EOF
}

case $lang in
    p)
	make_p 
	;;







|
<











|




|











|








|


|



<
|


|







103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162
163
164
165
ColumnVector F${Sys}_input (
	ColumnVector	&mttx,
	ColumnVector	&mtty,
	const double	&mttt,
	ColumnVector	&mttpar
)
{
#elif (CODEGENTARGET == OCTAVEDLD)

#include <octave/oct.h>
#include <variables.h>
#include "${Sys}_def.h"

DEFUN_DLD (${Sys}_input, args, ,
"Usage: [mttu] = ${Sys}_input()
Octave input (-stdin) representation of system ${Sys}
Generated by MTT on `date`")
{

  octave_value_list retval;
#endif // (CODEGENTARGET == STANDALONE)

  ColumnVector	mttu	(MTTNU);

  // Set up the mttu vector
#if (CODEGENTARGET == OCTAVEDLD)
  int MTT_input_index	= static_cast<int>(get_global_value ("MTT_input_index").double_value ());
  int MTT_input_last	= static_cast<int>(get_global_value ("MTT_input_last").double_value ());
  Matrix MTT_input 	= get_global_value ("MTT_input").matrix_value();

  mttu = MTT_input.row (MTT_input_index);

  if (MTT_input_index < (MTT_input_last - 1))
    {
      set_global_value ("MTT_input_index", static_cast<double>(++MTT_input_index));
    }
  
#elif (CODEGENTARGET == STANDALONE)
  double t, u;
  strip_comments (cin);
  cin >> t;
  for (register int i = 0; i < MTTNU; i++)
    {      
      cin >> u;
      mttu(i) = u;
    }
#endif // (CODEGENTARGET == OCTAVEDLD)


#if (CODEGENTARGET == OCTAVEDLD)
  retval (0)	= octave_value (mttu);
  return (retval);
}

#elif (CODEGENTARGET == STANDALONE)
  return mttu;
}
#endif // (CODEGENTARGET == OCTAVEDLD)
EOF
}

case $lang in
    p)
	make_p 
	;;

Modified mttroot/mtt/bin/trans/mtt_header from [f0f5b8d756] to [c82b78366b].

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.42  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.41  2002/04/23 17:46:05  gawthrop
## _sim.m now returns time as third argument
##







>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.43  2002/04/30 23:27:00  geraint
## Replaced octave_map with columnvector in simpar.cc. Not quite as descriptive but
## standardises the interfaces somewhat and reduces the dependency on liboctinterp
## (and thus libreadline, libkpathsea, libncurses, etc).
##
## Revision 1.42  2002/04/28 18:41:27  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.41  2002/04/23 17:46:05  gawthrop
## _sim.m now returns time as third argument
##
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
    echo ${ans}
}


write_DLD_header()
{
    cat <<EOF
#ifndef STANDALONE
#include <octave/oct.h>
#include <octave/toplev.h>
#include <math.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$output] = ${system}_${rep}($args)\nOctave ${rep} representation of system ${system}\nGenerated by MTT on `date`")
{

  octave_value_list retval;
#endif // ! STANDALONE

EOF
}


map_DLD_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    printf "#ifndef STANDALONE\n"
    c=`get_field ${s} 0`			# count of inputs
    i=0
    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"
		;;
	    ColumnVector | Matrix | *)
		printf "  ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
		;;
	esac
    done
    printf "#endif // ! STANDALONE\n\n"
}	


declare_DLD_outputs ()
{
    s=${1:-""}					# comma separated output list
    c=`get_field ${s} 0`			# count of outputs







|













|









|

















|







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
    echo ${ans}
}


write_DLD_header()
{
    cat <<EOF
#if (CODEGENTARGET == OCTAVEDLD)
#include <octave/oct.h>
#include <octave/toplev.h>
#include <math.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$output] = ${system}_${rep}($args)\nOctave ${rep} representation of system ${system}\nGenerated by MTT on `date`")
{

  octave_value_list retval;
#endif // (CODEGENTARGET == OCTAVEDLD)

EOF
}


map_DLD_inputs ()
{
    s=${1:-""}					# comma separated input list
    if [ -z ${s:-""} ];then return; fi
    printf "#if (CODEGENTARGET == OCTAVEDLD)\n"
    c=`get_field ${s} 0`			# count of inputs
    i=0
    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"
		;;
	    ColumnVector | Matrix | *)
		printf "  ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
		;;
	esac
    done
    printf "#endif // (CODEGENTARGET == OCTAVEDLD)\n\n"
}	


declare_DLD_outputs ()
{
    s=${1:-""}					# comma separated output list
    c=`get_field ${s} 0`			# count of outputs
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
    s=${1:-""}					# comma separated output list
    c=`get_field ${s} 0`			# count of outputs
    i=0
    cat <<EOF

\/\/ END Code

#ifndef STANDALONE
EOF
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
	w=`get_field ${s} ${i}`
	printf "  retval (${j})\t= octave_value (${w});\n"
    done
    cat <<EOF
  return (retval);
}
#endif // ! STANDALONE
EOF
}

write_standalone_header ()
{
    get_arg_specific_stuff ${output}
    cat <<EOF


#ifdef STANDALONE






#include <octave/oct.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

${arg_type} F${system}_${rep} (







|










|








>
|
>
>
>
>
>
>







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
    s=${1:-""}					# comma separated output list
    c=`get_field ${s} 0`			# count of outputs
    i=0
    cat <<EOF

\/\/ END Code

#if (CODEGENTARGET == OCTAVEDLD)
EOF
    while [ ${i} -lt ${c} ]; do
	j=${i}
	i=`expr ${i} + 1`
	w=`get_field ${s} ${i}`
	printf "  retval (${j})\t= octave_value (${w});\n"
    done
    cat <<EOF
  return (retval);
}
#endif // (CODEGENTARGET == OCTAVEDLD)
EOF
}

write_standalone_header ()
{
    get_arg_specific_stuff ${output}
    cat <<EOF

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

#if (CODEGENTARGET == STANDALONE)
#include <octave/oct.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"

${arg_type} F${system}_${rep} (
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
	    get_arg_specific_stuff ${w}
	    printf "\t${arg_type}\t&${w}${comma}\n"
	done
    fi
    cat <<EOF
)
{
#endif // STANDALONE
EOF
}

return_standalone_output ()
{
    cat <<EOF
#ifdef STANDALONE
  return ${output};
}
#endif // STANDALONE
EOF
}

# Header information
cat<<EOF
$modeline
$function $declaration







|






|


|







855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
	    get_arg_specific_stuff ${w}
	    printf "\t${arg_type}\t&${w}${comma}\n"
	done
    fi
    cat <<EOF
)
{
#endif // (CODEGENTARGET == STANDALONE)
EOF
}

return_standalone_output ()
{
    cat <<EOF
#if (CODEGENTARGET == STANDALONE)
  return ${output};
}
#endif // (CODEGENTARGET == STANDALONE)
EOF
}

# Header information
cat<<EOF
$modeline
$function $declaration

Modified mttroot/mtt/lib/cc/mtt_Hybrd_Solver.cc from [f1e519c135] to [478c947ac8].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  static int convergences;
  static int progress_errors;
  static int limit_errors;
  static int unknown_errors;
  
  NLFunc fcn(&Hybrd_Solver::f_hybrd);
  NLEqn	 eqn(Solver::_ui,fcn);
  eqn.set_tolerance(1.0e-3);
  Solver::_ui = eqn.solve(info);

  switch (info)
    {
    case 1:
      convergences++;
      break;







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  static int convergences;
  static int progress_errors;
  static int limit_errors;
  static int unknown_errors;
  
  NLFunc fcn(&Hybrd_Solver::f_hybrd);
  NLEqn	 eqn(Solver::_ui,fcn);
  eqn.set_tolerance(1.0e-20);
  Solver::_ui = eqn.solve(info);

  switch (info)
    {
    case 1:
      convergences++;
      break;

Modified mttroot/mtt/lib/cc/mtt_dassl.cc from [b9b24f4791] to [e3d59b9298].

1
2
3
4
5
6
7
8
9
10
11
12
13






14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

#include <octave/oct.h>
#include <octave/DASSL.h>


#ifdef  OCTAVE_DEV
#include <octave/parse.h>
#define VECTOR_VALUE column_vector_value
#else   // !OCTAVE_DEV
#include <octave/toplev.h>
#define VECTOR_VALUE vector_value
#endif  // OCTAVE_DEV








#ifdef STANDALONE
extern ColumnVector
Fmtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires);
#endif // STANDALONE


ColumnVector
mtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires)
{
#ifdef STANDALONE
  return Fmtt_residual (X, DX, t, ires);
#else // !STANDALONE
  static octave_value_list args, f;
  args(0) = octave_value (X);
  args(1) = octave_value (DX);
  args(2) = octave_value (t);
  args(3) = octave_value (ires);
  f = feval ("mtt_residual", args, 1);
  return f(0).VECTOR_VALUE ();
#endif // STANDALONE
}


#ifdef STANDALONE
ColumnVector
Fmtt_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	&openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_dassl, args, ,
	   "dassl integration method")
{
  ColumnVector		x	= args(0).VECTOR_VALUE();
  const ColumnVector   	u	= args(1).VECTOR_VALUE();
  const double		t	= args(2).double_value();
  const ColumnVector	par	= args(3).VECTOR_VALUE();
  const ColumnVector	dx	= args(4).VECTOR_VALUE();
  const double		ddt	= args(5).double_value();
  const int		Nx	= static_cast<int> (args(6).double_value());
  const int		Nyz	= static_cast<int> (args(7).double_value());
  const ColumnVector	openx	= args(8).VECTOR_VALUE();
#endif // STANDALONE

  static DAEFunc fdae(mtt_residual);
  static ColumnVector XX (Nx+Nyz);
  XX.insert (x,0);

  for (register int i = Nx; i < Nx+Nyz; i++)
    XX(i) = 0.0;

  double tout = t + ddt;

  DASSL fdassl (XX, t, fdae);
  x = fdassl.do_integrate (tout).extract (0,Nx-1);

  for (register int i = 0; i < Nx; i++)
    if (openx (i) > 0.5)
      x (i) = 0.0;
      

#ifdef STANDALONE
  return x;
#else
  return octave_value (x);
#endif
}













>
>
>
>
>
>

|


|





|

|







|



|











|












|


















|

|

|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

#include <octave/oct.h>
#include <octave/DASSL.h>


#ifdef  OCTAVE_DEV
#include <octave/parse.h>
#define VECTOR_VALUE column_vector_value
#else   // !OCTAVE_DEV
#include <octave/toplev.h>
#define VECTOR_VALUE vector_value
#endif  // OCTAVE_DEV

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

#if (CODEGENTARGET == STANDALONE)
extern ColumnVector
Fmtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires);
#endif // (CODEGENTARGET == STANDALONE)


ColumnVector
mtt_residual (const ColumnVector &X, const ColumnVector &DX, double t, int &ires)
{
#if (CODEGENTARGET == STANDALONE)
  return Fmtt_residual (X, DX, t, ires);
#elif (CODEGENTARGET == OCTAVEDLD)
  static octave_value_list args, f;
  args(0) = octave_value (X);
  args(1) = octave_value (DX);
  args(2) = octave_value (t);
  args(3) = octave_value (ires);
  f = feval ("mtt_residual", args, 1);
  return f(0).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)
}


#if (CODEGENTARGET == STANDALONE)
ColumnVector
Fmtt_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	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_dassl, args, ,
	   "dassl integration method")
{
  ColumnVector		x	= args(0).VECTOR_VALUE();
  const ColumnVector   	u	= args(1).VECTOR_VALUE();
  const double		t	= args(2).double_value();
  const ColumnVector	par	= args(3).VECTOR_VALUE();
  const ColumnVector	dx	= args(4).VECTOR_VALUE();
  const double		ddt	= args(5).double_value();
  const int		Nx	= static_cast<int> (args(6).double_value());
  const int		Nyz	= static_cast<int> (args(7).double_value());
  const ColumnVector	openx	= args(8).VECTOR_VALUE();
#endif // (CODEGENTARGET == STANDALONE)

  static DAEFunc fdae(mtt_residual);
  static ColumnVector XX (Nx+Nyz);
  XX.insert (x,0);

  for (register int i = Nx; i < Nx+Nyz; i++)
    XX(i) = 0.0;

  double tout = t + ddt;

  DASSL fdassl (XX, t, fdae);
  x = fdassl.do_integrate (tout).extract (0,Nx-1);

  for (register int i = 0; i < Nx; i++)
    if (openx (i) > 0.5)
      x (i) = 0.0;
      

#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Modified mttroot/mtt/lib/cc/mtt_euler.cc from [43d68034de] to [94aa4f3270].

1
2
3
4
5
6
7
8

9






10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <octave/oct.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV


#ifdef STANDALONE






ColumnVector Fmtt_euler (      ColumnVector	&x,
			 const ColumnVector	&dx,
			 const double		&ddt,
			 const int		&Nx,
			 const ColumnVector	&openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_euler, args, ,
	   "euler integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  const ColumnVector	dx	= args(1).VECTOR_VALUE ();
  const double		ddt	= args(2).double_value ();
  const int		Nx	= static_cast<int> (args(3).double_value ());
  const ColumnVector   	openx	= args(4).VECTOR_VALUE ();
#endif // STANDALONE

  register int i, n;
  
  n = Nx;
  for (i = 0; i < Nx; i++)
    {
      if (0 != openx (i))
	{
	  x (i) = 0.0;
	}
      else
	{
	  x (i) += dx (i) * ddt;
	}
    }
#ifdef STANDALONE
  return x;
#else // !STANDALONE  
  return octave_value (x);
#endif // STANDALONE
}








>
|
>
>
>
>
>
>






|








|















|

|

|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <octave/oct.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV

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

#if (CODEGENTARGET == STANDALONE)
ColumnVector Fmtt_euler (      ColumnVector	&x,
			 const ColumnVector	&dx,
			 const double		&ddt,
			 const int		&Nx,
			 const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_euler, args, ,
	   "euler integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  const ColumnVector	dx	= args(1).VECTOR_VALUE ();
  const double		ddt	= args(2).double_value ();
  const int		Nx	= static_cast<int> (args(3).double_value ());
  const ColumnVector   	openx	= args(4).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)

  register int i, n;
  
  n = Nx;
  for (i = 0; i < Nx; i++)
    {
      if (0 != openx (i))
	{
	  x (i) = 0.0;
	}
      else
	{
	  x (i) += dx (i) * ddt;
	}
    }
#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}

Modified mttroot/mtt/lib/cc/mtt_implicit.cc from [99ad6e1348] to [44405c14b7].

1
2
3
4
5
6
7
8
9

10






11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <octave/oct.h>
#include <octave/xdiv.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV


#ifdef STANDALONE






ColumnVector Fmtt_implicit (      ColumnVector	&x,
				  ColumnVector	&dx,
			          Matrix	&AA,
				  ColumnVector	&AAx,
			    const double	&t,
			    const int		&Nx,
			    const ColumnVector	&openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  ColumnVector		dx	= args(1).VECTOR_VALUE ();
  Matrix		AA	= args(2).matrix_value ();
  ColumnVector		AAx	= args(3).VECTOR_VALUE ();
  const  double		t	= args(4).double_value ();
  const  int		Nx	= (int) (args(5).double_value ());
  const  ColumnVector	openx	= args(6).VECTOR_VALUE ();
#endif // STANDALONE

  register int row, col;

  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{









>
|
>
>
>
>
>
>








|










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <octave/oct.h>
#include <octave/xdiv.h>

#ifdef	OCTAVE_DEV
#define VECTOR_VALUE column_vector_value
#else // !OCTAVE_DEV
#define	VECTOR_VALUE vector_value
#endif // OCTAVE_DEV

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

#if (CODEGENTARGET == STANDALONE)
ColumnVector Fmtt_implicit (      ColumnVector	&x,
				  ColumnVector	&dx,
			          Matrix	&AA,
				  ColumnVector	&AAx,
			    const double	&t,
			    const int		&Nx,
			    const ColumnVector	&openx)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
  ColumnVector  	x	= args(0).VECTOR_VALUE ();
  ColumnVector		dx	= args(1).VECTOR_VALUE ();
  Matrix		AA	= args(2).matrix_value ();
  ColumnVector		AAx	= args(3).VECTOR_VALUE ();
  const  double		t	= args(4).double_value ();
  const  int		Nx	= (int) (args(5).double_value ());
  const  ColumnVector	openx	= args(6).VECTOR_VALUE ();
#endif // (CODEGENTARGET == STANDALONE)

  register int row, col;

  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
59
60
61
62
63
64
65
66
67
68
69
70
71
    {
      if (openx (row) > 0.5)
	{
	  x (row) = 0.0;
	}
    }

#ifdef STANDALONE
  return x;
#else // !STANDALONE
  return octave_value (x);
#endif // STANDALONE
}







|

|

|

66
67
68
69
70
71
72
73
74
75
76
77
78
    {
      if (openx (row) > 0.5)
	{
	  x (row) = 0.0;
	}
    }

#if (CODEGENTARGET == STANDALONE)
  return x;
#elif (CODEGENTARGET == OCTAVEDLD)
  return octave_value (x);
#endif // (CODEGENTARGET == STANDALONE)
}


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