#14685: error in the computing of the approximate order in LazyPowerSeries
------------------------------------------------------------+---------------
       Reporter:  MatthieuDien                              |         Owner:  
sage-combinat
           Type:  defect                                    |        Status:  
new          
       Priority:  major                                     |     Milestone:  
sage-5.10    
      Component:  combinatorics                             |    Resolution:    
           
       Keywords:  LazyPowerSeries aorder approximate order  |   Work issues:    
           
Report Upstream:  N/A                                       |     Reviewers:    
           
        Authors:                                            |     Merged in:    
           
   Dependencies:                                            |      Stopgaps:    
           
------------------------------------------------------------+---------------
Changes (by MatthieuDien):

  * type:  PLEASE CHANGE => defect


Old 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:
> }}}

New 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:
 }}}

 I commited it with the number 18037 on the mercurial server

 It's my first patch, sorry if i did a mistake.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14685#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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 http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to