Jeroen Demeyer on Tue, 10 Feb 2009 12:53:40 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

PATCH: gcmp1 and gcmp_1 for t_SERs


Hello pari-dev,

It seems that gcmp1() and gcmp_1() were not implemented for t_SER (they always returned 0). This patch should fix that.

CHANGES:
- Implemented gcmp1() and gcmp_1() for t_SERs.

Cheers,
Jeroen
Index: src/basemath/gen2.c
===================================================================
--- src/basemath/gen2.c	(revision 11590)
+++ src/basemath/gen2.c	(working copy)
@@ -406,6 +406,8 @@
 int
 gcmp1(GEN x)
 {
+  long i;
+
   switch(typ(x))
   {
     case t_INT:
@@ -434,6 +436,12 @@
 
     case t_POL:
       return lg(x)==3 && gcmp1(gel(x,2));
+
+    case t_SER:
+      if (signe(x) == 0 || valp(x) != 0 || !gcmp1(gel(x,2))) return 0;
+      for (i = 3; i < lg(x); i++) if (!gcmp0(gel(x,i))) return 0;
+      return 1;
+
   }
   return 0;
 }
@@ -443,7 +451,7 @@
 gcmp_1(GEN x)
 {
   pari_sp av;
-  long y;
+  long i, y;
   GEN p1;
 
   switch(typ(x))
@@ -478,6 +486,11 @@
 
     case t_POL:
       return lg(x)==3 && gcmp_1(gel(x,2));
+
+    case t_SER:
+      if (signe(x) == 0 || valp(x) != 0 || !gcmp_1(gel(x,2))) return 0;
+      for (i = 3; i < lg(x); i++) if (!gcmp0(gel(x,i))) return 0;
+      return 1;
   }
   return 0;
 }