1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
+
+
+
|
#!/bin/sh
# Generates function header for a computer language
# PJ Gawthrop May 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2 1998/05/24 12:47:39 peterg
## This still needs worjk doing for c generation!!
##
## Revision 1.1 1998/05/23 16:17:40 peterg
## Initial revision
##
###############################################################
# Set up the language specific stuff
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
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
|
+
+
+
+
+
+
+
-
+
|
c)
ext='c';
Lc='/*';
Rc='*/';
Lb='[';
Rb=']';
;;
java)
ext='java';
Lc='/*';
Rc='*/';
Lb='[';
Rb=']';
;;
*)
echo Language $language not supported - sorry; exit 1
esac
######### Octave (matlab) code
if [ "$language" = m ]; then
cat <<EOF
function $output = $1_$rep($args);
% $output = $1_ode($args);
% $output = $1_$rep($args);
%System $system, representation $rep, language $language;
%File $1_$rep.$ext;
%Generated by MTT on `date`;
%
EOF
fi
|
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
|
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
printf("$Lc Time $Rc\n");
printf(" double t;\n");
printf("\n");
EOF
fi
if [ "$language" = "java" ]; then
cat <<EOF
public class $1_ode{
/*
System $system, representation $rep, language $language;
File $1_$rep.$ext;
Generated by MTT on `date`;
*/
EOF
fi
# Any extra bits ..
if [ -n "$extras" ]; then
cat <<EOF
$Lc Extra bits here $Rc
$extras
EOF
fi
# Globals
sympar2global_txt2lang $1 $language
if [ "$language" = "c" ] || [ "$language" = "m" ]; then
# Common part - ode
# Common part - ode (c and m)
# Use octave for this bit - needs the definition file
$MATRIX -q <<EOF
%System structure
[nx,ny,nu,nz,nyz] = $1_def;
printf("$Lc====== Read in the input ======$Rc\n");
printf("mttu = $1_input(mttx,t);\n");
printf("\n");
#printf("$Lc====== Read in the input ======$Rc\n");
#printf("mttu = $1_input(mttx,t);\n");
#printf("\n");
printf("$Lc====== Set up the state variables ======$Rc\n");
for i = 1:nx
printf(" mttx%i = mttx$Lb%i$Rb;\n",i,i);
end;
printf("\n");
printf("$Lc====== Set up the input variables ======$Rc\n");
for i = 1:nu
printf(" mttu%i = mttu$Lb%i$Rb;\n",i,i);
end;
printf("\n");
EOF
fi
#if [ "$language" = "java" ]; then
#$MATRIX -q <<EOF
# printf("JAVA\n");
#EOF
#fi
|