[GAP Forum] how to convert symbolic expression into a list of terms

Lee Martin CCNP tesleft at hotmail.com
Sun Sep 28 10:02:09 BST 2014


Hi 
i finally change to use 3 for loop instead of using Tuples, allow duplicate
but i have a final difficulty in get a list of terms in symbolic expression
for i in prepoly1[1][3] do	Print(i);od;
do not know how to get a list of terms of expression such as x+z^2;
how to convert to a list [x, z^2]  for for loop to get each terms?

mkdir maplecode./bin/gap.sh -o 16g
GAPInfo.CommandLineOptions.o;"16g" 
onelist := Tuples([0,1,0,1,0,1],3);onelist2 := [];Append( onelist2, onelist );Append( onelist2, onelist );Append( onelist2, onelist );matrixlist := Tuples(onelist2,3);matrixlist2 := [];Append( matrixlist2, matrixlist );Append( matrixlist2, matrixlist );Append( matrixlist2, matrixlist );LoadPackage("singular");R1:= PolynomialRing( Rationals, ["x","y","z"] : new );;SetTermOrdering(R1,"lp");SingularSetBaseRing(R1);x:=IndeterminatesOfPolynomialRing(R1)[1];;y:=IndeterminatesOfPolynomialRing(R1)[2];;z:=IndeterminatesOfPolynomialRing(R1)[3];;prepoly1 := [[x,y,z]]*matrixlist2[idealindexlist[1][1]];prepoly2 := [[x,y,z]]*matrixlist2[idealindexlist[1][2]];prepoly3 := [[x,y,z]]*matrixlist2[idealindexlist[1][3]];prepoly1 := [[x,y,z]]*matrixlist2[100];poly1 := 0;for j in Length(prepoly1[1]) do  poly1 := poly1 + prepoly1[1][3];
pp := rec(prepoly1[1][3]);
for i in prepoly1[1][3] do	Print(i);od;

pp.string
for j in [1..3] do	AppendTo(Concatenation(Concatenation("./maplecode/gapexport",String(j)),String(j)), j);od;
AppendTo("./gapexport", "T := table();\n");for j in [1..Length(matrixlist2)] do	for k in [1..Length(matrixlist2)] do		for i in [1..Length(matrixlist2)] do
for j in [1..3] do	for k in [1..3] do		for i in [1..3] do			  prepoly1 := [[x,y,z]]*matrixlist2[idealindexlist[i][1]];  prepoly2 := [[x,y,z]]*matrixlist2[idealindexlist[i][2]];  prepoly3 := [[x,y,z]]*matrixlist2[idealindexlist[i][3]];  I:= Ideal( R1, [prepoly1, prepoly2, prepoly3] );  S:=SingularInterface( "stdhilb", [I], "ideal");  HF := GeneratorsOfIdeal(S);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), "if not assigned(T[");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), HF);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), "]) then");  AppendTo(Concatenation("./maplecode/gapexport",String(j)),"\n");    AppendTo(Concatenation("./maplecode/gapexport",String(j)), "T[");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), HF);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), "] := [op(T[");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), HF);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), "]),[");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), prepoly1);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), ",");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), prepoly2);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), ",");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), prepoly3);  AppendTo(Concatenation("./maplecode/gapexport",String(j)), "]];\n");  AppendTo(Concatenation("./maplecode/gapexport",String(j)), "end if;\n");
Regards,
Martin
> From: tesleft at hotmail.com
> To: forum at gap-system.org
> Date: Sat, 27 Sep 2014 02:47:49 +0800
> Subject: [GAP Forum]   how to get variables in symbolic expression
> 
> Hi 
> maple can use op(1, poly)
> how to do similar things in gap?
> [ [ y, z, x+z ] ]
> poly1 := 0;for j in Length(prepoly1[1]) do  poly1 := poly1 + prepoly1[1][3]
> become y + z + x*z
> Regards,
> Martin 		 	   		  
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
 		 	   		  


More information about the Forum mailing list