#20935: Weird crash in mod N arithmetic for medium-size N
--------------------------------------+------------------------
       Reporter:  davidloeffler       |        Owner:
           Type:  defect              |       Status:  new
       Priority:  major               |    Milestone:  sage-7.3
      Component:  basic arithmetic    |   Resolution:
       Keywords:  modular arithmetic  |    Merged in:
        Authors:                      |    Reviewers:
Report Upstream:  N/A                 |  Work issues:
         Branch:                      |       Commit:
   Dependencies:                      |     Stopgaps:
--------------------------------------+------------------------
Changes (by davidloeffler):

 * keywords:   => modular arithmetic


Old description:

> The following code crashes in Sage v7.2 with a !ZeroDivisionError:
> {{{
> V = FreeModule(Zmod(3^10), 1)
> v = V.gen(0)
> x = v * v
> x.valuation(3)
> }}}
> The variable x is just 1 (mod 3^10^), and if you just do {{{
> Zmod(3^10)(1).valuation(3)}}} it returns 0 (as it should), but creating
> it via linear algebra in this way seems to somehow return a broken
> object.
>
> Oddly enough, only powers of 3 between 3^10^ and 3^19^ (inclusive) seem
> to raise this error -- larger or smaller powers work fine. Similarly
> powers of 2 between 2^16^ and 2^30^, or powers of 5 between 5^7^ and
> 5^13^. This strongly suggests there is an overflow error occurring
> somewhere when the modulus is too large for a 16-bit integer but large
> enough for a 32-bit.

New description:

 The following code crashes in Sage v7.2 with a !ZeroDivisionError:
 {{{
 V = FreeModule(Zmod(3^10), 1)
 v = V.gen(0)
 x = v * v
 x.valuation(3)
 }}}
 The variable x is just 1 (mod 3^10^), and if you just do {{{
 Zmod(3^10)(1).valuation(3)}}} it returns 0 (as it should), but creating it
 via linear algebra in this way seems to somehow return a "broken" integer
 mod object.

 This error only occurs for moduli in a certain interval: between 46342
 (~2^15.5^) and 2147483646 (~2^31^). Investigation suggests that {{{v *
 v}}} is getting returned as an {{{IntegerMod_int}}} object where it should
 be an {{{IntegerMod_int64}}}; the culprit seems to be the method
 {{{_dot_product_}}} in {{{ sage/modules/vector_modn_dense.pyx}}}.

--

--
Ticket URL: <https://trac.sagemath.org/ticket/20935#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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to