# 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 |
113 | 113 | from sage.structure.proof.proof import get_flag |
114 | 114 | import maps |
115 | 115 | |
116 | | import math, numpy |
117 | 116 | from sage.rings.integer_ring import IntegerRing |
118 | 117 | |
119 | 118 | def proof_flag(t): |
diff -r 032b070bdf52 -r e2d5d7ddd40a sage/rings/number_field/totallyreal_data.pyx
a
|
b
|
from sage.rings.real_mpfi import RealInt |
38 | 38 | |
39 | 39 | # RIF = RealIntervalField() |
40 | 40 | |
41 | | import math, numpy |
| 41 | import math |
42 | 42 | |
43 | 43 | # Other global variables |
44 | 44 | ZZx = PolynomialRing(IntegerRing(), 'x') |
… |
… |
def lagrange_degree_3(n, an1, an2, an3): |
269 | 269 | df = ZZx([i*p[i] for i in range(1,7)]) |
270 | 270 | f = f//gcd(f,df) |
271 | 271 | fcoeff = [int(c) for c in f.list()] |
| 272 | import numpy |
272 | 273 | rts = numpy.roots(fcoeff) |
273 | 274 | |
274 | 275 | rts = numpy.real([rts[i] for i in range(len(rts)) if numpy.isreal(rts[i])]).tolist() |
… |
… |
cdef class tr_data: |
506 | 507 | # Annoying, but must reverse coefficients for numpy. |
507 | 508 | gnk = [int(binomial(j,k+2))*a[j] for j in range(k+2,n+1)] |
508 | 509 | gnk.reverse() |
| 510 | import numpy |
509 | 511 | rts = numpy.roots(gnk).tolist() |
510 | 512 | rts.sort() |
511 | 513 | self.beta[(k+1)*(n+1)+0] = self.b_lower |
diff -r 032b070bdf52 -r e2d5d7ddd40a sage/rings/number_field/totallyreal_rel.py
a
|
b
|
from sage.rings.number_field.totallyreal |
31 | 31 | from sage.rings.number_field.totallyreal import weed_fields, odlyzko_bound_totallyreal, enumerate_totallyreal_fields_prim |
32 | 32 | from sage.libs.pari.gen import pari |
33 | 33 | |
34 | | import math, numpy, bisect, sys |
35 | | from numpy.linalg import inv |
| 34 | import math, bisect, sys |
36 | 35 | |
37 | 36 | r""" |
38 | 37 | ## This code needs optimization before any serious use. |
… |
… |
def integral_elements_in_box(K, C): |
103 | 102 | Foo = K.real_embeddings() |
104 | 103 | B = K.reduced_basis() |
105 | 104 | |
| 105 | import numpy |
| 106 | import numpy.linalg |
106 | 107 | L = numpy.array([ [v(b) for b in B] for v in Foo]) |
107 | 108 | Linv = numpy.linalg.inv(L) |
108 | 109 | Vi = [[C[0][0]],[C[0][1]]] |
… |
… |
class tr_data_rel: |
184 | 185 | further documentation. |
185 | 186 | """ |
186 | 187 | |
187 | | def __init__(self, F, m, B, a=[]): |
| 188 | def __init__(self, F, m, B, a=None): |
188 | 189 | r""" |
189 | 190 | Initialization routine (constructor). |
190 | 191 | |
… |
… |
class tr_data_rel: |
204 | 205 | sage: F.<t> = NumberField(x^2-2) |
205 | 206 | sage: T = sage.rings.number_field.totallyreal_rel.tr_data_rel(F, 2, 2000) |
206 | 207 | """ |
| 208 | if a is None: # don't make the stupid noob mistake of putting a=[] |
| 209 | a = [] # in the function signature above. |
207 | 210 | |
208 | 211 | # Initialize constants. |
209 | 212 | self.m = m |
… |
… |
class tr_data_rel: |
245 | 248 | anm1s = sum(anm1s, []) |
246 | 249 | anm1s = [sum([Z_Fbasis[i]*a[i] for i in range(self.d)]) for a in anm1s] |
247 | 250 | # Minimize trace in class. |
| 251 | import numpy |
248 | 252 | for i in range(len(anm1s)): |
249 | 253 | 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]] |
250 | 254 | Q = str(numpy.array(Q).transpose()) |