︙ | | | ︙ | |
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.18 2000/12/03 16:06:22 peterg
## Fixed bug in generating dummies
## Added logic declarations
##
## Revision 1.17 2000/12/01 20:55:01 peterg
## Added Geraint's fix for zeroing matrices
##
|
>
>
>
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.19 2000/12/03 16:11:43 peterg
## Corrected bug in logic declatations
##
## Revision 1.18 2000/12/03 16:06:22 peterg
## Fixed bug in generating dummies
## Added logic declarations
##
## Revision 1.17 2000/12/01 20:55:01 peterg
## Added Geraint's fix for zeroing matrices
##
|
︙ | | | ︙ | |
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
states=no;
inputs=no;
parameters=yes;
output=mttopen
args=$eqnargs
declareinputs=yes
declarestates=yes
;;
numpar)
states=no;
inputs=no;
parameters=no;
output='mttpar'
;;
|
>
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
states=no;
inputs=no;
parameters=yes;
output=mttopen
args=$eqnargs
declareinputs=yes
declarestates=yes
declareswitches=yes
;;
numpar)
states=no;
inputs=no;
parameters=no;
output='mttpar'
;;
|
︙ | | | ︙ | |
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
|
declaration="$Output$1_$rep$Args;"
noglobals=true; # Fudge to make mtt_m2p work
start='## BEGIN Code'
finish='## END Code'
var_declaration=$Lc
declarestates=no
declareinputs=no
;;
txt)
modeline='## -*-octave-*- Put Emacs into octave-mode ##';
Lc='##';
Rc='';
Lb='(';
Rb=')';
function=""
declaration=""
start=''
parameters=no
states=no
inputs=no
declarestates=no
declareinputs=no
;;
oct)
modeline="// -*-c++-*- Put Emacs into c++-mode";
Lc='//';
oct_header=yes;
constant_declaration="const double "
var_declaration="double "
|
>
>
|
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
|
declaration="$Output$1_$rep$Args;"
noglobals=true; # Fudge to make mtt_m2p work
start='## BEGIN Code'
finish='## END Code'
var_declaration=$Lc
declarestates=no
declareinputs=no
declareswitches=no
;;
txt)
modeline='## -*-octave-*- Put Emacs into octave-mode ##';
Lc='##';
Rc='';
Lb='(';
Rb=')';
function=""
declaration=""
start=''
parameters=no
states=no
inputs=no
declarestates=no
declareinputs=no
declareswitches=no
;;
oct)
modeline="// -*-c++-*- Put Emacs into c++-mode";
Lc='//';
oct_header=yes;
constant_declaration="const double "
var_declaration="double "
|
︙ | | | ︙ | |
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
;;
*)
esac
echo " mtt$name = zeros($N,$M);"
done
}
function declare_dummies(){
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
grep "${dummy}[0-9]* " < ${fun_name}.m |\
awk '{
# if (match(dummy,$1)==1)
print $1
}' dummy=$dummy | sort -u >> mtt_dummies
done
dummy_list=`sort -u mtt_dummies`
# Comments
cat <<EOF
$Lc Declarations of dummies $Rc
EOF
for dummy in $dummy_list; do
echo ' ' $var_declaration $dummy';'
done
} # declare_dummies
function declare_vars(){
# Grab the names
names=`awk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`
# Comments
cat <<EOF
|
>
|
>
>
>
>
>
>
>
>
|
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
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
|
;;
*)
esac
echo " mtt$name = zeros($N,$M);"
done
}
function declare_dummies(){
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
grep "${dummy}[0-9]* " < ${fun_name}.m |\
awk '{
# if (match(dummy,$1)==1)
print $1
}' dummy=$dummy >> mtt_dummies
done
dummy_list=`sort -u mtt_dummies`
# Comments
cat <<EOF
$Lc Declarations of dummies $Rc
EOF
for dummy in $dummy_list; do
echo ' ' $var_declaration $dummy';'
done
} # declare_dummies
function declare_switches {
cat <<EOF
$Lc Declarations of switches $Rc
EOF
strip_comments <${system}_switch.txt |\
awk '{printf(" double %s_logic = 0;\n", tolower($1))}'
} # declare_switches
function declare_vars(){
# Grab the names
names=`awk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`
# Comments
cat <<EOF
|
︙ | | | ︙ | |
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF
$Lc Parameters $Rc
EOF
sympar2par_txt2m ${system} "" "$constant_declaration" "$minusone"
cat <<EOF
$Lc Switches $Rc
EOF
strip_comments <${system}_switch.txt | awk '{printf(" int %s = 0;\n", tolower($1))}'
fi
# States
if [ "$states" = "yes" ]; then
cat <<EOF
$Lc States $Rc
|
<
<
<
<
<
<
|
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF
$Lc Parameters $Rc
EOF
sympar2par_txt2m ${system} "" "$constant_declaration" "$minusone"
fi
# States
if [ "$states" = "yes" ]; then
cat <<EOF
$Lc States $Rc
|
︙ | | | ︙ | |
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
if [ "$declareinputs" = "yes" ]; then
declare_vars input
fi
if [ "$declaredummies" = "yes" ]; then
declare_dummies
fi
zero_matrices;
}
# Argument specific stuff
function get_arg_specific_stuff ()
|
>
>
>
>
>
|
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
if [ "$declareinputs" = "yes" ]; then
declare_vars input
fi
if [ "$declaredummies" = "yes" ]; then
declare_dummies
fi
if [ "$declareswitches" = "yes" ]; then
declare_switches
fi
zero_matrices;
}
# Argument specific stuff
function get_arg_specific_stuff ()
|
︙ | | | ︙ | |