def isIntBasis(self): """ Determine whether self.basis is integral basis of self field. """ D = self.disc() if squarefree.trial_division(abs(D)): return True else: if D % 4 == 0: if squarefree.trial_division(abs(D)//4) and (D//4) % 4 != 1: return True # compare with real integer ring return abs(self.integer_ring().determinant()) == 1
def isIntBasis(self): """ Determine whether self.basis is integral basis of self field. """ D = self.disc() if squarefree.trial_division(abs(D)): return True else: if D & 3 == 0: if squarefree.trial_division(abs(D) >> 2) and (D >> 2) & 3 != 1: return True # compare with real integer ring return abs(self.integer_ring().determinant()) == 1
def next_disc(d, absbound): """ Return fundamental discriminant D, such that D < d. If there is no D with |d| < |D| < absbound, return False """ # -disc % 16 negdisc_mod16 = (3, 4, 7, 8, 11, 15) for negdisc in bigrange.range(-d + 1, absbound): if negdisc & 15 not in negdisc_mod16: continue if negdisc & 1 and not squarefree.trial_division(negdisc): continue if arith1.issquare(negdisc): continue return -negdisc return False
def next_disc(d, absbound): """ Return fundamental discriminant D, such that D < d. If there is no D with |d| < |D| < absbound, return False """ # -disc % 16 negdisc_mod16 = (3, 4, 7, 8, 11, 15) for negdisc in bigrange.range(-d + 1, absbound): if negdisc % 16 not in negdisc_mod16: continue if negdisc % 2 == 1 and not squarefree.trial_division(negdisc): continue if arith1.issquare(negdisc): continue return -negdisc return False