Ticket #8827: 8827-point-height-cache.patch

File 8827-point-height-cache.patch, 1.9 KB (added by robertwb, 12 years ago)
  • sage/schemes/elliptic_curves/ell_point.py

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1272609519 25200
    # Node ID 548238ee56a5052d81ceb93f27a3431a40aaa14b
    # Parent  faea7973dedcb0c7bdd3b512372e9b6bc80c3400
    #8827 - Cache elliptic curve point heights.
    
    diff -r faea7973dedc -r 548238ee56a5 sage/schemes/elliptic_curves/ell_point.py
    a b  
    17291729            (0 : -7/2*a - 1/2 : 1)
    17301730            sage: Q.height()
    17311731            0.0511114082399688
     1732            sage: Q.height(precision=100)
     1733            0.051111408239968840235886099755
    17321734
    17331735        An example to show that the bug at \#5252 is fixed::
    17341736
     
    17611763            return rings.QQ(0)
    17621764 
    17631765        if precision is None:
    1764             precision = rings.RealField().precision()
     1766            precision = rings.RealField().precision()
     1767           
     1768        try:
     1769            height = self.__height
     1770            if height.prec() >= precision:
     1771                return rings.RealField(precision)(height)
     1772        except AttributeError:
     1773            pass
    17651774
    17661775        if self.curve().base_ring() is rings.QQ:
    17671776            E = self.curve()
     
    17691778            iso = E.isomorphism_to(Emin)
    17701779            P = iso(self)
    17711780            h = Emin.pari_curve(prec=precision).ellheight([P[0], P[1]],precision=precision)
    1772             return rings.RealField(precision)(h)
     1781            height = rings.RealField(precision)(h)
    17731782        else:
    1774             return (self.nonarchimedian_local_height(prec=precision)
     1783            height = (self.nonarchimedian_local_height(prec=precision)
    17751784                        + self.archimedian_local_height(prec=precision))
     1785       
     1786        self.__height = height
     1787        return height
    17761788
    17771789
    17781790    def archimedian_local_height(self, v=None, prec=None):