Overview
Comment:Now does cse.m file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: ab8ae05167bb80fd0a9e4de8e50730ea13edf7e2f29ae6a1ab1e2c99251ee023
User & Date: gawthrop@users.sourceforge.net on 1999-10-26 23:47:58
Other Links: branch diff | manifest | tags
Context
1999-10-27
01:43:33
Initial revision check-in: 80e80788f1 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1999-10-26
23:47:58
Now does cse.m file check-in: ab8ae05167 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
23:45:30
Now calls mtt_solve instead of mtt_lud
(mtt_lud is now called by mtt_solve)
check-in: bb3161228e user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_r2m from [28abfd9a50] to [a2fa014777].

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.7  1999/03/16 00:38:06  peterg
## Done some more tidying up
##
## Revision 1.6  1999/03/15 07:29:25  peterg
## Fixed various obscure reduce bugs
## THIS NEEDS A MAJOR REWRITE!!!!
##







>
>
>







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.8  1999/07/26 06:07:19  peterg
## Reinstated removal of the odeo.p file
##
## Revision 1.7  1999/03/16 00:38:06  peterg
## Done some more tidying up
##
## Revision 1.6  1999/03/15 07:29:25  peterg
## Fixed various obscure reduce bugs
## THIS NEEDS A MAJOR REWRITE!!!!
##
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54



55
56
57
58
59
60
61
## Put in correct N and M values for dm rep
##
## Revision 1.1  1998/07/27 16:30:26  peterg
## Initial revision
##
###############################################################



# Set up the language specific stuff
rep=$2
ext='m';
codegenerator='PASCAL'
Lc='#';
Rc='#';
Lb='(';
Rb=')';

outfile=$1"_"$rep




#Set up gentran
cat <<EOF >mtt_setreduce.r
% Set up the code generator
% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := '$codegenerator;
ON GENTRANSEG;







>












>
>
>







39
40
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
## Put in correct N and M values for dm rep
##
## Revision 1.1  1998/07/27 16:30:26  peterg
## Initial revision
##
###############################################################



# Set up the language specific stuff
rep=$2
ext='m';
codegenerator='PASCAL'
Lc='#';
Rc='#';
Lb='(';
Rb=')';

outfile=$1"_"$rep

## 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;
GENTRANLANG!* := '$codegenerator;
ON GENTRANSEG;
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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







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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222


# Remove the old log file
rm -f mtt_r2m.log

#Remove the temporary files

if [ "$rep" = "ode" ]; then
  #echo Creating $1_odea.$ext
  outfileo=$outfile"o"
  echo Creating $outfileo.m

  #rm -f $1_odea.$ext.1;

  #Header
  lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_ode.p
  lang_header $1 odeo $ext 'mttx,mttu,t' mtty  > $1_odeo.p

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";
      
  % 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";
    

 








      % The body of the odeo function
     GENTRANOUT "mtt_odeo";
     mtt_matrix := MTTy$
     mtt_matrix_n := MTTNy$
     mtt_matrix_m := 1$
     lang_matrix(); 
     GENTRANSHUT "mtt_odeo";








END;;















EOF

     
#  cat $1_odeo.$ext.1

##  # Algebraic bits
##  $MATRIX -q  <<EOF  >> $1_ode.$ext
##    %System structure
##    [nx,ny,nu,nz,nyz] = $1_def;
##  if nyz>0
##    printf("global mttxx mttt;\n");
##    printf("mttxx = mttx; mttt=t;\n");
##  
##    printf("$Lc====== Extract the internal input variables ======$Rc\n");
##    for i = 1:nyz
##      printf("  mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx);
##    end;
##    printf("\n");
##  
##    printf("[mttui,info] = fsolve('$1_odea',mttui);\n");
##    printf("if (info!=1)\n"); 
##    printf("  error('fsolve has not converged')\n");
##    printf("end\n");
##    printf("\n");
##  
##    printf("$Lc====== Set up the internal input variables ======$Rc\n");
##    for i = 1:nyz
##      printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
##    end;
##    printf("\n");
##  
##    printf("$Lc====== Put internal input variables at end of state derivative ======$Rc\n");
##    for i = 1:nyz
##      printf(" mttdx$Lb%i$Rb = mttui%i;\n",i+nx,i);
##    end;
##    printf("\n");
##  end;
##  
##EOF
##  
  
  
##  # Create the odea.$ext function
##  lang_header $1 odea $ext 'mttui' mttyz 'global mttxx mttt; mttx = mttxx; t=mttt;' > $1_odea.$ext
##  
##  $MATRIX -q  <<EOF  >> $1_odea.$ext
##    %System structure
##    [nx,ny,nu,nz,nyz] = $1_def;
##  if nyz>0
##    printf("$Lc====== Set up the internal input variables ======$Rc\n");
##    for i = 1:nyz
##      printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
##    end;
##    printf("\n");
##  end;
##EOF
##  
##  cat <<EOF >> $1_odea.$ext
##  
##  % The algebraic equations
##EOF
##  sed 's/mtt_matrix/mttyz/' $1_odea.$ext.1 >> $1_odea.$ext
  
  
  # Create the odeo function
  
