On 2018-06-18 09:50, [email protected] wrote:
I have a library in PARI/GP and since Sage also supports the GP
calculator I have been trying to shift my library using gp.set() and
gp.get() commands. So far all functions are working but I got a PARI/GP
error while implementing this function in Sage using gp.set(). Here is
the code of that function:

compareSides(printedgesonscreen=0) =
{
   local( edge, edgesCheckList1:list, edgesCheckList2:list,
cancelCriterion);

   edgesCheckList1 = listcreate(2*numberOfLines);
   edgesCheckList2 = listcreate(2*numberOfLines);

   for (j = 1, numberOfSpheres,
    if( deleteFlag[j] == 0,

      if( printedgesonscreen == 1,
              print("Cell ",j," lies on the hemisphere with center at ",
                   divideInNumberField(K,Lambda[j],Mu[j]) );
              print(" with radius square ", radiusSquare[j],
                 " and has the following edges:");
       );

       for( s = 1, length( pointsOfLine[j]),

          edge = setintersect(Set(pointsOfLine[j][s]),
                                 Set(pointsOfSphere[j]:list));

          if(length(edge) == 2,

                 if(printedgesonscreen == 1, print(edge); );

                 if( setsearch(Set(edgesCheckList1),edge),

                         if(setsearch(Set(edgesCheckList2),edge),

                                 if (printedgesonscreen == 1,
                                   print("***Error in function
compareSides: triple edge in cell diagram");
                                 );
                                ,
                                 listput(edgesCheckList2,edge);
                         );
                        , /* else not yet entered in edgesCheckList1 */
                         listput(edgesCheckList1,edge);
                 );

          );
          if(length(edge) > 2,
                 print("***Error in function compareSides: edge with
three corners");
          );
       );
    );
   );

   if(Set(edgesCheckList1) == Set(edgesCheckList2),

         print("All ", length(edgesCheckList1), " = ",
                 length(edgesCheckList2)," edges appear twice.");
         if( length(edgesCheckList1) > 3,
                 cancelCriterion = 1
                 ,
                 cancelCriterion = 0
         );
         , /* else some edges do not appear twice. */
                 print("Some edges do not appear twice:");

print(setminus(Set(edgesCheckList1),Set(edgesCheckList2)));
   );
   listkill(edgesCheckList1); listkill(edgesCheckList2);
   /* Return */ cancelCriterion
};


I have run this function in the GP calculator of Sage using the
gp.console() command and it works fine but I don't understand why it is
not working using gp.set(). Here is the implementation I did:

gp.set('compareSides(printedgesonscreen=0)','{  local( edge,
edgesCheckList1:list, edgesCheckList2:list, cancelCriterion);
edgesCheckList1 = listcreate(2*numberOfLines);  edgesCheckList2 =
listcreate(2*numberOfLines);  for (j = 1, numberOfSpheres,   if(
deleteFlag[j] == 0,     if( printedgesonscreen == 1,
print("Cell ",j," lies on the hemisphere with center at
",                  divideInNumberField(K,Lambda[j],Mu[j])
);             print(" with radius square ",
radiusSquare[j],                " and has the following edges:");
);       for( s = 1, length( pointsOfLine[j]),         edge =
setintersect(Set(pointsOfLine[j][s]),
Set(pointsOfSphere[j]:list));         if(length(edge) ==
2,                 if(printedgesonscreen == 1, print(edge);
);                if(
setsearch(Set(edgesCheckList1),edge),
if(setsearch(Set(edgesCheckList2),edge),
if (printedgesonscreen == 1, print("***Error in function compareSides:
triple edge in cell diagram");
);                               ,
listput(edgesCheckList2,edge);
);                       , /* else not yet entered in edgesCheckList1
*/                        listput(edgesCheckList1,edge);
);                                 );         if(length(edge) >
2,                print("***Error in function compareSides: edge with
three corners"); );      );   );     );  if(Set(edgesCheckList1) ==
Set(edgesCheckList2),             print("All ", length(edgesCheckList1),
" = ",                length(edgesCheckList2)," edges appear
twice.");        if( length(edgesCheckList1) > 3,
cancelCriterion = 1;                ,                cancelCriterion =
0;        );        , /* else some edges do not appear twice.
*/                print("Some edges do not appear
twice:");
print(setminus(Set(edgesCheckList1),Set(edgesCheckList2)));  );
listkill(edgesCheckList1); listkill(edgesCheckList2);  /* Return */
cancelCriterion}')

When I run this in Sage it shows a PARI/GP error and outputs the whole
code. I have been trying to find the bug since the last 3 days. Please
help me regarding this. Thank you.

--
You received this message because you are subscribed to the Google
Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

It looks strange to use gp.set() for that. I would simply use gp.eval()

--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to