Index: mttroot/mtt/bin/trans/dae2cse_r
==================================================================
--- mttroot/mtt/bin/trans/dae2cse_r
+++ mttroot/mtt/bin/trans/dae2cse_r
@@ -13,10 +13,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.24  2002/09/16 08:08:00  geraint
+## Merged changes from global-optimisation branch.
+##
 ## Revision 1.23.2.3  2002/09/12 18:50:50  geraint
 ## Uncommented cse optimisations - they seem to work ok.
 ##
 ## Revision 1.23.2.2  2002/09/10 23:24:19  geraint
 ## Rationalised local and global optimisations.
@@ -490,16 +493,14 @@
 cat $1_csex.r1 $1_csex.r2  > $1_csex.r
 cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r
 
 if [ ${optimise:-""} = "-optimise_global" ]; then
     mtt_optimise global $1 ae
-    mtt_optimise global $1 cse
     mtt_optimise global $1 cseo
     mtt_optimise global $1 csex
 elif [ ${optimise:-""} = "-optimise_local" ]; then
     mtt_optimise local $1 ae
-    mtt_optimise local $1 cse
     mtt_optimise local $1 cseo
     mtt_optimise local $1 csex
 fi
 
 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,13 @@
 ###############################################################
 ## Version control history
 ###############################################################
 ## $Id$
 ## $Log$
+## Revision 1.17  2002/09/16 08:08:00  geraint
+## Merged changes from global-optimisation branch.
+##
 ## Revision 1.16.2.3  2002/09/10 23:24:19  geraint
 ## Rationalised local and global optimisations.
 ## Fixes presentation of locally optimised code (ode view).
 ## Much more elegant :-)
 ##
@@ -172,12 +175,28 @@
 
 echo 'off echo$' >> $1_$2_write.r
 echo 'load gentran$' >> $1_$2_write.r
 
 for matrix in $matrices; do
-    matrix_exists=`grep -i MTT${matrix} ${sys}_dae.r | wc -l | gawk '{print $1}'`
-    if [ "$matrix" = "EdX" -o $matrix_exists -gt 0 ]; then
+    ignore_matrix="no"
+    if [ "$matrix" = "E" ]; then
+	matrix_exists=`grep -i MTTE ${sys}_dae.r | wc -l | gawk '{print $1}'`
+	if [ ! $matrix_exists -gt 0 ]; then
+	    ignore_matrix="yes"
+	    n=`first "$ns"`; ns=`rest "$ns"` 
+	    m=`first "$ms"`; ms=`rest "$ms"`
+ 	    is=`n2m 1 $n`;
+	    echo "write \"% Begin Matrix MTTE\"$" >> $1_$2_write.r
+	    for i in $is; do
+		echo 'write'
+		name=`echo MTTE'('$i','$i')'`
+		echo '  '$comma$name ':=' $name '$'
+	    done >> $1_$2_write.r
+	    echo "write \"% End Matrix MTTE\"$" >> $1_$2_write.r
+	fi
+    fi
+    if [ ! "$ignore_matrix" = "yes" ]; then
 	n=`first "$ns"`; ns=`rest "$ns"` 
 	m=`first "$ms"`; ms=`rest "$ms"`
 	is=`n2m 1 $n`; 
 	js=`n2m 1 $m`; 
 	echo "write \"% Begin Matrix MTT${matrix}\"$" >> $1_$2_write.r

Index: mttroot/mtt/bin/trans/mtt_optimise
==================================================================
--- mttroot/mtt/bin/trans/mtt_optimise
+++ mttroot/mtt/bin/trans/mtt_optimise
@@ -13,11 +13,11 @@
 
 case $representation in
     ae)
 	matrix=yz ;
 	nmatrix=`mtt_getsize $system yz` ;;
-    cse | csex)
+    csex)
 	matrix=edx ;
 	nmatrix=`mtt_getsize $system x` ;;
     ode)
 	matrix=dx ;
 	nmatrix=`mtt_getsize $system x` ;;