Index: mttroot/mtt/bin/trans/dae2cse_r ================================================================== --- mttroot/mtt/bin/trans/dae2cse_r +++ mttroot/mtt/bin/trans/dae2cse_r @@ -13,13 +13,20 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.22 2002/06/28 15:35:47 geraint +## Commented out aej.r generation (not used yet). +## ## Revision 1.21 2002/06/28 10:13:40 geraint ## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y. ## +## Revision 1.20.2.1 2002/06/05 11:14:50 geraint +## ae.r now generated using def2write_r like cse?.r +## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r. +## ## Revision 1.20 2002/04/28 18:41:26 geraint ## Fixed [ 549658 ] awk should be gawk. ## Replaced calls to awk with call to gawk. ## ## Revision 1.19 2001/10/26 01:01:49 geraint @@ -135,23 +142,25 @@ esac shift done # Create the reduce output code +def2write_r $optimise $fixcc $1 ae def2write_r $optimise $fixcc $1 cse def2write_r $optimise $fixcc $1 csex # Version without E matrix def2write_r $optimise $fixcc $1 cseo +echo "Creating $1_ae.r $optimise_msg" echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg" echo "Creating $1_csex.r $optimise_msg" echo "Creating $1_cseo.r $optimise_msg" # Remove the old log file rm -f dae2cse_r.log # Remove some files -rm -f $1_cse.r? $1_cseo.r? +rm -f $1_ae.r? $1_cse.r? $1_cseo.r? # Use reduce to accomplish the transformation $SYMBOLIC >dae2cse_r.log << EOF %Read the formatting function @@ -327,21 +336,10 @@ % No algebraic variables left! MTTNYz := 0; END; % IF MTTNyz>0 and $solve -OUT "$1_ae.r"; -IF (MTTNyz>0) THEN % not $solve (or perhaps solution failed?) -BEGIN - WRITE "MATRIX MTTyz(",MTTNyz,",1)"; - WRITE "%File: $1_ae.r"; - FOR i := 1:MTTNyz DO - WRITE "MTTyz(",i,",1) := ",MTTyz(i,1)," +0"; -END; % if MTTNyz>0 (and !$solve) -WRITE ";END;"; -SHUT "$1_ae.r"; - %OUT "$1_aej.r"; %IF (MTTNyz>0) THEN % as above %BEGIN % WRITE "MATRIX MTTyzj(",MTTNyz,",",MTTNyz,")"; % WRITE "%File: $1_aej.r"; @@ -353,10 +351,22 @@ % WRITE "MTTyzj(",i,",",j,") := ",didj," +0"; % END; %END; %WRITE ";END;"; %SHUT "$1_aej.r"; + +IF MTTNyz>0 THEN % not $solve or solution failed +BEGIN +OUT "$1_ae.r1"; +write "MATRIX MTTYZ(", MTTNyz, ",", 1, ")$"; +SHUT "$1_ae.r1"; +END; +OUT "$1_ae.r2"; +write "%File: $1_ae.r"; +in ("$1_ae_write.r"); +write "END;"; +SHUT "$1_ae.r2"; % Create the matrix declarations OUT "$1_cse.r1"; write "%"; IF (MTTNx > 0) THEN @@ -453,12 +463,14 @@ SHUT "$1_cseo.r2"; END; quit; EOF +touch $1_ae.r1 $1_ae.r2 touch $1_cseo.r1 touch $1_cseo.r2 +cat $1_ae.r1 $1_ae.r2 > $1_ae.r cat $1_cse.r1 $1_cse.r2 > $1_cse.r cat $1_csex.r1 $1_csex.r2 > $1_csex.r cat $1_cseo.r1 $1_cseo.r2 > $1_cseo.r if [ "$solve" = "1" ]; then Index: mttroot/mtt/bin/trans/def2write_r ================================================================== --- mttroot/mtt/bin/trans/def2write_r +++ mttroot/mtt/bin/trans/def2write_r @@ -11,10 +11,17 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.12 2002/06/28 10:13:40 geraint +## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y. +## +## Revision 1.11.2.1 2002/06/05 11:14:51 geraint +## ae.r now generated using def2write_r like cse?.r +## fix_c.r called at ese2rdae stage so that pow gets fixed in ae.r. +## ## Revision 1.11 2002/05/17 09:14:58 geraint ## Optimises each line in a separate session. Allows larger models to be built. ## ## Revision 1.10 2002/04/28 18:41:27 geraint ## Fixed [ 549658 ] awk should be gawk. @@ -84,10 +91,15 @@ Nyz=`mtt_getsize $sys yz` # Zero outputs #Npar=`wc -l $sys\_sympar.txt | gawk '{print $1}'` # Set up representation-specific stuff case $rep in + ae) + matrices='Yz' + ns="$Nyz" + ms="1" + ;; cse) matrices='EdX E' ns="$Nx $Nx" ms="1 $Nx" ;; @@ -182,11 +194,11 @@ cat <> $tmp - + echo "%%% $lhs %%%" >> def2write_r1.log ${SYMBOLIC:-reduce} < $tmp >> def2write_r1.log 2>> def2write_r2.log cat $tmp2 | gawk -v RS=';' '($2 == ":=") {print $0}' > $tmp3 cat $tmp3 | mtt_fix_integers rm -f $tmp $tmp2 $tmp3 return @@ -210,20 +222,22 @@ for matrix in $matrices; do n=`first "$ns"`; ns=`rest "$ns"` m=`first "$ms"`; ms=`rest "$ms"` is=`n2m 1 $n`; js=`n2m 1 $m`; - for i in $is; do - for j in $js; do - if [ ${opt:-""} = "-optimise" ]; then - name=`echo MTT$matrix'('$i','$j')'` - mtt_optimise $1 "$comma$name" "$name" - comma='' - else - echo 'write' - name=`echo MTT$matrix'('$i','$j')'` - echo ' '$comma$name ':=' $name '$' - fi >> $1_$2_write.r - done - done + if [ $n -ge 1 ]; then + for i in $is; do + for j in $js; do + if [ ${opt:-""} = "-optimise" ]; then + name=`echo MTT$matrix'('$i','$j')'` + mtt_optimise $1 "$comma$name" "$name" + comma='' + else + echo 'write' + name=`echo MTT$matrix'('$i','$j')'` + echo ' '$comma$name ':=' $name '$' + fi >> $1_$2_write.r + done + done + fi done echo ';END;' >>$1_$2_write.r