︙ | | | ︙ | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# 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
|
>
>
>
|
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.18 2000/08/24 17:11:40 peterg
## Now optimises as well as segmenting - uses the SCOPE package
##
## 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
|
︙ | | | ︙ | |
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
|
## Find som constants
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; % Segmentation
ON GENTRANOPT; % Code optimise using scope
OFF GENDECS; % No declarations
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
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";
%Read the reduce $REP file
in "$1_$rep.r";
%Read the substitution file
in "$1_subs.r";
EOF
#Inform user
echo Creating $outfile.m
|
>
<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
## Find som constants
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; % Segmentation
ON GENTRANOPT; % Code optimise using scope
OFF GENDECS; % No declarations
MAXEXPPRINTLEN!* := 80;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_s;
% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";
%Read the reduce definitions file
in "$1_def.r";
%Read the reduce $REP file
in "$1_$rep.r";
%Read the substitution file
in "$1_subs.r";
%%% The following is a bug fix from ZIB to fix
%%% segmentation violation problem
symbolic procedure maxtype type;
% ------------------------------------------------------------------- ;
% A type may be a pair (l u) wher l is the minimum type for a variable;
% and u is the maximum type. This procedure returns the maximum type.;
% ------------------------------------------------------------------- ;
if atom type
then type
else if pairp cdr type then cadr type else car type;
% This fix handles the case that the type is a list with ONE entry.
% Should never happen ?? W.N.
%%%%%% End of bug fix
END;
EOF
#Inform user
echo Creating $outfile.m
|
︙ | | | ︙ | |
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
END;;
EOF
if [ "$rep" = "ode" ]; then
# Use reduce to accomplish the transformation
$SYMBOLIC > mtt_r2m.log <<EOF
%Set up the code generator
in"mtt_setreduce.r";
% The body of the ode function
GENTRANOUT "mtt_ode";
mtt_matrix := MTTdX$
mtt_matrix_n := MTTNx$
mtt_matrix_m := 1$
lang_matrix();
GENTRANSHUT "mtt_ode";
END;;
EOF
else
## cse representation
$SYMBOLIC > mtt_r2m.log <<EOF
%Set up the code generator
in"mtt_setreduce.r";
% The body of the cse function
GENTRANOUT "mtt_ode";
mtt_matrix := MTTEdX$
mtt_matrix_n := MTTNx$
|
|
|
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
END;;
EOF
if [ "$rep" = "ode" ]; then
# Use reduce to accomplish the transformation
$SYMBOLIC >> mtt_r2m.log <<EOF
%Set up the code generator
in"mtt_setreduce.r";
% The body of the ode function
GENTRANOUT "mtt_ode";
mtt_matrix := MTTdX$
mtt_matrix_n := MTTNx$
mtt_matrix_m := 1$
lang_matrix();
GENTRANSHUT "mtt_ode";
END;;
EOF
else
## cse representation
$SYMBOLIC >> mtt_r2m.log <<EOF
%Set up the code generator
in"mtt_setreduce.r";
% The body of the cse function
GENTRANOUT "mtt_ode";
mtt_matrix := MTTEdX$
mtt_matrix_n := MTTNx$
|
︙ | | | ︙ | |
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
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
if [ "$rep" = "sm" ]||[ "$rep" = "ssm" ]||[ "$rep" = "csm" ]||[ "$rep" = "obs" ]; then
case $Symbol in
a)
N=MTTNx; M=MTTNx
;;
b)
|
|
|
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
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
echo Doing $Symbol
if [ "$rep" = "sm" ]||[ "$rep" = "ssm" ]||[ "$rep" = "csm" ]||[ "$rep" = "obs" ]; then
case $Symbol in
a)
N=MTTNx; M=MTTNx
;;
b)
|
︙ | | | ︙ | |
319
320
321
322
323
324
325
326
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
356
357
358
359
360
361
362
363
364
365
|
fi
# Set up the matrices
rm -f mtt_zero.m
$SYMBOLIC << EOF >mtt_r2m.log
%Set up the code generator
in"mtt_setreduce.r";
OUT "mtt_zero.m";
write "mtt$Symbol = zeros(", $N, ",", $M , ");" ;
SHUT "mtt_zero.m";
GENTRANOUT "$outfile.1";
mtt_matrix := MTT$Symbol;
mtt_matrix_n := $N;
mtt_matrix_m := $M;
lang_matrix();
GENTRANSHUT "$outfile.1";
EOF
echo "%$Symbol matrix#" >> $outfile.pas
cat mtt_zero.m >> $outfile.pas
sed "s/mtt_matrix/mtt$Symbol/" < $outfile.1 |\
grep -v '=0\.0;' >> $outfile.pas
done
fi
# Convert from Pascal syntax to Octave syntax
mtt_p2m <$outfile.pas > $outfile.m
rm -f $outfile.pas
rm -f mtt_zero.m
rm -f $outfile.1
|
|
|
<
>
>
>
|
>
>
|
334
335
336
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
fi
# Set up the matrices
rm -f mtt_zero.m
$SYMBOLIC << EOF >>mtt_r2m.log
write "Doing ", "$Symbol";
%Set up the code generator
in"mtt_setreduce.r";
OUT "mtt_zero.m";
write "mtt$Symbol = zeros(", $N, ",", $M , ");" ;
SHUT "mtt_zero.m";
GENTRANOUT "$outfile.1";
mtt_matrix := MTT$Symbol;
mtt_matrix_n := $N;
mtt_matrix_m := $M;
lang_matrix();
GENTRANSHUT "$outfile.1";
END;
EOF
echo "%$Symbol matrix#" >> $outfile.pas
cat mtt_zero.m >> $outfile.pas
sed "s/mtt_matrix/mtt$Symbol/" < $outfile.1 |\
grep -v '=0\.0;' >> $outfile.pas
echo Done $Symbol
done
fi
# Convert from Pascal syntax to Octave syntax
mtt_p2m <$outfile.pas > $outfile.m
rm -f $outfile.pas
rm -f mtt_zero.m
#rm -f $outfile.1
# Now invoke the standard error handling.
mtt_error_r mtt_r2m.log
|