︙ | | | ︙ | |
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.40 2002/04/17 16:23:59 geraint
## Partial fix for [ 545113 ] zeros missing in c++.
## Fixes -oct by removing duplicate initialisation (-c is still outstanding).
##
## Revision 1.39 2002/04/15 10:54:31 geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u" (Reduce:see NERO)).
|
>
>
>
|
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.41 2002/04/23 17:46:05 gawthrop
## _sim.m now returns time as third argument
##
## Revision 1.40 2002/04/17 16:23:59 geraint
## Partial fix for [ 545113 ] zeros missing in c++.
## Fixes -oct by removing duplicate initialisation (-c is still outstanding).
##
## Revision 1.39 2002/04/15 10:54:31 geraint
## Statically declare outputs and initialise to zero.
## This is necessary to prevent spurious values from being output when no assignments are made (i.e. when "y(i) := 0 for all u" (Reduce:see NERO)).
|
︙ | | | ︙ | |
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
if [ -z "$system" ]; then
echo 'Usage: mtt_header sys rep lang [stdin]'
exit
fi
# get octave version
octave_development=`octave --version | awk '{print $4}' | awk -F\. '{print $2}'`
case `$MATRIX --version | awk -F\. '{print $2}'` in
0) # stable
vector_value=vector_value
;;
1) # development
vector_value=column_vector_value
;;
*)
|
|
|
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
if [ -z "$system" ]; then
echo 'Usage: mtt_header sys rep lang [stdin]'
exit
fi
# get octave version
octave_development=`octave --version | gawk '{print $4}' | gawk -F\. '{print $2}'`
case `$MATRIX --version | gawk -F\. '{print $2}'` in
0) # stable
vector_value=vector_value
;;
1) # development
vector_value=column_vector_value
;;
*)
|
︙ | | | ︙ | |
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
get_sizes()
{
Nx=`mtt_getsize $system x` # States
Nxx=`mtt_getsize $system xx` # States x States
Nu=`mtt_getsize $system u` # Inputs
Ny=`mtt_getsize $system y` # Outputs
Nyz=`mtt_getsize $system yz` # Zero outputs
##Npar=`wc -l $system\_sympar.txt | awk '{print $1}'`
}
zero_matrices()
{
## Set matrices to zero
echo
## echo '## Set matrices to zero'
|
|
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
get_sizes()
{
Nx=`mtt_getsize $system x` # States
Nxx=`mtt_getsize $system xx` # States x States
Nu=`mtt_getsize $system u` # Inputs
Ny=`mtt_getsize $system y` # Outputs
Nyz=`mtt_getsize $system yz` # Zero outputs
##Npar=`wc -l $system\_sympar.txt | gawk '{print $1}'`
}
zero_matrices()
{
## Set matrices to zero
echo
## echo '## Set matrices to zero'
|
︙ | | | ︙ | |
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
declare_dummies()
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
grep "${dummy}[0-9]*[ \t\n]*=" < ${fun_name}.m |\
awk '{
if (match($1,dummy)==1)
print $1
}' dummy=$dummy >> mtt_dummies
done
dummy_list=`sort -u mtt_dummies`
|
|
|
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
declare_dummies()
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
grep "${dummy}[0-9]*[ \t\n]*=" < ${fun_name}.m |\
gawk '{
if (match($1,dummy)==1)
print $1
}' dummy=$dummy >> mtt_dummies
done
dummy_list=`sort -u mtt_dummies`
|
︙ | | | ︙ | |
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
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
declare_vars()
{
# Grab the names
names=`awk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`
# Comments
cat <<EOF
$Lc Declarations for $1 names $Rc
EOF
# Declarations
|
|
|
|
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
declare_switches ()
{
cat <<EOF
$Lc Declarations of switches $Rc
EOF
strip_comments <${system}_switch.txt |\
gawk '{printf(" double %s_logic = 0;\n", tolower($1))}'
} # declare_switches
declare_vars()
{
# Grab the names
names=`gawk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`
# Comments
cat <<EOF
$Lc Declarations for $1 names $Rc
EOF
# Declarations
|
︙ | | | ︙ | |
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
|
get_field ()
{ # parse comma separated string
s=${1:-""} # comma separated string
i=${2:-0} # field number in string
if [ 0 -eq ${i} ]; then # return number of fields
echo ${s} |\
awk -F\, '{ print NF }'
else # return ith field
echo ${s} |\
awk -F\, -v i=${i} '{ print $i }'
fi
}
get_extra_fields ()
{ # return list of words in s2 and not in s1
s1=${1:-""} # comma separated list
|
|
|
|
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
|
get_field ()
{ # parse comma separated string
s=${1:-""} # comma separated string
i=${2:-0} # field number in string
if [ 0 -eq ${i} ]; then # return number of fields
echo ${s} |\
gawk -F\, '{ print NF }'
else # return ith field
echo ${s} |\
gawk -F\, -v i=${i} '{ print $i }'
fi
}
get_extra_fields ()
{ # return list of words in s2 and not in s1
s1=${1:-""} # comma separated list
|
︙ | | | ︙ | |