Opened 8 years ago

Closed 8 years ago

#11234 closed defect (fixed)

Fractional ideal class double exponentiation fails

Reported by: jdemeyer Owned by: davidloeffler
Priority: major Milestone: sage-4.7.1
Component: number fields Keywords: pari class group
Cc: Merged in: sage-4.7.1.alpha0
Authors: Francis Clarke Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by fwclarke)

sage: k.<a> = NumberField(x^2 + 20072); G = k.class_group(); (G.0^2)^2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/usr/local/src/sage-4.7.alpha4/<ipython console> in <module>()

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/rings/number_field/class_group.pyc in __pow__(self, n)
    302         # we go along; actually computing self.__ideal ** n would
    303         # be disastrous.
--> 304         n = n % self.order()
    305         return MonoidElement.__pow__(self, n)
    306

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/rings/number_field/class_group.pyc in order(self)
    392         """
    393         # an old method with a new docstring
--> 394         return AbelianGroupElement.order(self)
    395
    396     def multiplicative_order(self):

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/groups/abelian_gps/abelian_group_element.pyc in order(self)
    304             return o
    305         L = list(self.list())
--> 306         N = LCM([invs[i]//GCD(invs[i],L[i]) for i in range(len(invs)) if L[i]!=0])
    307         if N == 0:
    308             return infinity

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/rings/integer.so in sage.rings.integer.Integer.__floordiv__ (sage/rings/integer.c:12659)()

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.bin_op (sage/structure/element.c:19135)()

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.bin_op (sage/structure/element.c:19033)()

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6498)()

/usr/local/src/sage-4.7.alpha4/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6436)()

TypeError: unsupported operand type(s) for //: 'sage.libs.pari.gen.gen' and 'sage.libs.pari.gen.gen'

Both patches should be applied.

Attachments (2)

trac_11234_ideal_class_order.patch (1.4 KB) - added by fwclarke 8 years ago.
trac_11234_extra_doctest.patch (811 bytes) - added by fwclarke 8 years ago.
Apply both patches

Download all attachments as: .zip

Change History (11)

comment:1 Changed 8 years ago by jdemeyer

  • Description modified (diff)
  • Summary changed from Fractional ideal class multiplication sometimes fails to Fractional ideal class double exponentiation fails

Changed 8 years ago by fwclarke

comment:2 follow-up: Changed 8 years ago by fwclarke

  • Authors set to Francis Clarke
  • Status changed from new to needs_review

The root cause of this defect is that the coordinates of class group elements were Pari integers. 

The problem wasn't detected before because only generators were tested in the doctests for sage.rings.number_field.class_group.FractionalIdealClass.order .

The attached patch fixes the problem and alters one doctest.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 8 years ago by jdemeyer

  • Status changed from needs_review to needs_work

Replying to fwclarke:

The root cause of this defect is that the coordinates of class group elements were Pari integers. 

The problem wasn't detected before because only generators were tested in the doctests for sage.rings.number_field.class_group.FractionalIdealClass.order .

The attached patch fixes the problem and alters one doctest.

Thanks, I will test it. However, you should add a doctest to show that the problem from this ticket is fixed (so needs_work for this reason).

Changed 8 years ago by fwclarke

Apply both patches

comment:4 Changed 8 years ago by fwclarke

  • Description modified (diff)

comment:5 in reply to: ↑ 3 Changed 8 years ago by fwclarke

Replying to jdemeyer:

you should add a doctest to show that the problem from this ticket is fixed.

Done. All the previous tests only took powers of a generator.

comment:6 Changed 8 years ago by fwclarke

  • Status changed from needs_work to needs_review

comment:7 Changed 8 years ago by jdemeyer

  • Reviewers set to Jeroen Demeyer
  • Status changed from needs_review to positive_review

Looks good! Patch makes sense and fixes the problem.

comment:8 Changed 8 years ago by cremona

I also tested the patch (after #11230 and on the way to #11130) and everything tested fine.

comment:9 Changed 8 years ago by jdemeyer

  • Merged in set to sage-4.7.1.alpha0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.