Ticket #3967: trac-3967-rebase.patch
| File trac-3967-rebase.patch, 5.6 kB (added by craigcitro, 4 months ago) |
|---|
-
a/sage/rings/number_field/totallyreal.pyx
old new 102 102 dB = 33.9508 103 103 return dB 104 104 105 def enumerate_totallyreal_fields_prim(n, B, a = [], verbose=0, return_seqs=False, \ 106 phc=False, keep_fields=False, t_2=False): 105 def enumerate_totallyreal_fields_prim(n, B, a = [], verbose=0, return_seqs=False, 106 phc=False, keep_fields=False, t_2=False, 107 just_print=False): 107 108 r""" 108 109 This function enumerates primitive totally real fields of degree 109 110 $n>1$ with discriminant $d \leq B$; optionally one can specify the … … 124 125 125 126 If t_2 = T, then keep only polynomials with t_2 norm >= T. 126 127 128 If just_print is not False, instead of creating a sorted list of 129 totally real number fileds, we simply write each totally real 130 field we find to the file whose filename is given by 131 just_print. In this case, we don't return anything. 132 127 133 NOTE: 128 This is guaranteed to give all primitive such fields, and129 seems in practice to give many imprimitive ones.134 This is guaranteed to give all primitive such fields, and 135 seems in practice to give many imprimitive ones. 130 136 131 137 INPUT: 132 138 n -- integer, the degree … … 222 228 cdef pari_gen B_pari, d, d_poly, keepB, nf, t2val, ngt2, ng 223 229 cdef int *f_out 224 230 cdef int counts[4] 225 cdef int i, n_int, j 231 cdef int i, n_int, j, skip_jp 226 232 cdef bint found, use_t2, phc_flag, verb_int, temp_bint 227 233 cdef Py_ssize_t k0, ind, lenS 228 234 cdef tr_data T … … 295 301 else: 296 302 phc_flag = 0 297 303 304 if just_print: 305 skip_jp = 0 306 jp_file = open(just_print, "w") 307 else: 308 skip_jp = 1 309 298 310 # Trivial case 299 311 if n == 1: 312 sage_free(f_out) 300 313 if return_seqs: 301 314 return [[0,0,0,0],[[1,[-1,1]]]] 302 315 else: … … 345 358 346 359 dng = [d, ng] 347 360 348 # Check if K is contained in the list. 349 found = 0 350 ind = bisect.bisect_left(S, dng) 351 while ind < lenS: 352 if S[ind][0] != d: 353 break 354 if S[ind][1] == ng: 355 if verb_int: 356 print "but is not new" 357 found = 1 358 break 359 ind += 1 360 361 ngt2 = <pari_gen>(ng[n_int-1]**2-2*ng[n_int-2]) 362 if not found: 363 temp_bint = ngt2 >= t2val 364 if ((not use_t2) or temp_bint): 365 if verb_int: 366 print "and is new!" 367 S.insert(ind, dng) 368 lenS += 1 361 if skip_jp: 362 # Check if K is contained in the list. 363 found = 0 364 ind = bisect.bisect_left(S, dng) 365 while ind < lenS: 366 if S[ind][0] != d: 367 break 368 if S[ind][1] == ng: 369 if verb_int: 370 print "but is not new" 371 found = 1 372 break 373 ind += 1 374 375 ngt2 = <pari_gen>(ng[n_int-1]**2-2*ng[n_int-2]) 376 if not found: 377 temp_bint = ngt2 >= t2val 378 if ((not use_t2) or temp_bint): 379 if verb_int: 380 print "and is new!" 381 S.insert(ind, dng) 382 lenS += 1 383 else: 384 if ((not use_t2) or ngt2 >= t2val): 385 jp_file.write(str([d, ng.Vecrev()]) + "\n") 369 386 370 387 else: 371 388 if verb_int: … … 387 404 T.incr(f_out,verb_int,0,phc_flag) 388 405 else: 389 406 T.incr(f_out,0,0,phc_flag) 407 408 if not skip_jp: 409 if n_int == 2 and B >= 5 and ((not use_t2) or t2val <= 5): 410 jp_file.write(str([2,[-1,-1,1]]) + "\n") 411 if B >= 8 and B < 32: 412 jp_file.write(str([2,[-2,0,1]]) + "\n") 413 elif n_int == 3 and B >= 49 and ((not use_t2) or 5 >= t2val): 414 jp_file.write(str([3,[1,-2,-1,1]]) + "\n") 415 jp_file.close() 416 sage_free(f_out) 417 return 418 390 419 391 420 # In the application of Smyth's theorem above (and easy 392 421 # irreducibility test), we exclude finitely many possibilities … … 418 447 fsock.close() 419 448 sys.stdout = saveout 420 449 450 sage_free(f_out) 421 451 if return_seqs: 422 452 return [[ counts[i] for i in range(4) ], 423 453 [[s[0],s[1].reverse().Vec()] for s in S]]