Ticket #2348: numberfields_gap.2.patch

File numberfields_gap.2.patch, 2.3 KB (added by SimonKing, 14 years ago)

This may be close to a solution

  • sage/rings/number_field/number_field.py

    # HG changeset patch
    # User Simon King <king@mathematik.uni-jena.de>
    # Date 1204381413 -3600
    # Node ID 12318d9a52fd76803eae3298f317f974a509ef69
    # Parent  5db8b4f0c24b27fee4b5287154af7a7b374d4d34
    Potential solution of the gap(Numberfield) problem
    
    diff -r 5db8b4f0c24b -r 12318d9a52fd sage/rings/number_field/number_field.py
    a b class NumberField_generic(number_field_b 
    15811581        """
    15821582        return 0
    15831583
     1584    def _gap_init_(self):
     1585        """
     1586        Create a gap object representing self and return its name
     1587        """
     1588        if not self.is_absolute():
     1589            raise NotImplementedError, "Currently, only simple algebraic extensions are possible in gap"
     1590        if self.__dict__.has_key('_gap_name_'): # if it was constructed before
     1591            return self.__dict__['_gap_name_']
     1592        PR = sage.interfaces.gap.gap(sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing(self.base_field(),self.gen()))
     1593        BF = sage.interfaces.gap.gap(self.base_field())
     1594        MP = sage.interfaces.gap.gap(self.polynomial())
     1595        OUT = BF.AlgebraicExtension(MP)
     1596        self.__dict__['_gap_name_'] = OUT.name()
     1597        return OUT.name()
     1598
    15841599    def class_group(self, proof=None, names='c'):
    15851600        r"""
    15861601        Return the class group of the ring of integers of this number field.
  • sage/rings/number_field/number_field_element.pyx

    diff -r 5db8b4f0c24b -r 12318d9a52fd sage/rings/number_field/number_field_element.pyx
    a b cdef class NumberFieldElement(FieldEleme 
    355355            \zeta_{12}^{2} - \zeta_{12} - 1
    356356        """
    357357        return self.polynomial()._latex_(name=self.number_field().latex_variable_name())
     358
     359    def _gap_init_(self):
     360        """
     361        Return gap string representation of self.
     362        """
     363        if self.parent().__dict__.has_key('_gap_name_'):
     364            return self.__repr__()
     365        self.parent()._gap_init_()
     366        return self.__repr__()
    358367
    359368    def _pari_(self, var='x'):
    360369        raise NotImplementedError, "NumberFieldElement sub-classes must override _pari_"