Hi,
I succeed with the following code.
for j in [1..3] do      for k in [1..3] do              for i in [1..3] do      
                prepoly1 := [[x,y,z]]*matrixlist2[j];                   
prepoly2 := [[x,y,z]]*matrixlist2[k];                   prepoly3 := 
[[x,y,z]]*matrixlist2[i];                   poly1 := 0;                     for 
j in [1..Length(prepoly1[1])] do                      zz:=1;                    
      for i in SplitString(String(prepoly1[1][j]), "+" ) do                     
    zz:=zz*EvalString(i);                     od;                     if zz <> 
1 then                           poly1 := poly1 + zz;                          
fi;                   od;                     poly2 := 0;                     
for j in [1..Length(prepoly2[1])] do                      zz:=1;                
          for i in SplitString(String(prepoly2[1][j]), "+" ) do                 
        zz:=zz*EvalString(i);                     od;                     if zz 
<> 1 then                           poly2 := poly2 + zz;                        
  fi;                   od;                     poly3 := 0;                     
for j in [1..Length(prepoly3[1])] do                      zz:=1;                
          for i in SplitString(String(prepoly3[1][j]), "+" ) do                 
        zz:=zz*EvalString(i);                     od;                     if zz 
<> 1 then                           poly3 := poly3 + zz;                        
  fi;                   od;                     if poly1 <> 0 and poly2 <> 0 
and poly3 <> 0 then                                                        I:= 
Ideal( R1, [poly1, poly2, poly3] );                         
S:=SingularInterface( "stdhilb", [I], "ideal");                         HF := 
GeneratorsOfIde
 al(S);                         Print(HF);                              
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)), poly1);              
                AppendTo(Concatenation("./maplecode/gapexport",String(j)), 
",");                                
AppendTo(Concatenation("./maplecode/gapexport",String(j)), poly2);              
                AppendTo(Concatenation("./maplecode/gapexport",String(j)), 
",");                                
AppendTo(Concatenation("./maplecode/gapexport",String(j)
 ), poly3);                             
AppendTo(Concatenation("./maplecode/gapexport",String(j)), "];\n");             
                AppendTo(Concatenation("./maplecode/gapexport",String(j)), "end 
if;\n");                        fi;             od;     od;od;
Regards,
Martin
> From: tesl...@hotmail.com
> To: fo...@gap-system.org
> Date: Sun, 28 Sep 2014 17:02:09 +0800
> Subject: [GAP Forum] how to convert symbolic expression into a list of terms
> 
> 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)), "]),[");  Ap
 pendTo(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: tesl...@hotmail.com
> > To: fo...@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@mail.gap-system.org
> > http://mail.gap-system.org/mailman/listinfo/forum
>                                         
> _______________________________________________
> Forum mailing list
> Forum@mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
                                          
_______________________________________________
Forum mailing list
Forum@mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to