##$MATRIX -q  <<EOF  >> $1_odeo.p
##    %System structure
##    [nx,ny,nu,nz,nyz] = $1_def;
##  if nyz>0
##    printf("$Lc====== Extract the internal input variables ======$Rc\n");
##    for i = 1:nyz
##      printf("  mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx);
##    end;
##    printf("\n");
##  
##    printf("$Lc====== Set up the internal input variables ======$Rc\n");
##    for i = 1:nyz
##      printf("  mttui%i = mttui$Lb%i$Rb;\n",i,i);
##    end;
##    printf("\n");
##  end;
##EOF

sed 's/mtt_matrix/mttdx/' <mtt_ode  >> $1_ode.p
sed 's/mtt_matrix/mtty/'  <mtt_odeo >> $1_odeo.p

rm -f mtt_odeo mtt_ode

# Convert from Pascal syntax to Octave syntax 
 mtt_p2m<$1_odeo.p > $1_odeo.m 

 rm -f    $1_odeo.p
fi
  
if [ "$rep" = "sm" ]||[ "$rep" = "dm" ]; then

if [ "$rep" = "sm" ]; then







|







|
|

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













>
|
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>


>

>
>
>
>
>
>
>
>
>
>
>
>

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|


|







88
89
90
91
92
93
94
95
96
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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182





















































































183
184
185
186
187
188
189
190
191
192
193


# Remove the old log file
rm -f mtt_r2m.log

#Remove the temporary files

if [ "$rep" = "ode" ]||[ "$rep" = "cse" ]; then
  #echo Creating $1_odea.$ext
  outfileo=$outfile"o"
  echo Creating $outfileo.m

  #rm -f $1_odea.$ext.1;

  #Header
  lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_$2.p
  lang_header $1 $2o $ext 'mttx,mttu,t' mtty  > $1_$2o.p

  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";
      
    
    % The body of the odeo function
     GENTRANOUT "mtt_odeo";
     mtt_matrix := MTTy$
     mtt_matrix_n := MTTNy$
     mtt_matrix_m := 1$
     lang_matrix(); 
     GENTRANSHUT "mtt_odeo";

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 represnetation
echo doing cse
$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$
    mtt_matrix_m := 1$
    lang_matrix();
    GENTRANSHUT "mtt_ode";
    
    GENTRANOUT "mtt_odee";
    mtt_matrix := MTTE$
    mtt_matrix_n := MTTNx$
    mtt_matrix_m := MTTNx$
    lang_matrix();
    GENTRANSHUT "mtt_odee";

END;;

EOF

  fi

touch mtt_odee
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

if [ "$rep" = "cse" ]; then
cat <<EOF >>$1_$2.p

   ## Solve E dx = dxe;;
   mtt_solve(mttdx,mttE,mttdx,$Nx);; 
EOF
fi





















































































rm -f mtt_odeo mtt_ode mtt_odee

# Convert from Pascal syntax to Octave syntax 
 mtt_p2m<$1_$2o.p > $1_$2o.m 

 rm -f    $1_odeo.p
fi
  
if [ "$rep" = "sm" ]||[ "$rep" = "dm" ]; then

if [ "$rep" = "sm" ]; then


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]