Ticket #6046: heights3.patch

File heights3.patch, 5.8 KB (added by fwclarke, 12 years ago)

Apply after the other two

  • sage/rings/number_field/number_field_element.pyx

    # HG changeset patch
    # User Francis Clarke <F.Clarke@Swansea.ac.uk>
    # Date 1242478224 -3600
    # Node ID caab6c1e2557096a97f9bd6fffdf4791eb784002
    # Parent  c6ed558cf5c3651a98d93a2f3fd5d351434fce61
    more heights fixes
    
    diff -r c6ed558cf5c3 -r caab6c1e2557 sage/rings/number_field/number_field_element.pyx
    a b  
    687687            sage: [1/K(5).abs_non_arch(P) for P in K.primes_above(5)]
    688688            [5.00000000000000]
    689689
     690        A relative example::
     691
     692            sage: L.<b> = K.extension(x^2-5)
     693            sage: [b.abs_non_arch(P) for P in L.primes_above(b)]
     694            [0.447213595499958, 0.447213595499958]
    690695        """
    691696        from sage.rings.real_mpfr import RealField
    692697        if prec is None:
     
    698703            return R.zero_element()
    699704        val = self.valuation(P)
    700705        nP = P.residue_class_degree()*P.absolute_ramification_index()
    701         return R(P.norm()) ** (-R(val) / R(nP))
     706        return R(P.absolute_norm()) ** (-R(val) / R(nP))
    702707
    703708    def coordinates_in_terms_of_powers(self):
    704709        r"""
     
    20342039            1
    20352040            sage: type(b.valuation(P))
    20362041            <type 'sage.rings.integer.Integer'>
     2042
     2043        The function can be applied to elements in relative number fields::
     2044
     2045            sage: L.<b> = K.extension(x^2 - 3)
     2046            sage: [L(6).valuation(P) for P in L.primes_above(6)]
     2047            [4, 2, 2]
    20372048        """
    20382049        from number_field_ideal import is_NumberFieldIdeal
    20392050        from sage.rings.infinity import infinity
     
    20862097            8.22174772834662
    20872098            sage: (b^-1).local_height(P)
    20882099            0.000000000000000
     2100
     2101        A relative example::
     2102
     2103            sage: PK.<y> = K[]
     2104            sage: L.<c> = NumberField(y^2 + a)
     2105            sage: L(1/4).local_height(L.ideal(2, c-a+1))
     2106            1.38629436111989
    20892107        """
    20902108        if self.valuation(P) >= 0: ## includes the case self=0
    20912109            from sage.rings.real_mpfr import RealField
     
    21312149            [0.530192454572, 0.886414217456, 0.886414217456, 0.530192454572]
    21322150            sage: [a.local_height_arch(i, weighted=True) for i in range(4)]
    21332151            [0.530192454572, 1.77282843491, 1.77282843491, 1.06038490914]
     2152   
     2153        A relative example::
     2154
     2155            sage: L.<b, c> = NumberFieldTower([x^2 - 5, x^3 + x + 3])
     2156            sage: [(b + c).local_height_arch(i) for i in range(6)]
     2157            [0.78002896175,
     2158             0.78002896175,
     2159             1.23822339076,
     2160             1.16048938497,
     2161             1.16048938497,
     2162             0.0224034722996]
    21342163        """
    21352164        from sage.rings.real_mpfr import RealField
    21362165        if prec is None:
     
    21892218            [0.000000000000000, 2.77258872223978, 2.19722457733622, 2.19722457733622]
    21902219            sage: sum([b.local_height(P,weighted=True) for P in b.support()])
    21912220            7.16703787691222
     2221   
     2222        A relative example::
     2223
     2224            sage: PK.<y> = K[]
     2225            sage: L.<c> = NumberField(y^2 + a)
     2226            sage: (c/10).global_height_non_arch()
     2227            18.4206807439524
    21922228        """
    21932229        from sage.rings.real_mpfr import RealField
    21942230        if prec is None:
     
    21972233            R = RealField(prec)
    21982234        if self.is_zero():
    21992235            return R.zero_element()
    2200         return R(self.denominator_ideal().norm()).log()
     2236        return R(self.denominator_ideal().absolute_norm()).log()
    22012237
    22022238    def global_height_arch(self, prec=None):
    22032239        """
     
    22292265            R = RealField(prec)
    22302266        if self.is_zero():
    22312267            return R.zero_element()
    2232         n = self.number_field().degree()
     2268        n = self.number_field().absolute_degree()
    22332269        # Note that the list of embeddings does have length n as it
    22342270        # includes both conjugates for each non-real embedding.  This
    22352271        # gives the correct total, since the contributions from the
     
    22792315            sage: (a^2).global_height() # element of K (degree 4 field)
    22802316            1.41660667202811
    22812317        """
    2282         return self.global_height_non_arch(prec)+self.global_height_arch(prec)/self.number_field().degree()
     2318        return self.global_height_non_arch(prec)+self.global_height_arch(prec)/self.number_field().absolute_degree()
    22832319
    22842320    def numerator_ideal(self):
    22852321        """
     
    23262362        """
    23272363        if self.is_zero():
    23282364            raise ValueError, "numerator ideal of 0 is not defined."
    2329         K = self.number_field()
    2330         one = K.ideal(1)
    2331         return one / (one + K.ideal(1/self))
     2365        return self.number_field().ideal(self).numerator()
    23322366
    23332367    def denominator_ideal(self):
    23342368        """
     
    23752409        """
    23762410        if self.is_zero():
    23772411            raise ValueError, "denominator ideal of 0 is not defined."
    2378         K = self.number_field()
    2379         one = K.ideal(1)
    2380         return one / (one + K.ideal(self))
     2412        return self.number_field().ideal(self).denominator()
    23812413
    23822414    def support(self):
    23832415        """
  • sage/rings/number_field/number_field_ideal_rel.py

    diff -r c6ed558cf5c3 -r caab6c1e2557 sage/rings/number_field/number_field_ideal_rel.py
    a b  
    456456            sage: K.ideal(13).is_prime()
    457457            False
    458458        """
    459         return self.absolute_ideal().is_prime()
     459        try:
     460            return self._pari_prime is not None
     461        except AttributeError:
     462            abs_ideal = self.absolute_ideal()
     463            _ = abs_ideal.is_prime()
     464            self._pari_prime = abs_ideal._pari_prime
     465            return self._pari_prime is not None
    460466
    461467    def is_integral(self):
    462468        """