8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# Constrained-state equation to state matrices with x vector
# Used for implicit integration
# Copyright (C) 2000 by Peter J. Gawthrop
## Modified from eailier version
# Args
while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
-noglobals)
noglobals='-noglobals';
;;
-parameters)
parameters='-parameters';
;;
*)
echo $1 is an unknown option
exit;;
esac
shift
done
|
>
>
>
>
>
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# Constrained-state equation to state matrices with x vector
# Used for implicit integration
# Copyright (C) 2000 by Peter J. Gawthrop
## Modified from eailier version
# Args
## Now default to matrix form
matrix='yes'
while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
-noglobals)
noglobals='-noglobals';
;;
-parameters)
parameters='-parameters';
;;
-matrix)
matrix='yes';
;;
*)
echo $1 is an unknown option
exit;;
esac
shift
done
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
rep=$2
fi
case $rep in
smx)
nrep=0;
out='[mtta,mttax]';
;;
smxa)
nrep=1;
out='mtta';
;;
smxax)
nrep=2
out='mttax';
;;
*) echo Representation $2 not recognised;
exit;;
esac
# Inform user
echo Creating $1_$rep.$lang
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang
# Remove the old log file
rm -f cse2smx_r.log
rm -f $1_smx.$lang
rm -f $1_smxx.$lang
|
>
|
>
>
>
>
>
>
>
>
|
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
rep=$2
fi
case $rep in
smx)
nrep=0;
out='[mtta,mttax]';
nmatrix=1;
;;
smxa)
nrep=1;
if [ -n "$matrix" ]; then
blurb="in matrix form";
nmatrix=1;
else
blurb="in vector form";
nmatrix=0;
fi
out='mtta';
;;
smxax)
nrep=2
out='mttax';
nmatrix=0;
;;
*) echo Representation $2 not recognised;
exit;;
esac
# Inform user
echo Creating $1_$rep.$lang $blurb
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang
# Remove the old log file
rm -f cse2smx_r.log
rm -f $1_smx.$lang
rm -f $1_smxx.$lang
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
clear mttx; % Dont need this now - use mkid instead
OFF Echo;
% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'Pascal;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 120;
TEMPVARNUM!* := 1;
TEMPVARNAME!* := 'mtt_t;
% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";
%Set up output according to the language.
OFF NAT;
GENTRANOUT "$1_$rep.body";
% Set up output according to the language.
|
>
|
>
>
|
|
|
|
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
|
clear mttx; % Dont need this now - use mkid instead
OFF Echo;
% Load the general translator package
LOAD GENTRAN;
LOAD SCOPE;
GENTRANLANG!* := 'Pascal;
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";
%Set up output according to the language.
OFF NAT;
GENTRANOUT "$1_$rep.body";
% Set up output according to the language.
|
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
|
FOR j := 1:MTTNx DO
BEGIN
ij := i + MTTNx*(j-1);
xj := mkid(mttx,j);
a_ij := df(MTTEdx(i,1), xj, 1);
aa_ij := MTTE(i,j) - mttt*a_ij;
IF (aa_ij NEQ 0) THEN
IF ($nrep EQ 0) THEN
BEGIN
%% Write a and with full indexing
GENTRAN mtta(i,j) ::=: aa_ij;
END;
IF ($nrep EQ 1) THEN
BEGIN
%% Write a with vector indexing
GENTRAN mtta(ij) ::=: aa_ij;
END;
mttAAx_i := mttAAx_i + aa_ij*xj;
END;
IF (mttAAx_i NEQ 0) THEN
IF (($nrep EQ 0) OR ($nrep EQ 2)) THEN
GENTRAN mttax(i) ::=: mttAAx_i;
END;
%Shut the output according to the language.
GENTRANSHUT "$1_$rep.body";
EOF
if [ "$lang" = "m" ]; then
|
|
|
>
|
>
>
>
>
|
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
159
160
161
162
163
164
165
166
167
|
FOR j := 1:MTTNx DO
BEGIN
ij := i + MTTNx*(j-1);
xj := mkid(mttx,j);
a_ij := df(MTTEdx(i,1), xj, 1);
aa_ij := MTTE(i,j) - mttt*a_ij;
IF (aa_ij NEQ 0) THEN
IF ($nmatrix EQ 1) THEN
BEGIN
%% Write a with full indexing
INAME(mtt_o); % Set temp name
GENTRAN mtta(i,j) ::=: aa_ij;
END;
IF (($nmatrix EQ 0) AND ($nrep EQ 1)) THEN
BEGIN
%% Write a with vector indexing
INAME(mtt_o); % Set temp name
GENTRAN mtta(ij) ::=: aa_ij;
END;
mttAAx_i := mttAAx_i + aa_ij*xj;
END;
IF (mttAAx_i NEQ 0) THEN
IF (($nrep EQ 0) OR ($nrep EQ 2)) THEN
BEGIN
INAME(mtt_o); % Set temp name
GENTRAN mttax(i) ::=: mttAAx_i;
END;
END;
%Shut the output according to the language.
GENTRANSHUT "$1_$rep.body";
EOF
if [ "$lang" = "m" ]; then
|