Opened 8 years ago

Last modified 5 years ago

#14685 needs_work defect

error in the computing of the approximate order in LazyPowerSeries — at Initial Version

Reported by: MatthieuDien Owned by: sage-combinat
Priority: major Milestone: sage-6.6
Component: combinatorics Keywords: LazyPowerSeries aorder approximate order
Cc: mantepse Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Hi,

I found a bug in the LazyPowerSeries? class of package combinat. There is mistake in the computing of the approximate order of a serie. A demonstration of the bug :

sage: R = LazyPowerSeriesRing(QQ)
sage: B = R([0,0,0,1,0])
sage: B.aorder
0
sage: B.coefficients(10)
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
sage: B.aorder
1

Here, a patch :

diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
--- a/sage/combinat/species/series.py
+++ b/sage/combinat/species/series.py
@@ -631,6 +631,7 @@
                         self.aorder += 1
                         ao += 1
                     else:
+                        self.order = ao
                         break
 
             #Try to recognize the zero series
@@ -643,8 +644,17 @@
                     self.order  = inf
                     return
                 
-            if ao < n:
-                self.order = ao
+            if self.order == unk:
+                while ao < n:
+                    if self._stream[ao] == 0:
+                        self.aorder += 1
+                        ao += 1
+                    else:
+                        self.order = ao
+                        break
+
+            # if ao < n:
+            #     self.order = ao
             
     
         if hasattr(self, '_reference') and self._reference is not None:

Change History (0)

Note: See TracTickets for help on using tickets.