Index: mttroot/mtt/bin/trans/mtt_p2cc ================================================================== --- mttroot/mtt/bin/trans/mtt_p2cc +++ mttroot/mtt/bin/trans/mtt_p2cc @@ -34,11 +34,11 @@ cat > $sys_rep.cc < DEFUN_DLD ($sys_rep, args, , - "$sys_rep was generated by MTT on $date") + "Usage: $sys_rep(x,u,t,par)\n$sys_rep was generated by MTT on $date") { ColumnVector mttx = args(0).vector_value (); ColumnVector mttu = args(1).vector_value (); double mttt = args(2).double_value (); ColumnVector mttpar = args(3).vector_value (); @@ -58,11 +58,11 @@ cseo) echo " ColumnVector mtty ($Ny);" >> $sys_rep.cc ;; smx | smxa | smxax) Nxx=`echo "$Nx*$Nx" | bc` - echo " ColumnVector mtta ($Nxx);" >> $sys_rep.cc + echo " Matrix mtta ($Nx,$Nx);" >> $sys_rep.cc echo " ColumnVector mttax ($Nx);" >> $sys_rep.cc ;; *) esac @@ -69,19 +69,20 @@ #Extract Type info echo '/* Types */' >> $sys_rep.cc grep typedef $sys_rep.C >> $sys_rep.cc -#Extract the rep code and converting [] to () and deleting mtt variables etc +#Extract the rep code converting [] to () and deleting mtt variables etc +#The awk part detects the begin and end of the relevant code. echo "/* Representation $rep information */" >> $sys_rep.cc awk '{ - if ($1=="}") writing=0; - if ( (writing)&&(match($2,"mtt")!=1) ) print $0; + if ( (match($1,"}")==1)&&(NF>1)) writing=0; + if ( (writing) && !(match($2,"mtt[a-z]")==1) ) print $0; if (match($1,"{")==1) writing=1; }' <$sys_rep.C |\ -sed 's/\[\([0-9]*\)\]/(\1)/g' |\ -sed 's/\[\(mmtti\)\]/(\1)/g' >> $sys_rep.cc +sed 's/\[\([a-z0-9_]*\)\]\[\([a-z0-9_]*\)\]/(\1,\2)/g' |\ +sed 's/\[\([a-z_0-9]*\)\]/(\1)/g' >> $sys_rep.cc # Tail cat >> $sys_rep.cc <> $sys_rep.cc; + # Convert to octave loadable code echo Creating $sys_rep.oct mkoctfile $sys_rep.cc