Overview
Comment:Modified for smx, smxa, smxax
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 7356caf5d0306f6d2b1360f58ccfc6d0e2e12ee739e7bf33e7d2365a6b616e1a
User & Date: gawthrop@users.sourceforge.net on 2000-04-07 13:25:52
Other Links: branch diff | manifest | tags
Context
2000-04-07
13:38:13
New mtt_getsize to replace bc check-in: 56555dc0b2 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
13:25:52
Modified for smx, smxa, smxax check-in: 7356caf5d0 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
13:25:27
Initial revision check-in: a64332785f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_p2cc from [4424a8dffa] to [508c370e50].

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


94
95
96

# Pascal to .oct (octave loadable binary).
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	

# Find system constants
Nx=`mtt_getsize $1 x`
Nu=`mtt_getsize $1 u`


# Create numpar code
mtt_p2C $1 numpar

# Create input code
mtt_p2C $1 input

# Create the representation code
mtt_p2C $1 $2

# Inform user
echo Creating $1_$2.cc

# Create the c++ code
# Heading
date=`date`

cat > $1_$2.cc <<EOF
#include <octave/oct.h>
 
DEFUN_DLD ($1_$2, args, ,
	   "$1_$2 was generated by MTT on $date")
{
  ColumnVector mttdx ($Nx);
  ColumnVector mttu ($Nu);

  ColumnVector mttx = args(0).vector_value ();

EOF























#Extract Type info
#echo '/* Types */'                >> $1_$2.cc
#grep typedef $1_$2.C              >> $1_$2.cc

#Extract any additional mtt_tmp variables
awk 'BEGIN{
  writing = 1;
}
{


  if (match($1,"mtt")==1) writing=0;  
  if ( (writing)&&(match($0,"mtt_t[0-9]")>0) ) print $0;
}' < $1_$2.C >> $1_$2.cc

#Extract the numpar code
echo '/* Numerical parameters */' >> $1_$2.cc
awk '{
  if ($1=="}") writing=0;
  if (writing) print $0;
  if ($1=="{") writing=1;
}' <$1_numpar.C >> $1_$2.cc

#Extract the input code converting [] to ()
echo "/* Input information */" >> $1_$2.cc
awk '{
  if ($1=="}") writing=0;
  if (match($1,"mtt")==1) writing=1;
  if (writing) print $0;
}' <$1_input.C |\
sed 's/\[\([0-9]*\)\]/(\1)/g' >> $1_$2.cc


#Extract the rep code converting [] to ()
echo "/* Representation $2 information */" >> $1_$2.cc
awk '{
  if ($1=="}") writing=0;

  if (match($1,"mtt")==1) writing=1;
  if (writing) print $0;
}' <$1_$2.C |\
sed 's/\[\([0-9]*\)\]/(\1)/g' >> $1_$2.cc

# Tail
cat >> $1_$2.cc <<EOF





  return octave_value (mttdx);

















}
EOF




# Convert to octave loadable code
echo Creating $1_$2.oct
mkoctfile $1_$2.cc








|
|
>


|


|













|



|
|
>
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
|


|
|
<
<
>
>
|
|
|


|
|
|
|
|
|


|
|
|
|
|
|
|

<
|



>
|
<






>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>

>
>



>
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
94
95
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
# Pascal to .oct (octave loadable binary).
# P.J.Gawthrop Feb 2000
# Copyright (C) 2000 by Peter J. Gawthrop

    #$Id$	

# Find system constants
Nx=`mtt_getsize $1 x` # States
Nu=`mtt_getsize $1 u` # Inputs 
Ny=`mtt_getsize $1 y` # Inputs 

# Create numpar code
#mtt_p2C $1 numpar

# Create input code
#mtt_p2C $1 input

# Create the representation code
mtt_p2C $1 $2

# Inform user
echo Creating $1_$2.cc

# Create the c++ code
# Heading
date=`date`

cat > $1_$2.cc <<EOF
#include <octave/oct.h>

DEFUN_DLD ($1_$2, args, ,
	   "$1_$2 was generated by MTT on $date")
{
  ColumnVector mttx = args(0).vector_value ();
  ColumnVector mttu = args(1).vector_value ();
  double mttt = args(2).double_value ();
  ColumnVector mttpar = args(3).vector_value ();

EOF

case "$2" in
    ode)
	echo "  ColumnVector mttdx ($Nx);" >> $1_$2.cc
	;;
    odeo)
	echo "  ColumnVector mtty ($Ny);" >> $1_$2.cc
	;;
    cse)
	echo "  ColumnVector mttdx ($Nx);" >> $1_$2.cc
	;;
    cseo)
	echo "  ColumnVector mtty ($Ny);" >> $1_$2.cc
	;;
    smx | smxa | smxax)
        Nxx=`echo "$Nx*$Nx" | bc`
	echo "  ColumnVector mtta ($Nxx);" >> $1_$2.cc
	echo "  ColumnVector mttax ($Nx);" >> $1_$2.cc
	;;
    *)
	
esac

#Extract Type info
echo '/* Types */'                >> $1_$2.cc
grep typedef $1_$2.C              >> $1_$2.cc

#Extract any additional mtt_tmp variables
#awk 'BEGIN{
#  writing = 1;


#}
#{
#  if (match($1,"mtt")==1) writing=0;  
#  if ( (writing)&&(match($0,"mtt_t[0-9]")>0) ) print $0;
#}' < $1_$2.C >> $1_$2.cc

#Extract the numpar code
#echo '/* Numerical parameters */' >> $1_$2.cc
#awk '{
#  if ($1=="}") writing=0;
#  if (writing) print $0;
#  if ($1=="{") writing=1;
#}' <$1_numpar.C >> $1_$2.cc

#Extract the input code converting [] to ()
#echo "/* Input information */" >> $1_$2.cc
#awk '{
#  if ($1=="}") writing=0;
#  if (match($1,"mtt")==1) writing=1;
#  if (writing) print $0;
#}' <$1_input.C |\
#sed 's/\[\([0-9]*\)\]/(\1)/g' >> $1_$2.cc


#Extract the rep code and  converting [] to () and deleting mtt variables etc
echo "/* Representation $2 information */" >> $1_$2.cc
awk '{
  if ($1=="}") writing=0;
  if ( (writing)&&(match($2,"mtt")==0) ) print $0;
  if (match($1,"{")==1) writing=1;

}' <$1_$2.C |\
sed 's/\[\([0-9]*\)\]/(\1)/g' >> $1_$2.cc

# Tail
cat >> $1_$2.cc <<EOF

EOF

case "$2" in
    ode)
        echo "return octave_value (mttdx);" >> $1_$2.cc;
	;;
    odeo)
        echo "return octave_value (mtty); " >> $1_$2.cc;
	;;
    cse)
        echo "return octave_value (mttdx);" >> $1_$2.cc;
	;;
    cseo)
        echo "return octave_value (mtty); " >> $1_$2.cc;
	;;
    smxa)
        echo "return octave_value (mtta); " >> $1_$2.cc;
	;;
    smxax)
        echo "return octave_value (mttax); " >> $1_$2.cc;
	;;
    *)
	

esac

# Terminating }
echo "}" >> $1_$2.cc;
# Convert to octave loadable code
echo Creating $1_$2.oct
mkoctfile $1_$2.cc


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