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.17 2000/05/20 15:23:56 peterg
## Paramererised version of sm etc etc (using -parameter switch)
##
## Revision 1.16 2000/04/18 11:14:18 peterg
## Put in the -parameters option
##
## Revision 1.15 2000/02/10 14:58:57 peterg
## *** empty log message ***
##
## Revision 1.14 1999/12/08 02:06:00 peterg
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
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
|
+
-
+
+
+
-
+
+
+
+
+
|
Nx=`grep "MTTNx " <$1_def.r | awk '{print $3}' | sed 's/;//'`
#Set up gentran
cat <<EOF >mtt_setreduce.r
% Set up the code generator
% Load the general translator package
LOAD GENTRAN;
LOAD SCOPE;
GENTRANLANG!* := '$codegenerator;
ON GENTRANSEG;
ON GENTRANSEG; % Segmentation
ON GENTRANOPT; % Code optimise using scope
OFF GENDECS; % No declarations
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_t;
TEMPVARNAME!* := 'mtt_s;
% Output control
ON DIV;
ON EXP;
% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";
%Read the reduce definitions file
in "$1_def.r";
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
-
-
+
+
|
#echo Creating $1_odea.$ext
outfileo=$outfile"o"
echo Creating $outfileo.m
#rm -f $1_odea.$ext.1;
#Header
lang_header $noglobals $parameters $1 $rep $ext 'mttx,mttu,mttt,mttpar' mttdx > $1_$2.p
lang_header $noglobals $parameters $1 $2o $ext 'mttx,mttu,mttt,mttpar' mtty > $1_$2o.p
lang_header $noglobals $parameters $1 $rep $ext 'mttx,mttu,mttt,mttpar' mttdx > $1_$2.pas
lang_header $noglobals $parameters $1 $2o $ext 'mttx,mttu,mttt,mttpar' mtty > $1_$2o.pas
rm -f mtt_ode mtt_odeo
# Use reduce to accomplish the transformation
$SYMBOLIC > mtt_r2m.log <<EOF
%Set up the code generator
in"mtt_setreduce.r";
|
211
212
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
253
254
255
256
257
258
259
260
261
|
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
|
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
fi
#if [ "$rep" = "ode" ]; then
# touch mtt_odee
#fi
sed 's/mtt_matrix/mttdx/' <mtt_ode >> $1_$2.p
#sed 's/mtt_matrix/mtte/' <mtt_odee >> $1_$2.p
sed 's/mtt_matrix/mtty/' <mtt_odeo >> $1_$2o.p
sed 's/mtt_matrix/mttdx/' <mtt_ode >> $1_$2.pas
#sed 's/mtt_matrix/mtte/' <mtt_odee >> $1_$2.pas
sed 's/mtt_matrix/mtty/' <mtt_odeo >> $1_$2o.pas
rm -f mtt_odeo mtt_ode #mtt_odee
#rm -f mtt_odeo mtt_ode #mtt_odee
# Convert from Pascal syntax to Octave syntax
mtt_p2m<$1_$2o.p > $1_$2o.m
mtt_p2m<$1_$2o.pas > $1_$2o.m
rm -f $1_odeo.p
rm -f $1_odeo.pas
fi
if [ "$rep" = "sm" ]||[ "$rep" = "ssm" ]||[ "$rep" = "dm" ]||\
[ "$rep" = "csm" ]||[ "$rep" = "obs" ]; then
if [ "$rep" = "sm" ]||[ "$rep" = "ssm" ]; then
#Header
lang_header $noglobals $parameters $1 $rep $ext "$par" [mtta,mttb,mttc,mttd] > $outfile.p
lang_header $noglobals $parameters $1 $rep $ext "$par" [mtta,mttb,mttc,mttd] > $outfile.pas
Symbols='a b c d'
fi
if [ "$rep" = "dm" ]||[ "$rep" = "csm" ]; then
#Header
lang_header $noglobals $parameters $1 $rep $ext "$par" [mtta,mttb,mttc,mttd,mtte] > $outfile.p
lang_header $noglobals $parameters $1 $rep $ext "$par" [mtta,mttb,mttc,mttd,mtte] > $outfile.pas
Symbols='a b c d e'
fi
if [ "$rep" = "obs" ]; then
# Is the system affine (look in the _obs.r file
affine=`grep 'affine :=' $1_obs.r | awk '{print $3}' | sed 's/;//'`
echo 'affine = ' $affine
#Header
if [ "$affine" = "1" ]; then
lang_header $noglobals $parameters $1 obs m mttx [mttobs_o,mttobs_h] > $outfile.p
lang_header $noglobals $parameters $1 obs m mttx [mttobs_o,mttobs_h] > $outfile.pas
else
lang_header $noglobals $parameters $1 obs m mttx,mttu mttyy > $outfile.p
lang_header $noglobals $parameters $1 obs m mttx,mttu mttyy > $outfile.pas
fi
Symbols='obs_o obs_h'
fi
for Symbol in $Symbols; do
rm -f $outfile.1
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
-
-
+
+
-
+
-
+
-
+
|
mtt_matrix_n := $N;
mtt_matrix_m := $M;
lang_matrix();
GENTRANSHUT "$outfile.1";
EOF
echo "%$Symbol matrix#" >> $outfile.p
cat mtt_zero.m >> $outfile.p
echo "%$Symbol matrix#" >> $outfile.pas
cat mtt_zero.m >> $outfile.pas
sed "s/mtt_matrix/mtt$Symbol/" < $outfile.1 |\
grep -v '=0\.0;' >> $outfile.p
grep -v '=0\.0;' >> $outfile.pas
done
fi
# Convert from Pascal syntax to Octave syntax
mtt_p2m <$outfile.p > $outfile.m
mtt_p2m <$outfile.pas > $outfile.m
rm -f $outfile.p
rm -f $outfile.pas
rm -f mtt_zero.m
rm -f $outfile.1
|