Ticket #3561: sage-3561.patch

File sage-3561.patch, 3.7 KB (added by was, 14 years ago)
  • sage/rings/number_field/number_field.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1215335842 25200
    # Node ID e2d5d7ddd40a9b2f1572603f84718107fbb80dd0
    # Parent  032b070bdf52156c7ddcb48b056188b8ec31fd7f
    trac #3561 -- Get rid of some "import numpy"'s.
    
    diff -r 032b070bdf52 -r e2d5d7ddd40a sage/rings/number_field/number_field.py
    a b from sage.structure.proof.proof import g 
    113113from sage.structure.proof.proof import get_flag
    114114import maps
    115115
    116 import math, numpy
    117116from sage.rings.integer_ring import IntegerRing
    118117
    119118def proof_flag(t):
  • sage/rings/number_field/totallyreal_data.pyx

    diff -r 032b070bdf52 -r e2d5d7ddd40a sage/rings/number_field/totallyreal_data.pyx
    a b from sage.rings.real_mpfi import RealInt 
    3838
    3939# RIF = RealIntervalField()
    4040
    41 import math, numpy
     41import math
    4242
    4343# Other global variables
    4444ZZx = PolynomialRing(IntegerRing(), 'x')
    def lagrange_degree_3(n, an1, an2, an3): 
    269269        df = ZZx([i*p[i] for i in range(1,7)])
    270270        f = f//gcd(f,df)
    271271        fcoeff = [int(c) for c in f.list()]
     272        import numpy
    272273        rts = numpy.roots(fcoeff)
    273274
    274275        rts = numpy.real([rts[i] for i in range(len(rts)) if numpy.isreal(rts[i])]).tolist()
    cdef class tr_data: 
    506507            # Annoying, but must reverse coefficients for numpy.
    507508            gnk = [int(binomial(j,k+2))*a[j] for j in range(k+2,n+1)]
    508509            gnk.reverse()
     510            import numpy
    509511            rts = numpy.roots(gnk).tolist()
    510512            rts.sort()
    511513            self.beta[(k+1)*(n+1)+0] = self.b_lower
  • sage/rings/number_field/totallyreal_rel.py

    diff -r 032b070bdf52 -r e2d5d7ddd40a sage/rings/number_field/totallyreal_rel.py
    a b from sage.rings.number_field.totallyreal 
    3131from sage.rings.number_field.totallyreal import weed_fields, odlyzko_bound_totallyreal, enumerate_totallyreal_fields_prim
    3232from sage.libs.pari.gen import pari
    3333
    34 import math, numpy, bisect, sys
    35 from numpy.linalg import inv
     34import math, bisect, sys
    3635
    3736r"""
    3837## This code needs optimization before any serious use.
    def integral_elements_in_box(K, C): 
    103102    Foo = K.real_embeddings()
    104103    B = K.reduced_basis()
    105104
     105    import numpy
     106    import numpy.linalg
    106107    L = numpy.array([ [v(b) for b in B] for v in Foo])
    107108    Linv = numpy.linalg.inv(L)
    108109    Vi = [[C[0][0]],[C[0][1]]]
    class tr_data_rel: 
    184185    further documentation.
    185186    """
    186187   
    187     def __init__(self, F, m, B, a=[]):
     188    def __init__(self, F, m, B, a=None):
    188189        r"""
    189190        Initialization routine (constructor).
    190191
    class tr_data_rel: 
    204205            sage: F.<t> = NumberField(x^2-2)
    205206            sage: T = sage.rings.number_field.totallyreal_rel.tr_data_rel(F, 2, 2000)
    206207        """
     208        if a is None:  # don't make the stupid noob mistake of putting a=[]
     209            a = []     # in the function signature above.
    207210
    208211        # Initialize constants.
    209212        self.m = m
    class tr_data_rel: 
    245248                anm1s = sum(anm1s, [])
    246249            anm1s = [sum([Z_Fbasis[i]*a[i] for i in range(self.d)]) for a in anm1s]
    247250            # Minimize trace in class.
     251            import numpy
    248252            for i in range(len(anm1s)):
    249253                Q = [ [ v(m*x) for v in self.Foo] + [0] for x in Z_Fbasis] + [[v(anm1s[i]) for v in self.Foo] + [10**6]]
    250254                Q = str(numpy.array(Q).transpose())