Differences From Artifact [fdd2d8ef52]:

To Artifact [2d421e6110]:


11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.13  1998/08/11 09:32:07  peterg
## Added comments at procedure begin and end.
##
## Revision 1.12  1998/07/30 11:30:42  peterg
## Included zeros function
##
## Revision 1.11  1998/07/29 14:18:34  peterg







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  1998/08/12 15:21:12  peterg
## Added type definition for the SVD procedures
##
## Revision 1.13  1998/08/11 09:32:07  peterg
## Added comments at procedure begin and end.
##
## Revision 1.12  1998/07/30 11:30:42  peterg
## Included zeros function
##
## Revision 1.11  1998/07/29 14:18:34  peterg
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
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    smx)
	echo "PROCEDURE $Sys_rep(VAR mtta : StateMatrix;"






	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector);"


	;;
    ode2odes)
	echo "PROGRAM $Sys_rep;"
	echo "TYPE"
	echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"
	echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"
	echo "    OutputVector = ARRAY[1..$Ny] OF REAL;"
	echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;"
	echo "    glnparray = StateVector;"
	echo "    glmparray = StateVector;"

	echo "    glnpbynp = StateMatrix;"
	echo "    glmpbynp = StateMatrix;"
	echo "    IntegrationMethod = 1..3;"

	echo "VAR"
        echo "    MTTt,mttLAST,mttDT,mttDDT   : REAL;"
        echo "    MTTWMIN,mttWMAX             : REAL;"
	echo "    mttx,mttdx                  : StateVector;"
	echo "    mttu                        : InputVector;"
	echo "    mtty                        : OutputVector;"
	echo "    mttA                        : StateMatrix;"
	echo "    MTTi,MTTj,MTTit,MTTiLast,mttSTEPFACTOR,mttWSTEPS : INTEGER;"
	echo "    mttMETHOD : IntegrationMethod;"

        ;;
    switch)
	echo "PROCEDURE $Sys_rep(VAR mttxs : StateVector;"
	echo "                       mttx  : StateVector);"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
	;;







>
>
>
>
>
>
|
|
>
>








|
|
>
|
|
|
>



|


|
|

>







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
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    smx)
	echo "PROCEDURE $Sys_rep(VAR mtta : StateMatrix;"
	echo "                   VAR mttx : StateVector;"
	echo "                   VAR mttu : InputVector;"
	echo "                       mttdt : REAL);"
	;;
    smxx|smxtx)
	echo "PROCEDURE $Sys_rep(VAR mttax : StateVector;"
	echo "                       mttx  : StateVector;"
	echo "                       mttu  : InputVector;"
	echo "                       mttxx : StateVector;"
	echo "                       mttdt : REAL);"
	;;
    ode2odes)
	echo "PROGRAM $Sys_rep;"
	echo "TYPE"
	echo "    StateVector  = ARRAY[1..$Nx] OF REAL;"
	echo "    InputVector  = ARRAY[1..$Nu] OF REAL;"
	echo "    OutputVector = ARRAY[1..$Ny] OF REAL;"
	echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;"
	echo "    glnparray    = StateVector;"
	echo "    glmparray    = StateVector;"
	echo "    glnarray     = StateVector;"
	echo "    glnpbynp     = StateMatrix;"
	echo "    glmpbynp     = StateMatrix;"
	echo "    IntegrationMethod = 1..4;"
	echo ""
	echo "VAR"
        echo "    MTTt,mttLAST,mttDT,mttDDT   : REAL;"
        echo "    MTTWMIN,mttWMAX             : REAL;"
	echo "    mttx,mttdx,mttxx,mttAAx     : StateVector;"
	echo "    mttu                        : InputVector;"
	echo "    mtty                        : OutputVector;"
	echo "    mttAA                       : StateMatrix;"
	echo "    MTTi,MTTj,MTTit,MTTjt,MTTiLast,mttSTEPFACTOR,mttWSTEPS,mttSTEPS : INTEGER;"
	echo "    mttMETHOD : IntegrationMethod;"
	echo ""
        ;;
    switch)
	echo "PROCEDURE $Sys_rep(VAR mttxs : StateVector;"
	echo "                       mttx  : StateVector);"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
	;;
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

{*** System $Sys, rep $rep, language Pascal, file $Filename ***}
{*** Translated by MTT from $Sys_rep.m on `date` ***}

EOF

#Regexps
  name="[a-zA-Z0-9]*"
  fun_name="$Sys\_$name"
  mttfun_name="mtt_update"
  space="[ \t]*"
  spaces="[ \t][ \t]*"
  non_space="[^ ]*"

# Body	
grep -v '^[ ]*function' < $Sys_rep.m  | sed "s/^$space%/#/" |\
awk -F# '{printf("%s",$1) 







|

|







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

{*** System $Sys, rep $rep, language Pascal, file $Filename ***}
{*** Translated by MTT from $Sys_rep.m on `date` ***}

