teste

POL2REL

  • This function transforms a relation of type [pol, 0] in [mon, pol_1], where mon is a summand of largest order, where pol = mon  - pol_1, for example,

gap>POL2REL(U*V^2*U - V*U^2*V);

[V*U^2*V, U*V^2*U]

gap>

  • This function calls other functions: ORDERING.


POL2REL:=function(pol)
local polaux, rel;

if pol = 0*pol then return [0*pol, 0*pol];fi;

polaux:=SplitString(String(pol), "+");
Sort(polaux, ORDERING);
polaux:=Reversed(polaux);

rel:=[];
if Size(polaux) = 1 then
    rel[2]:=Zero(EvalString(polaux[1]));
    if EvalString(COEF_STRG(polaux[1])) < 0 then
    rel[1]:=   -EvalString(polaux[1]);
else
    rel[1]:=   EvalString(polaux[1]);
    fi;
    return rel;
fi;
    

if EvalString(COEF_STRG(polaux[1])) < 0 then
    rel[1]:=   -EvalString(polaux[1]);
    rel[2]:=   EvalString(JoinStringsWithSeparator(polaux{[2..Size(polaux)]}, "+"));
else
    rel[1]:=   EvalString(polaux[1]);
    rel[2]:=   -EvalString(JoinStringsWithSeparator(polaux{[2..Size(polaux)]}, "+"));
fi;
    
return rel;

end;