Index: mttroot/mtt/bin/trans/cse2smx_lang ================================================================== --- mttroot/mtt/bin/trans/cse2smx_lang +++ mttroot/mtt/bin/trans/cse2smx_lang @@ -28,13 +28,15 @@ -optimise) optimise='LOAD SCOPE; ON GENTRANOPT;'; iname='INAME mtt_o;'; ;; -fixcc ) - fix_pow='FOR ALL x,y LET x^y = pow(x,y);' + fix_mtt_pow='FOR ALL x,y LET x^y = mtt_pow(x,y);' + operator='OPERATOR mtt_pow;' blurb2='fixing c and cc code'; - unfix_pow='FOR ALL x,y CLEAR x^y;' + unfix_mtt_pow='FOR ALL x,y CLEAR x^y;' + unfix_pow='FOR ALL x,y LET pow(x,y) = x^y;'; ;; *) echo $1 is an unknown option exit;; esac @@ -106,10 +108,11 @@ rm -f $1_$rep.body # Use reduce to accomplish the transformation $SYMBOLIC << EOF >cse2smx_lang.log +${operator} %% Define mtt_pow if needed lang := $lang; in "$1_subs.r"; in "$1_def.r"; in "$1_cse.r"; @@ -163,24 +166,24 @@ write "matrix mttb(", mttnx, ",", mttnu, ");"; write "matrix mttc(", mttny, ",", mttnx, ");"; write "matrix mttd(", mttny, ",", mttnu, ");"; END; - ${fix_pow} %% set x^y to pow(x,y) + ${unfix_pow} %% set pow(x,y) to x^y % find MTTA : the A matrix FOR i := 1:MTTNx DO BEGIN mttAAx_i := 0; FOR j := 1:MTTNx DO BEGIN - ${unfix_pow} %% Revert to x^y form + ${unfix_mtt_pow} %% Revert to x^y form 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; - ${fix_pow} %% set x^y to pow(x,y) + ${fix_mtt_pow} %% set x^y to mtt_pow(x,y) IF (aa_ij NEQ 0) THEN IF ($nmatrix EQ 1) THEN BEGIN %% Write a with full indexing $iname @@ -202,27 +205,28 @@ END; END; + %Shut the output according to the language. GENTRANSHUT "$1_$rep.body"; EOF fix_broken_numbers ( ) { sed -e "/[0-9.]$/ N" -e "s/\([0-9.]\)[\n\t\ ]*\([0-9]\)/\1\2/g" } + +refix_pow() { + sed 's/mtt_pow/pow/g' +} if [ "$lang" = "m" ]; then # lang_header $noglobals $parameters $1 $rep m 'mttx,mttu,mttt,mttpar' $out > $1_$rep.m mtt_header $1 $rep m > $1_$rep.m - cat $1_$rep.body | fix_broken_numbers | mtt_p2m >> $1_$rep.m + cat $1_$rep.body | fix_broken_numbers | refix_pow | mtt_p2m >> $1_$rep.m echo "## END Code" >> $1_$rep.m echo "endfunction" >> $1_$rep.m fi # Now invoke the standard error handling. mtt_error_r cse2smx_lang.log - - - -