Index: mttroot/mtt/bin/trans/mtt_r2m ================================================================== --- mttroot/mtt/bin/trans/mtt_r2m +++ mttroot/mtt/bin/trans/mtt_r2m @@ -14,10 +14,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.1 1998/07/27 16:30:26 peterg +## Initial revision +## ############################################################### # Set up the language specific stuff rep=$2 @@ -65,47 +68,44 @@ # Remove the old log file rm -f mtt_r2lang.log #Remove the temporary files -rm -f $1_$rep.$ext.1 - -#Header -lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_$rep.$ext +rm -f $outfile.* if [ "$rep" = "ode" ]; then echo Creating $1_odea.$ext echo Creating $1_odeo.$ext rm -f $1_odeo.$ext.1; rm -f $1_odea.$ext.1; #Header - lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_$rep.$ext + lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $outfile.1 # Use reduce to accomplish the transformation $SYMBOLIC >mtt_r2lang.log << EOF %Set up the code generator in"mtt_setreduce.r"; % The body of the ode function - GENTRANOUT "$1_ode.$ext.1"; + GENTRANOUT "$outfile.3"; mtt_matrix := MTTdX$ mtt_matrix_n := MTTNx$ mtt_matrix_m := 1$ mtt_matrix_name := 'MTTdX$ lang_matrix(); - GENTRANSHUT "$1_ode.$ext.1"; - - % The algebraic equations (if any) - GENTRANOUT "$1_odea.$ext.1"; - mtt_matrix := MTTYz$ - mtt_matrix_n := MTTNYz$ - mtt_matrix_m := 1$ - mtt_matrix_name := MTTYz$ - lang_matrix(); - GENTRANSHUT "$1_odea.$ext.1"; + GENTRANSHUT "$outfile.3"; + +%% % The algebraic equations (if any) +%% GENTRANOUT "$1_odea.$ext.1"; +%% mtt_matrix := MTTYz$ +%% mtt_matrix_n := MTTNYz$ +%% mtt_matrix_m := 1$ +%% mtt_matrix_name := MTTYz$ +%% lang_matrix(); +%% GENTRANSHUT "$1_odea.$ext.1; % Now do the y = g(x,t) function. % The body of the odeo function GENTRANOUT "$1_odeo.$ext.1"; @@ -115,11 +115,12 @@ mtt_matrix_name := MTTy$ lang_matrix(); GENTRANSHUT "$1_odeo.$ext.1"; EOF - + cat $1_odeo.$ext.1 + # Algebraic bits $MATRIX -q <> $1_ode.$ext %System structure [nx,ny,nu,nz,nyz] = $1_def; if nyz>0 @@ -151,17 +152,17 @@ printf("\n"); end; EOF - cat <> $outfile.O + cat <> $outfile.2 $Lc The differential equations $Rc EOF - sed 's/mtt_matrix/mttdx/' $1_ode.$ext.1 >> $1_ode.$ext - + sed 's/mtt_matrix/mttdx/' $outfile.3 > $outfile.4 + rm -f $outfile.3 # Create the odea.$ext function lang_header $1 odea $ext 'mttui' mttyz 'global mttxx mttt; mttx = mttxx; t=mttt;' > $1_odea.$ext $MATRIX -q <> $1_odea.$ext @@ -215,20 +216,30 @@ # Convert from Pascal syntax to Octave syntax mv $1_odeo.m mtt_junk; mtt_p2m $1_odeo.m mv $1_odea.m mtt_junk; mtt_p2m $1_odea.m fi +if [ "$rep" = "sm" ]||[ "$rep" = "dm" ]; then + if [ "$rep" = "sm" ]; then - - #Header - lang_header $1 $rep $ext 'mttx,mttu' [mtta,mttb,mttc,mttd] > $1_$rep.$ext + #Header + lang_header $1 $rep $ext '' [mtta,mttb,mttc,mttd] > $outfile.A + Symbols='a b c d' +fi - -Symbols='a b c d' +if [ "$rep" = "dm" ]; then + #Header + lang_header $1 $rep $ext '' [mtta,mttb,mttc,mttd,mtte] > $outfile.A + Symbols='a b c d e' +fi + for Symbol in $Symbols; do rm -f $outfile.1 - case $Symbol in + + +if [ "$rep" = "sm" ]; then + case $Symbol in a) N=MTTNx; M=MTTNx ;; b) N=MTTNx; M=MTTNu @@ -237,14 +248,38 @@ N=MTTNy; M=MTTNx ;; d) N=MTTNy; M=MTTNu ;; + e) + N=MTTNx; M=MTTNx + ;; *) -esac - + esac +else + NN=MTTNx+2*MTTNz+MTTNyz + case $Symbol in + a) + N=$NN; M=$NN + ;; + b) + N=$NN; M=MTTNu + ;; + c) + N=MTTNy; M=$NN + ;; + d) + N=MTTNy; M=MTTNu + ;; + e) + N=$NN; M=$NN + ;; + *) + esac + +fi $SYMBOLIC << EOF >mtt_r2m.log %Set up the code generator in"mtt_setreduce.r"; @@ -269,10 +304,11 @@ rm -f $outfile.[12] fi # Convert from Pascal syntax to Octave syntax -cat $outfile.? | mtt_p2m >> $outfile +cat $outfile.? | mtt_p2m > $outfile + rm -f $outfile.?