# 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 from sage.structure.proof.proof import g from sage.structure.proof.proof import get_flag import maps import math, numpy from sage.rings.integer_ring import IntegerRing def proof_flag(t):
• ## sage/rings/number_field/totallyreal_data.pyx

`diff -r 032b070bdf52 -r e2d5d7ddd40a sage/rings/number_field/totallyreal_data.pyx`
 a from sage.rings.real_mpfi import RealInt # RIF = RealIntervalField() import math, numpy import math # Other global variables ZZx = PolynomialRing(IntegerRing(), 'x') def lagrange_degree_3(n, an1, an2, an3): df = ZZx([i*p[i] for i in range(1,7)]) f = f//gcd(f,df) fcoeff = [int(c) for c in f.list()] import numpy rts = numpy.roots(fcoeff) rts = numpy.real([rts[i] for i in range(len(rts)) if numpy.isreal(rts[i])]).tolist() cdef class tr_data: # Annoying, but must reverse coefficients for numpy. gnk = [int(binomial(j,k+2))*a[j] for j in range(k+2,n+1)] gnk.reverse() import numpy rts = numpy.roots(gnk).tolist() rts.sort() 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 from sage.rings.number_field.totallyreal from sage.rings.number_field.totallyreal import weed_fields, odlyzko_bound_totallyreal, enumerate_totallyreal_fields_prim from sage.libs.pari.gen import pari import math, numpy, bisect, sys from numpy.linalg import inv import math, bisect, sys r""" ## This code needs optimization before any serious use. def integral_elements_in_box(K, C): Foo = K.real_embeddings() B = K.reduced_basis() import numpy import numpy.linalg L = numpy.array([ [v(b) for b in B] for v in Foo]) Linv = numpy.linalg.inv(L) Vi = [[C[0][0]],[C[0][1]]] class tr_data_rel: further documentation. """ def __init__(self, F, m, B, a=[]): def __init__(self, F, m, B, a=None): r""" Initialization routine (constructor). class tr_data_rel: sage: F. = NumberField(x^2-2) sage: T = sage.rings.number_field.totallyreal_rel.tr_data_rel(F, 2, 2000) """ if a is None:  # don't make the stupid noob mistake of putting a=[] a = []     # in the function signature above. # Initialize constants. self.m = m class tr_data_rel: anm1s = sum(anm1s, []) anm1s = [sum([Z_Fbasis[i]*a[i] for i in range(self.d)]) for a in anm1s] # Minimize trace in class. import numpy for i in range(len(anm1s)): 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]] Q = str(numpy.array(Q).transpose())