PRINTPOL_strg
- This function prints a non-commutative polynomial as an input to a tex file.
PRINTPOL_strg:=function(pol) # rel é do tipo rel = [mon, pol].
local polstrg, ind;
polstrg:=String(pol);
if polstrg = "0" then
Print(polstrg);
#return polstrg;
else
polstrg:=SplitString(polstrg, "+");
Sort(polstrg, ORDER);
polstrg:=Reversed(polstrg);
for ind in [1..Size(polstrg)] do
if EvalString(COEF_STRG(polstrg[ind])) = 1 then
polstrg[ind]:=ReplacedString(polstrg[ind], "(1)", "" ) ;
elif EvalString(COEF_STRG(polstrg[ind])) = -1 then
polstrg[ind]:=ReplacedString(polstrg[ind], "(-1)", "-" ) ;
else
polstrg[ind]:= ReplacedString(polstrg[ind], COEF_STRG(polstrg[ind]), String(EvalString(COEF_STRG(polstrg[ind]))));
fi;
od;
polstrg:=JoinStringsWithSeparator(polstrg, "\n+");
polstrg:=ReplacedString(polstrg, "*", "" ) ;
polstrg:=ReplacedString(polstrg, "\n+-", "\n-" ) ;
Print(polstrg);
#return polstrg;
fi;
end;