Index: mttroot/mtt/bin/trans/cse2smx_lang ================================================================== --- mttroot/mtt/bin/trans/cse2smx_lang +++ mttroot/mtt/bin/trans/cse2smx_lang @@ -10,18 +10,23 @@ # Copyright (C) 2000 by Peter J. Gawthrop ## Modified from eailier version # Args +## Now default to matrix form +matrix='yes' while [ -n "`echo $1 | grep '^-'`" ]; do case $1 in -noglobals) noglobals='-noglobals'; ;; -parameters) parameters='-parameters'; ;; + -matrix) + matrix='yes'; + ;; *) echo $1 is an unknown option exit;; esac shift @@ -43,26 +48,35 @@ case $rep in smx) nrep=0; out='[mtta,mttax]'; + nmatrix=1; ;; smxa) - nrep=1; + nrep=1; + if [ -n "$matrix" ]; then + blurb="in matrix form"; + nmatrix=1; + else + blurb="in vector form"; + nmatrix=0; + fi out='mtta'; ;; smxax) nrep=2 out='mttax'; + nmatrix=0; ;; *) echo Representation $2 not recognised; exit;; esac # Inform user -echo Creating $1_$rep.$lang +echo Creating $1_$rep.$lang $blurb #echo Creating $1_smxx.$lang #echo Creating $1_smxtx.$lang # Remove the old log file rm -f cse2smx_r.log @@ -85,18 +99,21 @@ OFF Echo; % Load the general translator package LOAD GENTRAN; +LOAD SCOPE; GENTRANLANG!* := 'Pascal; -ON GENTRANSEG; -MAXEXPPRINTLEN!* := 120; +ON GENTRANSEG; % Segmentation +ON GENTRANOPT; % Code optimise using scope +OFF GENDECS; % No declarations +MAXEXPPRINTLEN!* := 80; TEMPVARNUM!* := 1; -TEMPVARNAME!* := 'mtt_t; +TEMPVARNAME!* := 'mtt_s; % Matrix output function -in"$MTTPATH/trans/lang_matrix.r"; +%in"$MTTPATH/trans/lang_matrix.r"; %Set up output according to the language. OFF NAT; GENTRANOUT "$1_$rep.body"; @@ -119,25 +136,30 @@ ij := i + MTTNx*(j-1); xj := mkid(mttx,j); a_ij := df(MTTEdx(i,1), xj, 1); aa_ij := MTTE(i,j) - mttt*a_ij; IF (aa_ij NEQ 0) THEN - IF ($nrep EQ 0) THEN + IF ($nmatrix EQ 1) THEN BEGIN - %% Write a and with full indexing + %% Write a with full indexing + INAME(mtt_o); % Set temp name GENTRAN mtta(i,j) ::=: aa_ij; END; - IF ($nrep EQ 1) THEN + IF (($nmatrix EQ 0) AND ($nrep EQ 1)) THEN BEGIN %% Write a with vector indexing + INAME(mtt_o); % Set temp name GENTRAN mtta(ij) ::=: aa_ij; END; mttAAx_i := mttAAx_i + aa_ij*xj; END; IF (mttAAx_i NEQ 0) THEN IF (($nrep EQ 0) OR ($nrep EQ 2)) THEN + BEGIN + INAME(mtt_o); % Set temp name GENTRAN mttax(i) ::=: mttAAx_i; + END; END; %Shut the output according to the language. GENTRANSHUT "$1_$rep.body"; EOF