EOF

#Regexps
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  space="[ \t]*"
  spaces="[ \t][ \t]*"
  non_space="[^ ]*"

# Body	
grep -v '^[ ]*function' < $Sys_rep.m  | sed "s/^$space%/#/" |\
awk -F# '{printf("%s",$1) 
206
207
208
209
210
211
212
213
214















215
216
217
218

219
220
221
222
223
224
225
226

227
228
229
230
231
232
233
        if (rep=="ode2odes"){
          printf("VAR ");
          for (k=1;k<i;k++) printf("%s,",global[k])
          printf("%s : REAL;\n", global[i])
          printvar("x",Nx);
          printvar("u",Nu);
          printvar("y",Ny);
          printvar("t",Nt);
















          printf("{%s sign.p}\n",inc,sys)
          printf("{%s mtt_update.p}\n",inc)
          printf("{%s mtt_write.p}\n",inc)
          printf("{%s zeros.p}\n",inc)

          printf("{%s %s_simpar.p}\n",inc,sys) 
          printf("{%s %s_numpar.p}\n",inc,sys)
          printf("{%s %s_state.p}\n",inc,sys)
          printf("{%s %s_input.p}\n",inc,sys)
          printf("{%s %s_ode.p}\n",inc,sys)
          printf("{%s %s_odeo.p}\n",inc,sys)
          printf("{%s %s_smx.p}\n",inc,sys)
          printf("{%s %s_switch.p}\n",inc,sys)

          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN{%s}\n", Sys_rep)
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")







|

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


|
>






<
|
>







220
221
222
223
224
225
226
227
228
229
230
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
260
261
262
263
        if (rep=="ode2odes"){
          printf("VAR ");
          for (k=1;k<i;k++) printf("%s,",global[k])
          printf("%s : REAL;\n", global[i])
          printvar("x",Nx);
          printvar("u",Nu);
          printvar("y",Ny);
          printvar("_t",Nt);

          printf("\n{%s %s_smx.p}\n",inc,sys)
          printf("{%s %s_smxx.p}\n",inc,sys)
          printf("{%s %s_smxtx.p}\n\n",inc,sys)

          printf("\nPROCEDURE mtt_asub(VAR x,y : StateVector; n : INTEGER);\n");
          printf("{Sparse update routine -- y = Ax}\n");
          printf("BEGIN {asub}\n");
          printf("  %s_smxx(y,mttx,mttu,x,mttdt);\n", Sys);
          printf("END {asub};\n");
          printf("\nPROCEDURE mtt_atsub(VAR x,y : StateVector; n : INTEGER);\n");
          printf("{Sparse update routine -- y = ATx}\n");
          printf("BEGIN {atsub}\n");
          printf("  %s_smxtx(y,mttx,mttu,x,mttdt);\n", Sys);
          printf("END {atsub};\n\n");

          printf("\n{%s sign.p}\n",inc,sys)
          printf("{%s mtt_update.p}\n",inc)
          printf("{%s mtt_write.p}\n",inc)
          printf("{%s zero_matrix.p}\n",inc)
          printf("{%s zero_vector.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,sys) 
          printf("{%s %s_numpar.p}\n",inc,sys)
          printf("{%s %s_state.p}\n",inc,sys)
          printf("{%s %s_input.p}\n",inc,sys)
          printf("{%s %s_ode.p}\n",inc,sys)
          printf("{%s %s_odeo.p}\n",inc,sys)

          printf("{%s %s_switch.p}\n\n",inc,sys)

          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN{%s}\n", Sys_rep)
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
    printf("IMPLICIT = 3;\n")
    }
    else
      if (rep=="ode2odes")
                printf("END{%s}.\n", Sys_rep)
      else
        printf("END{%s};\n", Sys_rep)
}' sys=$sys Sys_rep=$Sys_rep rep=$rep Nx=$Nx Nu=$Nu Ny=$Ny |\
sed 's/(\([ijk0-9,]*\))/\[\1\]/g'  |\
sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g' \
>> $Filename

# p2c doesn't like mixed case filenames!
if [ "$Filename" != "$filename" ]; then
  echo Creating $filename
  cp -f $Filename $filename
fi









|











305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
    printf("IMPLICIT = 3;\n")
    }
    else
      if (rep=="ode2odes")
                printf("END{%s}.\n", Sys_rep)
      else
        printf("END{%s};\n", Sys_rep)
}' Sys=$Sys sys=$sys Sys_rep=$Sys_rep rep=$rep Nx=$Nx Nu=$Nu Ny=$Ny |\
sed 's/(\([ijk0-9,]*\))/\[\1\]/g'  |\
sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g' \
>> $Filename

# p2c doesn't like mixed case filenames!
if [ "$Filename" != "$filename" ]; then
  echo Creating $filename
  cp -f $Filename $filename
fi



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