#11856: Raise an overflow error if the exponent of a multivariate polynomial 
flows
over
-------------------------------------------------+--------------------------
   Reporter:  SimonKing                          |          Owner:  malb        
     
       Type:  defect                             |         Status:  
positive_review  
   Priority:  critical                           |      Milestone:  sage-4.7.2  
     
  Component:  commutative algebra                |       Keywords:  exponent 
overflow
Work_issues:  32bit doctests                     |       Upstream:  N/A         
     
   Reviewer:  Martin Albrecht, Alexander Dreyer  |         Author:  Simon King  
     
     Merged:                                     |   Dependencies:              
     
-------------------------------------------------+--------------------------

Old description:

> The following happens at least since sage-4.6.2 and was detected in #4539
> by a new doctest:
> {{{
> sage: P.<x,y> = QQ[]
> sage: y^2^30
> y^1073741824
> sage: P.<x,y,z> = QQ[]
> sage: y^2^30
> 0
> }}}
>
> According to Hans, the maximal exponent of a variable in a monomial does
> depend on the number of variables in the ring. There is no function that
> returns that maximal exponent, but it is stored in the `bitmask`
> attribute of a ring. The Singular interpreter actually only tests whether
> the ''total'' degree is below what is provided by bitmask; in theory,
> ''any'' exponent (not only the totall degree) can go up to that bound.
>
> Here is the corresponding code in Singular's `iparith.cc`:
> {{{
> static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
> {
>   poly a;
>   poly b;
>   int dummy;
>   if (v->next==NULL)
>   {
>     a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
>     if (u->next==NULL)
>     {
>       b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
>       if ((a!=NULL) && (b!=NULL)
>       &&
> (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask)))
>       {
>         Werror("OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
>           pTotaldegree(a),pTotaldegree(b),currRing->bitmask);
>         pDelete(&a);
>         pDelete(&b);
>         return TRUE;
> ...
> }}}

New description:

 The following happens at least since sage-4.6.2 and was detected in #4539
 by a new doctest:
 {{{
 sage: P.<x,y> = QQ[]
 sage: y^2^30
 y^1073741824
 sage: P.<x,y,z> = QQ[]
 sage: y^2^30
 0
 }}}

 According to Hans, the maximal exponent of a variable in a monomial does
 depend on the number of variables in the ring. There is no function that
 returns that maximal exponent, but it is stored in the `bitmask` attribute
 of a ring. The Singular interpreter actually only tests whether the
 ''total'' degree is below what is provided by bitmask; in theory, ''any''
 exponent (not only the totall degree) can go up to that bound.

 Here is the corresponding code in Singular's `iparith.cc`:
 {{{
 static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
 {
   poly a;
   poly b;
   int dummy;
   if (v->next==NULL)
   {
     a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
     if (u->next==NULL)
     {
       b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
       if ((a!=NULL) && (b!=NULL)
       &&
 
(pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask)))
       {
         Werror("OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
           pTotaldegree(a),pTotaldegree(b),currRing->bitmask);
         pDelete(&a);
         pDelete(&b);
         return TRUE;
 ...
 }}}

 Apply

  * [attachment:trac11856_exponent_overflow.patch]
  * [attachment:trac11856_fix_docs_32bit.patch Reviewer patch]

--

Comment(by SimonKing):

 Let's try to sort things out:

 The patch that Alexander posted at #4539 should better be a reviewer patch
 here. Thus, I copied his patch, added a commit message, and posted it here
 under a new name reflecting the ticket number. The positive review can be
 kept (I hope we  agree on that), and:

 Apply trac11856_exponent_overflow.patch trac11856_fix_docs_32bit.patch

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11856#comment:17>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to