︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
+
+
+
|
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996, 1998
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.1 1998/07/27 16:30:26 peterg
## Initial revision
##
###############################################################
# Set up the language specific stuff
rep=$2
ext='m';
codegenerator='PASCAL'
|
︙ | | |
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
|
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
|
-
+
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
|
# Remove the old log file
rm -f mtt_r2lang.log
#Remove the temporary files
rm -f $1_$rep.$ext.1
rm -f $outfile.*
#Header
lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_$rep.$ext
if [ "$rep" = "ode" ]; then
echo Creating $1_odea.$ext
echo Creating $1_odeo.$ext
rm -f $1_odeo.$ext.1;
rm -f $1_odea.$ext.1;
#Header
lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_$rep.$ext
lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $outfile.1
# Use reduce to accomplish the transformation
$SYMBOLIC >mtt_r2lang.log << EOF
%Set up the code generator
in"mtt_setreduce.r";
% The body of the ode function
GENTRANOUT "$1_ode.$ext.1";
GENTRANOUT "$outfile.3";
mtt_matrix := MTTdX$
mtt_matrix_n := MTTNx$
mtt_matrix_m := 1$
mtt_matrix_name := 'MTTdX$
lang_matrix();
GENTRANSHUT "$1_ode.$ext.1";
GENTRANSHUT "$outfile.3";
% The algebraic equations (if any)
GENTRANOUT "$1_odea.$ext.1";
mtt_matrix := MTTYz$
mtt_matrix_n := MTTNYz$
mtt_matrix_m := 1$
mtt_matrix_name := MTTYz$
lang_matrix();
GENTRANSHUT "$1_odea.$ext.1";
%% % The algebraic equations (if any)
%% GENTRANOUT "$1_odea.$ext.1";
%% mtt_matrix := MTTYz$
%% mtt_matrix_n := MTTNYz$
%% mtt_matrix_m := 1$
%% mtt_matrix_name := MTTYz$
%% lang_matrix();
%% GENTRANSHUT "$1_odea.$ext.1;
% Now do the y = g(x,t) function.
% The body of the odeo function
GENTRANOUT "$1_odeo.$ext.1";
mtt_matrix := MTTy$
mtt_matrix_n := MTTNy$
mtt_matrix_m := 1$
mtt_matrix_name := MTTy$
lang_matrix();
GENTRANSHUT "$1_odeo.$ext.1";
EOF
cat $1_odeo.$ext.1
# Algebraic bits
$MATRIX -q <<EOF >> $1_ode.$ext
%System structure
[nx,ny,nu,nz,nyz] = $1_def;
if nyz>0
printf("global mttxx mttt;\n");
printf("mttxx = mttx; mttt=t;\n");
|
︙ | | |
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
-
+
-
-
+
+
|
printf(" mttdx$Lb%i$Rb = mttui%i;\n",i+nx,i);
end;
printf("\n");
end;
EOF
cat <<EOF >> $outfile.O
cat <<EOF >> $outfile.2
$Lc The differential equations $Rc
EOF
sed 's/mtt_matrix/mttdx/' $1_ode.$ext.1 >> $1_ode.$ext
sed 's/mtt_matrix/mttdx/' $outfile.3 > $outfile.4
rm -f $outfile.3
# Create the odea.$ext function
lang_header $1 odea $ext 'mttui' mttyz 'global mttxx mttt; mttx = mttxx; t=mttt;' > $1_odea.$ext
$MATRIX -q <<EOF >> $1_odea.$ext
%System structure
[nx,ny,nu,nz,nyz] = $1_def;
|
︙ | | |
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
sed 's/mtt_matrix/mtty/' $1_odeo.$ext.1 >> $1_odeo.$ext
# Convert from Pascal syntax to Octave syntax
mv $1_odeo.m mtt_junk; mtt_p2m<mtt_junk > $1_odeo.m
mv $1_odea.m mtt_junk; mtt_p2m<mtt_junk > $1_odea.m
fi
if [ "$rep" = "sm" ]; then
if [ "$rep" = "sm" ]||[ "$rep" = "dm" ]; then
if [ "$rep" = "sm" ]; then
#Header
lang_header $1 $rep $ext 'mttx,mttu' [mtta,mttb,mttc,mttd] > $1_$rep.$ext
Symbols='a b c d'
#Header
lang_header $1 $rep $ext '' [mtta,mttb,mttc,mttd] > $outfile.A
Symbols='a b c d'
fi
if [ "$rep" = "dm" ]; then
#Header
lang_header $1 $rep $ext '' [mtta,mttb,mttc,mttd,mtte] > $outfile.A
Symbols='a b c d e'
fi
for Symbol in $Symbols; do
rm -f $outfile.1
if [ "$rep" = "sm" ]; then
case $Symbol in
case $Symbol in
a)
N=MTTNx; M=MTTNx
;;
b)
N=MTTNx; M=MTTNu
;;
c)
N=MTTNy; M=MTTNx
;;
d)
N=MTTNy; M=MTTNu
;;
e)
N=MTTNx; M=MTTNx
;;
*)
esac
esac
else
NN=MTTNx+2*MTTNz+MTTNyz
case $Symbol in
a)
N=$NN; M=$NN
;;
b)
N=$NN; M=MTTNu
;;
c)
N=MTTNy; M=$NN
;;
d)
N=MTTNy; M=MTTNu
;;
e)
N=$NN; M=$NN
;;
*)
esac
fi
$SYMBOLIC << EOF >mtt_r2m.log
%Set up the code generator
in"mtt_setreduce.r";
out "$outfile.2";
write "mtt$Symbol = zeros(", $N, ",", $M, ");";
|
︙ | | |
267
268
269
270
271
272
273
274
275
276
277
278
|
302
303
304
305
306
307
308
309
310
311
312
313
314
|
-
+
+
|
done
rm -f $outfile.[12]
fi
# Convert from Pascal syntax to Octave syntax
cat $outfile.? | mtt_p2m >> $outfile
cat $outfile.? | mtt_p2m > $outfile
rm -f $outfile.?
|