bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
|
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
| 472,900
|
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
|
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
| 472,901
|
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
|
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
| 472,902
|
def trial_division(n, bound=None): """ Return the smallest prime divisor <= bound of the positive integer n, or n if there is no such prime. If the optional argument bound is omitted, then bound <= n. INPUT: - ``n`` - a positive integer - ``bound`` - (optional) a positive integer OUTPUT: - ``int`` - a prime p=bound that divides n, or n if there is no such prime. EXAMPLES:: sage: trial_division(15) 3 sage: trial_division(91) 7 sage: trial_division(11) 11 sage: trial_division(387833, 300) 387833 sage: # 300 is not big enough to split off a sage: # factor, but 400 is. sage: trial_division(387833, 400) 389 """ if n == 1: return 1 for p in [2, 3, 5]: if n%p == 0: return p if bound == None: bound = n dif = [6, 4, 2, 4, 2, 4, 6, 2] m = 7; i = 1 while m <= bound and m*m <= n: if n%m == 0: return m m += dif[i%8] i += 1 return n
|
def trial_division(n, bound=None): """ Return the smallest prime divisor <= bound of the positive integer n, or n if there is no such prime. If the optional argument bound is omitted, then bound <= n. INPUT: - ``n`` - a positive integer - ``bound`` - (optional) a positive integer OUTPUT: - ``int`` - a prime p=bound that divides n, or n if there is no such prime. EXAMPLES:: sage: trial_division(15) 3 sage: trial_division(91) 7 sage: trial_division(11) 11 sage: trial_division(387833, 300) 387833 sage: # 300 is not big enough to split off a sage: # factor, but 400 is. sage: trial_division(387833, 400) 389 """ if bound is None: return ZZ(n).trial_division() else: return ZZ(n).trial_division(bound)
| 472,903
|
def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): """ Returns the factorization of n. The result depends on the type of n. If n is an integer, factor returns the factorization of the integer n as an object of type Factorization. If n is not an integer, ``n.factor(proof=proof, **kwds)`` gets called. See ``n.factor??`` for more documentation in this case. .. warning:: This means that applying factor to an integer result of a symbolic computation will not factor the integer, because it is considered as an element of a larger symbolic ring. EXAMPLE:: sage: f(n)=n^2 sage: is_prime(f(3)) False sage: factor(f(3)) 9 INPUT: - ``n`` - an nonzero integer - ``proof`` - bool or None (default: None) - ``int_`` - bool (default: False) whether to return answers as Python ints - ``algorithm`` - string - ``'pari'`` - (default) use the PARI c library - ``'kash'`` - use KASH computer algebra system (requires the optional kash package be installed) - ``'magma'`` - use Magma (requires magma be installed) - ``verbose`` - integer (default 0); pari's debug variable is set to this; e.g., set to 4 or 8 to see lots of output during factorization. OUTPUT: factorization of n The qsieve and ecm commands give access to highly optimized implementations of algorithms for doing certain integer factorization problems. These implementations are not used by the generic factor command, which currently just calls PARI (note that PARI also implements sieve and ecm algorithms, but they aren't as optimized). Thus you might consider using them instead for certain numbers. The factorization returned is an element of the class :class:`~sage.structure.factorization.Factorization`; see Factorization?? for more details, and examples below for usage. A Factorization contains both the unit factor (+1 or -1) and a sorted list of (prime, exponent) pairs. The factorization displays in pretty-print format but it is easy to obtain access to the (prime,exponent) pairs and the unit, to recover the number from its factorization, and even to multiply two factorizations. See examples below. EXAMPLES:: sage: factor(500) 2^2 * 5^3 sage: factor(-20) -1 * 2^2 * 5 sage: f=factor(-20) sage: list(f) [(2, 2), (5, 1)] sage: f.unit() -1 sage: f.value() -20 :: sage: factor(-500, algorithm='kash') # optional - kash -1 * 2^2 * 5^3 :: sage: factor(-500, algorithm='magma') # optional - magma -1 * 2^2 * 5^3 :: sage: factor(0) Traceback (most recent call last): ... ArithmeticError: Prime factorization of 0 not defined. sage: factor(1) 1 sage: factor(-1) -1 sage: factor(2^(2^7)+1) 59649589127497217 * 5704689200685129054721 Sage calls PARI's factor, which has proof False by default. Sage has a global proof flag, set to True by default (see :mod:`sage.structure.proof.proof`, or proof.[tab]). To override the default, call this function with proof=False. :: sage: factor(3^89-1, proof=False) 2 * 179 * 1611479891519807 * 5042939439565996049162197 :: sage: factor(2^197 + 1) # takes a long time (e.g., 3 seconds!) 3 * 197002597249 * 1348959352853811313 * 251951573867253012259144010843 Any object which has a factor method can be factored like this:: sage: K.<i> = QuadraticField(-1) sage: factor(122+454*i) (-i) * (3*i - 2) * (4*i + 1) * (i + 1)^3 * (2*i + 1)^3 To access the data in a factorization:: sage: f = factor(420); f 2^2 * 3 * 5 * 7 sage: [x for x in f] [(2, 2), (3, 1), (5, 1), (7, 1)] sage: [p for p,e in f] [2, 3, 5, 7] sage: [e for p,e in f] [2, 1, 1, 1] sage: [p^e for p,e in f] [4, 3, 5, 7] """ if not isinstance(n, (int,long, integer.Integer)): # this happens for example if n = x**2 + y**2 + 2*x*y try: return n.factor(proof=proof, **kwds) except AttributeError: raise TypeError, "unable to factor n" except TypeError: # just in case factor method doesn't have a proof option. try: return n.factor(**kwds) except AttributeError: raise TypeError, "unable to factor n" #n = abs(n) n = ZZ(n) if n < 0: unit = ZZ(-1) n = -n else: unit = ZZ(1) if n == 0: raise ArithmeticError, "Prime factorization of 0 not defined." if n == 1: return factorization.Factorization([], unit) #if n < 10000000000: return __factor_using_trial_division(n) if algorithm == 'pari': return factorization.Factorization(__factor_using_pari(n, int_=int_, debug_level=verbose, proof=proof), unit) elif algorithm in ['kash', 'magma']: if algorithm == 'kash': from sage.interfaces.all import kash as I else: from sage.interfaces.all import magma as I F = I.eval('Factorization(%s)'%n) i = F.rfind(']') + 1 F = F[:i] F = F.replace("<","(").replace(">",")") F = eval(F) if not int_: F = [(ZZ(a), ZZ(b)) for a,b in F] return factorization.Factorization(F, unit) else: raise ValueError, "Algorithm is not known"
|
def if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(n, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof=None, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) int_=False, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithm='pari', if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) verbose=0, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) **kwds): if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) """ if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Returns if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) The if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) result if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) depends if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) on if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) type if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) If if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) returns if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) as if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) object if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) type if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Factorization. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) If if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``n.factor(proof=proof, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) **kwds)`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) gets if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) called. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) See if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``n.factor??`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) more if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) documentation if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) this if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) case. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) .. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) warning:: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) This if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) means if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) that if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) applying if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) result if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) symbolic if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) computation if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) will if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) because if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) it if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) considered if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) as if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) element if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) larger if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) symbolic if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ring. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) EXAMPLE:: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f(n)=n^2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is_prime(f(3)) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) False if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(f(3)) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 9 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) INPUT: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``n`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) nonzero if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``proof`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) bool if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) or if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) None if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (default: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) None) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``int_`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) bool if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (default: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) False) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) whether if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) answers if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) as if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Python if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ints if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``algorithm`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) string if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``'pari'`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (default) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) use if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) PARI if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) c if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) library if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``'kash'`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) use if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) KASH if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) computer if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algebra if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) system if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (requires if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) optional if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) kash if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) package if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) be if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) installed) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``'magma'`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) use if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Magma if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (requires if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) magma if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) be if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) installed) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ``verbose`` if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (default if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 0); if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) pari's if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) debug if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) variable if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) set if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) this; if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) e.g., if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) set if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 4 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) or if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 8 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) see if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) lots if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) output if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) during if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) OUTPUT: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) The if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) qsieve if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) and if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ecm if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) commands if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) give if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) access if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) highly if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) optimized if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) implementations if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithms if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) doing if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) certain if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) problems. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) These if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) implementations if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) are if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) used if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) by if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) generic if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) command, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) which if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) currently if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) just if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) calls if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) PARI if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (note if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) that if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) PARI if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) also if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) implements if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sieve if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) and if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ecm if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithms, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) but if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) they if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) aren't if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) as if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) optimized). if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Thus if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) you if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) might if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) consider if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) using if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) them if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) instead if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) certain if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) numbers. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) The if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) returned if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) an if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) element if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) class if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :class:`~sage.structure.factorization.Factorization`; if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) see if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Factorization?? if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) more if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) details, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) and if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) examples if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) below if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) usage. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) A if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) contains if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) both if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (+1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) or if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) and if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sorted if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) list if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (prime, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) exponent) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) pairs. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) The if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) displays if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) pretty-print if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) format if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) but if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) it if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) easy if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) obtain if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) access if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (prime,exponent) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) pairs if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) and if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) recover if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) number if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) from if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) its if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) and if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) even if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) multiply if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) two if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorizations. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) See if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) examples if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) below. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) EXAMPLES:: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(500) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2^2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5^3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(-20) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2^2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f=factor(-20) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) list(f) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [(2, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2), if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (5, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1)] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f.unit() if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f.value() if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -20 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(-500, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithm='kash') if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) # if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) optional if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) kash if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2^2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5^3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(-500, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithm='magma') if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) # if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) optional if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) magma if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2^2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5^3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(0) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Traceback if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (most if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) recent if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) call if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) last): if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ... if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ArithmeticError: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Prime if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 0 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) defined. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(-1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(2^(2^7)+1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 59649589127497217 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5704689200685129054721 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Sage if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) calls if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) PARI's if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) which if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) has if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) False if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) by if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) default. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Sage if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) has if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) global if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) flag, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) set if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) True if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) by if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) default if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (see if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :mod:`sage.structure.proof.proof`, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) or if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof.[tab]). if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) To if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) override if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) default, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) call if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) this if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) function if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) with if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof=False. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(3^89-1, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof=False) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 179 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1611479891519807 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5042939439565996049162197 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) :: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(2^197 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) # if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) takes if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) long if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) time if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (e.g., if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) seconds!) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 197002597249 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1348959352853811313 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 251951573867253012259144010843 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) Any if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) object if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) which if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) has if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) method if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) can if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) be if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factored if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) like if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) this:: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) K.<i> if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) QuadraticField(-1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(122+454*i) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (-i) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (3*i if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) - if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (4*i if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (i if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1)^3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (2*i if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1)^3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) To if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) access if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) the if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) data if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization:: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor(420); if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2^2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 3 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) * if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 7 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [x if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) x if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [(2, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2), if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (3, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1), if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (5, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1), if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (7, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1)] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [p if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) p,e if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [2, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 3, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 7] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [e if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) p,e if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [2, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [p^e if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) p,e if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) f] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [4, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 3, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 5, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 7] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) """ if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) isinstance(n, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) (int,long, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) integer.Integer)): if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) # if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) this if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) happens if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) example if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) x**2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) y**2 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 2*x*y if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) try: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n.factor(proof=proof, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) **kwds) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) except if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) AttributeError: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) raise if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) TypeError, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) "unable if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n" if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) except if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) TypeError: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) # if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) just if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) case if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) method if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) doesn't if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) have if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) option. if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) try: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n.factor(**kwds) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) except if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) AttributeError: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) raise if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) TypeError, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) "unable if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) to if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factor if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n" if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) #n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) abs(n) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ZZ(n) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) < if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 0: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ZZ(-1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) -n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) else: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ZZ(1) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) == if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 0: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) raise if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ArithmeticError, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) "Prime if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) of if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 0 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) defined." if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) == if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization.Factorization([], if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) #if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) n if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) < if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 10000000000: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) __factor_using_trial_division(n) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithm if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) == if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 'pari': if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization.Factorization(__factor_using_pari(n, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) int_=int_, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) debug_level=verbose, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) proof=proof), if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) elif if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithm if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ['kash', if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 'magma']: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) algorithm if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) == if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 'kash': if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) from if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage.interfaces.all if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) import if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) kash if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) as if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) I if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) else: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) from if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) sage.interfaces.all if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) import if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) magma if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) as if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) I if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) I.eval('Factorization(%s)'%n) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) i if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F.rfind(']') if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) + if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) 1 if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F[:i] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F.replace("<","(").replace(">",")") if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) eval(F) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) if if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) int_: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) = if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) [(ZZ(a), if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ZZ(b)) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) for if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) a,b if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) in if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) F] if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) return if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) factorization.Factorization(F, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) unit) if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) else: if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) raise if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) ValueError, if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) "Algorithm if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) is if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) not if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit) known" if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit)
| 472,904
|
def is_identity(self): r""" Returns ``True`` if ``self`` is the identity morphism.
|
def is_identity(self): r""" Returns ``True`` if ``self`` is the identity morphism.
| 472,905
|
def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous.
|
def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous.
| 472,906
|
def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous.
|
def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous.
| 472,907
|
def intermediate_shape(self): """ Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
|
def intermediate_shape(self): """ Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
| 472,908
|
def intermediate_shape(self): """ Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
|
def intermediate_shape(self): """ Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
| 472,909
|
def blocks_and_cut_vertices(self): """ Computes the blocks and cut vertices of the graph. In the case of a digraph, this computation is done on the underlying graph.
|
def blocks_and_cut_vertices(self): """ Computes the blocks and cut vertices of the graph. In the case of a digraph, this computation is done on the underlying graph.
| 472,910
|
def blocks_and_cut_vertices(self): """ Computes the blocks and cut vertices of the graph. In the case of a digraph, this computation is done on the underlying graph.
|
def blocks_and_cut_vertices(self): """ Computes the blocks and cut vertices of the graph. In the case of a digraph, this computation is done on the underlying graph.
| 472,911
|
def face_lattice(self): """ Computes the face-lattice poset. Elements are tuples of (vertices, facets) - i.e. this keeps track of both the vertices in each face, and all the facets containing them.
|
def face_lattice(self): """ Computes the face-lattice poset. Elements are tuples of (vertices, facets) - i.e. this keeps track of both the vertices in each face, and all the facets containing them.
| 472,912
|
def face_lattice(self): """ Computes the face-lattice poset. Elements are tuples of (vertices, facets) - i.e. this keeps track of both the vertices in each face, and all the facets containing them.
|
def face_lattice(self): """ Computes the face-lattice poset. Elements are tuples of (vertices, facets) - i.e. this keeps track of both the vertices in each face, and all the facets containing them.
| 472,913
|
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
|
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
| 472,914
|
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
|
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
| 472,915
|
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
|
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
| 472,916
|
def _repr_(self): """ The printing representation of self.
|
def _repr_(self): """ The printing representation of self.
| 472,917
|
def _repr_(self): """ The default printing representation of self.
|
def _repr_(self): """ The default printing representation of self.
| 472,918
|
def module_morphism(self, on_basis = None, diagonal = None, triangular = None, **keywords): r""" Constructs morphisms by linearity
|
def module_morphism(self, on_basis = None, diagonal = None, triangular = None, **keywords): r""" Constructs morphisms by linearity
| 472,919
|
def leading_item(self, cmp=None): r""" Returns the pair ``(k, c)`` where ``c`` * (the basis elt. indexed by ``k``) is the leading term of ``self``.
|
def leading_item(self, cmp=None): r""" Returns the pair ``(k, c)`` where ``c`` * (the basis elt. indexed by ``k``) is the leading term of ``self``.
| 472,920
|
def leading_monomial(self, cmp=None): r""" Returns the leading monomial of ``self``.
|
def leading_monomial(self, cmp=None): r""" Returns the leading monomial of ``self``.
| 472,921
|
def leading_coefficient(self, cmp=None): r""" Returns the leading coefficient of ``self``.
|
def leading_coefficient(self, cmp=None): r""" Returns the leading coefficient of ``self``.
| 472,922
|
def leading_term(self, cmp=None): r""" Returns the leading term of ``self``.
|
def leading_term(self, cmp=None): r""" Returns the leading term of ``self``.
| 472,923
|
def trailing_item(self, cmp=None): r""" Returns the pair ``(c, k)`` where ``c*self.parent().monomial(k)`` is the trailing term of ``self``.
|
def trailing_item(self, cmp=None): r""" Returns the pair ``(c, k)`` where ``c*self.parent().monomial(k)`` is the trailing term of ``self``.
| 472,924
|
def trailing_monomial(self, cmp=None): r""" Returns the trailing monomial of ``self``.
|
def trailing_monomial(self, cmp=None): r""" Returns the trailing monomial of ``self``.
| 472,925
|
def trailing_coefficient(self, cmp=None): r""" Returns the trailing coefficient of ``self``.
|
def trailing_coefficient(self, cmp=None): r""" Returns the trailing coefficient of ``self``.
| 472,926
|
def trailing_term(self, cmp=None): r""" Returns the trailing term of ``self``.
|
def trailing_term(self, cmp=None): r""" Returns the trailing term of ``self``.
| 472,927
|
def extra_super_categories(self): """ EXAMPLES::
|
def extra_super_categories(self): """ EXAMPLES::
| 472,928
|
sage: def phi_on_basis(i): return Y.monomial(abs(i))
|
sage: def phi_on_basis(i): return Y.monomial(abs(i))
| 472,929
|
sage: def phi_on_basis(i): return Y.monomial(abs(i))
|
sage: def phi_on_basis(i): return Y.monomial(abs(i))
| 472,930
|
sage: def phi_on_basis(i): return Y.monomial(abs(i))
|
sage: def phi_on_basis(i): return Y.monomial(abs(i))
| 472,931
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
| 472,932
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
| 472,933
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
| 472,934
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
|
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
| 472,935
|
def is_Gamma0_equivalent(self, other, N, Transformation=False): r""" Checks if cusps ``self`` and ``other`` are `\Gamma_0(N)`- equivalent.
|
def is_Gamma0_equivalent(self, other, N, Transformation=False): r""" Checks if cusps ``self`` and ``other`` are `\Gamma_0(N)`- equivalent.
| 472,936
|
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
|
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
| 472,937
|
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
|
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
| 472,938
|
def _subdivide_palp(self, new_rays, verbose): r""" Subdivide ``self`` adding ``new_rays`` one by one.
|
def _subdivide_palp(self, new_rays, verbose): r""" Subdivide ``self`` adding ``new_rays`` one by one.
| 472,939
|
def _subdivide_palp(self, new_rays, verbose): r""" Subdivide ``self`` adding ``new_rays`` one by one.
|
def _subdivide_palp(self, new_rays, verbose): r""" Subdivide ``self`` adding ``new_rays`` one by one.
| 472,940
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
|
def parse_deps(self, filename, ext_module, verify=True): """ Open a Cython file and extract all of its dependencies.
| 472,941
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
| 472,942
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
| 472,943
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
|
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
| 472,944
|
def immediate_deps(self, filename): """ Returns a list of files directly referenced by this file. """ if (filename not in self._deps or self.timestamp(filename) < self._last_parse[filename]): self._deps[filename] = self.parse_deps(filename) self._last_parse[filename] = self.timestamp(filename) return self._deps[filename]
|
def immediate_deps(self, filename, ext_module): """ Returns a list of files directly referenced by this file. """ if (filename not in self._deps or self.timestamp(filename) < self._last_parse[filename]): self._deps[filename] = self.parse_deps(filename) self._last_parse[filename] = self.timestamp(filename) return self._deps[filename]
| 472,945
|
def immediate_deps(self, filename): """ Returns a list of files directly referenced by this file. """ if (filename not in self._deps or self.timestamp(filename) < self._last_parse[filename]): self._deps[filename] = self.parse_deps(filename) self._last_parse[filename] = self.timestamp(filename) return self._deps[filename]
|
def immediate_deps(self, filename): """ Returns a list of files directly referenced by this file. """ if (filename not in self._deps or self.timestamp(filename) < self._last_parse[filename]): self._deps[filename] = self.parse_deps(filename, ext_module) self._last_parse[filename] = self.timestamp(filename) return self._deps[filename]
| 472,946
|
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
|
def all_deps(self, filename, ext_module, path=None): """ Returns all files directly or indirectly referenced by this file.
| 472,947
|
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
|
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
| 472,948
|
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
|
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
| 472,949
|
def newest_dep(self, filename): """ Returns the most recently modified file that filename depends on, along with its timestamp. """ nfile = filename ntime = self.timestamp(filename) for f in self.all_deps(filename): if self.timestamp(f) > ntime: nfile = f ntime = self.timestamp(f) return nfile, ntime
|
def newest_dep(self, filename, ext_module): """ Returns the most recently modified file that filename depends on, along with its timestamp. """ nfile = filename ntime = self.timestamp(filename) for f in self.all_deps(filename): if self.timestamp(f) > ntime: nfile = f ntime = self.timestamp(f) return nfile, ntime
| 472,950
|
def newest_dep(self, filename): """ Returns the most recently modified file that filename depends on, along with its timestamp. """ nfile = filename ntime = self.timestamp(filename) for f in self.all_deps(filename): if self.timestamp(f) > ntime: nfile = f ntime = self.timestamp(f) return nfile, ntime
|
def newest_dep(self, filename): """ Returns the most recently modified file that filename depends on, along with its timestamp. """ nfile = filename ntime = self.timestamp(filename) for f in self.all_deps(filename, ext_module): if self.timestamp(f) > ntime: nfile = f ntime = self.timestamp(f) return nfile, ntime
| 472,951
|
def compile_command_list(ext_modules, deps): """ Computes a list of commands needed to compile and link the extension modules given in 'ext_modules' """ queue_compile_high = [] queue_compile_med = [] queue_compile_low = [] for m in ext_modules: new_sources = [] for f in m.sources: if f.endswith('.pyx'): dep_file, dep_time = deps.newest_dep(f) dest_file = "%s/%s"%(SITE_PACKAGES, f) dest_time = deps.timestamp(dest_file) if dest_time < dep_time: if dep_file == f: print "Building modified file %s."%f queue_compile_high.append([compile_command, (f,m)]) elif dep_file == (f[:-4] + '.pxd'): print "Building %s because it depends on %s."%(f, dep_file) queue_compile_med.append([compile_command, (f,m)]) else: print "Building %s because it depends on %s."%(f, dep_file) queue_compile_low.append([compile_command, (f,m)]) new_sources.append(process_filename(f, m)) m.sources = new_sources return queue_compile_high + queue_compile_med + queue_compile_low
|
def compile_command_list(ext_modules, deps): """ Computes a list of commands needed to compile and link the extension modules given in 'ext_modules' """ queue_compile_high = [] queue_compile_med = [] queue_compile_low = [] for m in ext_modules: new_sources = [] for f in m.sources: if f.endswith('.pyx'): dep_file, dep_time = deps.newest_dep(f,m) dest_file = "%s/%s"%(SITE_PACKAGES, f) dest_time = deps.timestamp(dest_file) if dest_time < dep_time: if dep_file == f: print "Building modified file %s."%f queue_compile_high.append([compile_command, (f,m)]) elif dep_file == (f[:-4] + '.pxd'): print "Building %s because it depends on %s."%(f, dep_file) queue_compile_med.append([compile_command, (f,m)]) else: print "Building %s because it depends on %s."%(f, dep_file) queue_compile_low.append([compile_command, (f,m)]) new_sources.append(process_filename(f, m)) m.sources = new_sources return queue_compile_high + queue_compile_med + queue_compile_low
| 472,952
|
def show(self, **kwds): """ Show this graphics image with the default image viewer.
|
def show(self, **kwds): """ Show this graphics image with the default image viewer.
| 472,953
|
def derivative(self, ex, operator): """ EXAMPLES::
|
def derivative(self, ex, operator): """ EXAMPLES::
| 472,954
|
def derivative(self, ex, operator): """ EXAMPLES::
|
def derivative(self, ex, operator): """ EXAMPLES::
| 472,955
|
def derivative(self, ex, operator): """ EXAMPLES::
|
def derivative(self, ex, operator): """ EXAMPLES::
| 472,956
|
def derivative(self, ex, operator): """ EXAMPLES::
|
def derivative(self, ex, operator): """ EXAMPLES::
| 472,957
|
def overlap_partition(self, other, delay=0, p=None, involution=None) : r""" Returns the partition of the alphabet induced by the overlap of self and other with the given delay.
|
def overlap_partition(self, other, delay=0, p=None, involution=None) : r""" Returns the partition of the alphabet induced by the overlap of self and other with the given delay.
| 472,958
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): r""" Enumerates projective, rational points on scheme ``X`` of height up to bound ``B``. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,959
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme; - ``B`` - a positive integer bound. OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,960
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of ``X`` of height up to ``B``, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,961
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,962
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on ``X``. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,963
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: - John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,964
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,965
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
|
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
| 472,966
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme ``X`` (defined over `\QQ`) up to bound ``B``. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,967
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme; - ``B`` - a positive integer bound. OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,968
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of ``X`` of height up to ``B``, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,969
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHORS: - David R. Kohel <kohel@maths.usyd.edu.au>: original version. - Charlie Turner (06-2010): small adjustments. """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,970
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = range(1, B + 1) R = [ 0 ] + [ s*k for k in range(1, B+1) for s in [1, -1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,971
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [0] * n m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,972
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except TypeError: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except TypeError: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,973
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] for it in iters: it.next() i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,974
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
|
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <kohel@maths.usyd.edu.au> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
| 472,975
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme ``X`` defined over a finite field. INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
| 472,976
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or a set of abstract rational points of such a scheme. OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
| 472,977
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of ``X`` over the finite field, sorted. EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
| 472,978
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. .. WARNING:: If ``X`` is defined over an infinite field, this code will not finish! AUTHORS: - John Cremona and Charlie Turner (06-2010). """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
| 472,979
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
|
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except TypeError: pass pts.sort() return pts
| 472,980
|
def identity_matrix(ring, n=0, sparse=False): r""" Return the `n \times n` identity matrix over the given ring. The default ring is the integers. EXAMPLES:: sage: M = identity_matrix(QQ, 2); M [1 0] [0 1] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: M = identity_matrix(2); M [1 0] [0 1] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: M = identity_matrix(3, sparse=True); M [1 0 0] [0 1 0] [0 0 1] sage: M.parent() Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring """ if isinstance(ring, (int, long, rings.Integer)): n = ring ring = rings.ZZ return matrix_space.MatrixSpace(ring, n, n, sparse).identity_matrix()
|
def identity_matrix(ring, n=0, sparse=False): r""" Return the `n \times n` identity matrix over the given ring. The default ring is the integers. EXAMPLES:: sage: M = identity_matrix(QQ, 2); M [1 0] [0 1] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: M = identity_matrix(2); M [1 0] [0 1] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: M = identity_matrix(3, sparse=True); M [1 0 0] [0 1 0] [0 0 1] sage: M.parent() Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring """ if isinstance(ring, (int, long, rings.Integer)): n = ring ring = rings.ZZ return matrix_space.MatrixSpace(ring, n, n, sparse)(1)
| 472,981
|
def zero_matrix(ring, nrows, ncols=None, sparse=False): r""" Return the `nrows \times ncols` zero matrix over the given ring. The default ring is the integers. EXAMPLES:: sage: M = zero_matrix(QQ, 2); M [0 0] [0 0] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: M = zero_matrix(2, 3); M [0 0 0] [0 0 0] sage: M.parent() Full MatrixSpace of 2 by 3 dense matrices over Integer Ring sage: M = zero_matrix(3, 1, sparse=True); M [0] [0] [0] sage: M.parent() Full MatrixSpace of 3 by 1 sparse matrices over Integer Ring """ if isinstance(ring, (int, long, rings.Integer)): nrows, ncols = (ring, nrows) ring = rings.ZZ return matrix_space.MatrixSpace(ring, nrows, ncols, sparse).zero_matrix()
|
def zero_matrix(ring, nrows, ncols=None, sparse=False): r""" Return the `nrows \times ncols` zero matrix over the given ring. The default ring is the integers. EXAMPLES:: sage: M = zero_matrix(QQ, 2); M [0 0] [0 0] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: M = zero_matrix(2, 3); M [0 0 0] [0 0 0] sage: M.parent() Full MatrixSpace of 2 by 3 dense matrices over Integer Ring sage: M = zero_matrix(3, 1, sparse=True); M [0] [0] [0] sage: M.parent() Full MatrixSpace of 3 by 1 sparse matrices over Integer Ring """ if isinstance(ring, (int, long, rings.Integer)): nrows, ncols = (ring, nrows) ring = rings.ZZ return matrix_space.MatrixSpace(ring, nrows, ncols, sparse)(0)
| 472,982
|
def _repr_defn(self): """ This function is used internally for printing.
|
def _repr_defn(self): """ This function is used internally for printing.
| 472,983
|
def __init__(self, parent, polys, check=True): SchemeMorphism_on_points.__init__(self, parent, polys, check) if check: # morphisms from projective space are always given by # homogeneous polynomials of the same degree deg = self.defining_polynomials()[0].degree() for poly in self.defining_polynomials(): if (poly.degree() != deg) or not poly.is_homogeneous(): raise ValueError, "polys (=%s) must be homogeneous of the same degree"%polys
|
def __init__(self, parent, polys, check=True): SchemeMorphism_on_points.__init__(self, parent, polys, check) if check: # morphisms from projective space are always given by # homogeneous polynomials of the same degree deg = self.defining_polynomials()[0].degree() for poly in self.defining_polynomials(): if (poly.degree() != deg) or not poly.is_homogeneous(): raise ValueError, "polys (=%s) must be homogeneous of the same degree"%polys
| 472,984
|
def edge_coloring(g, value_only=False, vizing=False, hex_colors=False, log=0): r""" Properly colors the edges of a graph. See the URL http://en.wikipedia.org/wiki/Edge_coloring for further details on edge coloring. INPUT: - ``g`` -- a graph. - ``value_only`` -- (default: ``False``): - When set to ``True``, only the chromatic index is returned. - When set to ``False``, a partition of the edge set into matchings is returned if possible. - ``vizing`` -- (default: ``False``): - When set to ``True``, tries to find a `\Delta + 1`-edge-coloring, where `\Delta` is equal to the maximum degree in the graph. - When set to ``False``, tries to find a `\Delta`-edge-coloring, where `\Delta` is equal to the maximum degree in the graph. If impossible, tries to find and returns a `\Delta + 1`-edge-coloring. This implies that ``value_only=False``. - ``hex_colors`` -- (default: ``False``) when set to ``True``, the partition returned is a dictionary whose keys are colors and whose values are the color classes (ideal for plotting). - ``log`` -- (default: ``0``) as edge-coloring is an `NP`-complete problem, this function may take some time depending on the graph. Use ``log`` to define the level of verbosity you wantfrom the linear program solver. By default ``log=0``, meaning that there will be no message printed by the solver. OUTPUT: In the following, `\Delta` is equal to the maximum degree in the graph ``g``. - If ``vizing=True`` and ``value_only=False``, return a partition of the edge set into `\Delta + 1` matchings. - If ``vizing=False`` and ``value_only=True``, return the chromatic index. - If ``vizing=False`` and ``value_only=False``, return a partition of the edge set into the minimum number of matchings. - If ``vizing=True`` and ``value_only=True``, should return something, but mainly you are just trying to compute the maximum degree of the graph, and this is not the easiest way. By Vizing's theorem, a graph has a chromatic index equal to `\Delta` or to `\Delta + 1`. .. NOTE:: In a few cases, it is possible to find very quickly the chromatic index of a graph, while it remains a tedious job to compute a corresponding coloring. For this reason, ``value_only = True`` can sometimes be much faster, and it is a bad idea to compute the whole coloring if you do not need it ! EXAMPLE:: sage: from sage.graphs.graph_coloring import edge_coloring sage: g = graphs.PetersenGraph() sage: edge_coloring(g, value_only=True) # optional - requires GLPK or CBC 4 Complete graphs are colored using the linear-time round-robin coloring:: sage: from sage.graphs.graph_coloring import edge_coloring sage: len(edge_coloring(graphs.CompleteGraph(20))) 19 """ from sage.numerical.mip import MixedIntegerLinearProgram from sage.plot.colors import rainbow from sage.numerical.mip import MIPSolverException if g.is_clique(): if value_only: return g.order()-1 if g.order() % 2 == 0 else g.order() vertices = g.vertices() r = round_robin(g.order()) classes = [[] for v in g] if g.order() % 2 == 0 and not vizing: classes.pop() for (u, v, c) in r.edge_iterator(): classes[c].append((vertices[u], vertices[v])) if hex_colors: return dict(zip(rainbow(len(classes)), classes)) else: return classes if value_only and g.is_overfull(): return max(g.degree())+1 p = MixedIntegerLinearProgram(maximization=True) color = p.new_variable(dim=2) obj = {} k = max(g.degree()) # reorders the edge if necessary... R = lambda x: x if (x[0] <= x[1]) else (x[1], x[0]) # Vizing's coloring uses Delta + 1 colors if vizing: value_only = False k += 1 # A vertex can not have two incident edges with the same color. [p.add_constraint( sum([color[R(e)][i] for e in g.edges_incident(v, labels=False)]), max=1) for v in g.vertex_iterator() for i in xrange(k)] # an edge must have a color [p.add_constraint(sum([color[R(e)][i] for i in xrange(k)]), max=1, min=1) for e in g.edge_iterator(labels=False)] # anything is good as an objective value as long as it is satisfiable e = g.edge_iterator(labels=False).next() p.set_objective(color[R(e)][0]) p.set_binary(color) try: if value_only: p.solve(objective_only=True, log=log) else: chi = p.solve(log=log) except: if value_only: return k + 1 else: # if the coloring with Delta colors fails, tries Delta + 1 return edge_coloring(g, vizing=True, hex_colors=hex_colors, log=log) if value_only: return k # Builds the color classes color = p.get_values(color) classes = [[] for i in xrange(k)] [classes[i].append(e) for e in g.edge_iterator(labels=False) for i in xrange(k) if color[R(e)][i] == 1] # if needed, builds a dictionary from the color classes adding colors if hex_colors: return dict(zip(rainbow(len(classes)), classes)) else: return classes
|
def edge_coloring(g, value_only=False, vizing=False, hex_colors=False, log=0): r""" Properly colors the edges of a graph. See the URL http://en.wikipedia.org/wiki/Edge_coloring for further details on edge coloring. INPUT: - ``g`` -- a graph. - ``value_only`` -- (default: ``False``): - When set to ``True``, only the chromatic index is returned. - When set to ``False``, a partition of the edge set into matchings is returned if possible. - ``vizing`` -- (default: ``False``): - When set to ``True``, tries to find a `\Delta + 1`-edge-coloring, where `\Delta` is equal to the maximum degree in the graph. - When set to ``False``, tries to find a `\Delta`-edge-coloring, where `\Delta` is equal to the maximum degree in the graph. If impossible, tries to find and returns a `\Delta + 1`-edge-coloring. This implies that ``value_only=False``. - ``hex_colors`` -- (default: ``False``) when set to ``True``, the partition returned is a dictionary whose keys are colors and whose values are the color classes (ideal for plotting). - ``log`` -- (default: ``0``) as edge-coloring is an `NP`-complete problem, this function may take some time depending on the graph. Use ``log`` to define the level of verbosity you wantfrom the linear program solver. By default ``log=0``, meaning that there will be no message printed by the solver. OUTPUT: In the following, `\Delta` is equal to the maximum degree in the graph ``g``. - If ``vizing=True`` and ``value_only=False``, return a partition of the edge set into `\Delta + 1` matchings. - If ``vizing=False`` and ``value_only=True``, return the chromatic index. - If ``vizing=False`` and ``value_only=False``, return a partition of the edge set into the minimum number of matchings. - If ``vizing=True`` and ``value_only=True``, should return something, but mainly you are just trying to compute the maximum degree of the graph, and this is not the easiest way. By Vizing's theorem, a graph has a chromatic index equal to `\Delta` or to `\Delta + 1`. .. NOTE:: In a few cases, it is possible to find very quickly the chromatic index of a graph, while it remains a tedious job to compute a corresponding coloring. For this reason, ``value_only = True`` can sometimes be much faster, and it is a bad idea to compute the whole coloring if you do not need it ! EXAMPLE:: sage: from sage.graphs.graph_coloring import edge_coloring sage: g = graphs.PetersenGraph() sage: edge_coloring(g, value_only=True) # optional - requires GLPK or CBC 4 Complete graphs are colored using the linear-time round-robin coloring:: sage: from sage.graphs.graph_coloring import edge_coloring sage: len(edge_coloring(graphs.CompleteGraph(20))) 19 """ from sage.numerical.mip import MixedIntegerLinearProgram from sage.plot.colors import rainbow from sage.numerical.mip import MIPSolverException if g.is_clique(): if value_only: return g.order()-1 if g.order() % 2 == 0 else g.order() vertices = g.vertices() r = round_robin(g.order()) classes = [[] for v in g] if g.order() % 2 == 0 and not vizing: classes.pop() for (u, v, c) in r.edge_iterator(): classes[c].append((vertices[u], vertices[v])) if hex_colors: return dict(zip(rainbow(len(classes)), classes)) else: return classes if value_only and g.is_overfull(): return max(g.degree())+1 p = MixedIntegerLinearProgram(maximization=True) color = p.new_variable(dim=2) obj = {} k = max(g.degree()) # reorders the edge if necessary... R = lambda x: x if (x[0] <= x[1]) else (x[1], x[0]) # Vizing's coloring uses Delta + 1 colors if vizing: value_only = False k += 1 # A vertex can not have two incident edges with the same color. [p.add_constraint( sum([color[R(e)][i] for e in g.edges_incident(v, labels=False)]), max=1) for v in g.vertex_iterator() for i in xrange(k)] # an edge must have a color [p.add_constraint(sum([color[R(e)][i] for i in xrange(k)]), max=1, min=1) for e in g.edge_iterator(labels=False)] # anything is good as an objective value as long as it is satisfiable e = g.edge_iterator(labels=False).next() p.set_objective(color[R(e)][0]) p.set_binary(color) try: if value_only: p.solve(objective_only=True, log=log) else: chi = p.solve(log=log) except MIPSolverException: if value_only: return k + 1 else: # if the coloring with Delta colors fails, tries Delta + 1 return edge_coloring(g, vizing=True, hex_colors=hex_colors, log=log) if value_only: return k # Builds the color classes color = p.get_values(color) classes = [[] for i in xrange(k)] [classes[i].append(e) for e in g.edge_iterator(labels=False) for i in xrange(k) if color[R(e)][i] == 1] # if needed, builds a dictionary from the color classes adding colors if hex_colors: return dict(zip(rainbow(len(classes)), classes)) else: return classes
| 472,985
|
def minpoly(ex, var='x', algorithm=None, bits=None, degree=None, epsilon=0): r""" Return the minimal polynomial of self, if possible. INPUT: - ``var`` - polynomial variable name (default 'x') - ``algorithm`` - 'algebraic' or 'numerical' (default both, but with numerical first) - ``bits`` - the number of bits to use in numerical approx - ``degree`` - the expected algebraic degree - ``epsilon`` - return without error as long as f(self) epsilon, in the case that the result cannot be proven. All of the above parameters are optional, with epsilon=0, bits and degree tested up to 1000 and 24 by default respectively. The numerical algorithm will be faster if bits and/or degree are given explicitly. The algebraic algorithm ignores the last three parameters. OUTPUT: The minimal polynomial of self. If the numerical algorithm is used then it is proved symbolically when epsilon=0 (default). If the minimal polynomial could not be found, two distinct kinds of errors are raised. If no reasonable candidate was found with the given bit/degree parameters, a ``ValueError`` will be raised. If a reasonable candidate was found but (perhaps due to limits in the underlying symbolic package) was unable to be proved correct, a ``NotImplementedError`` will be raised. ALGORITHM: Two distinct algorithms are used, depending on the algorithm parameter. By default, the numerical algorithm is attempted first, then the algebraic one. Algebraic: Attempt to evaluate this expression in QQbar, using cyclotomic fields to resolve exponential and trig functions at rational multiples of pi, field extensions to handle roots and rational exponents, and computing compositums to represent the full expression as an element of a number field where the minimal polynomial can be computed exactly. The bits, degree, and epsilon parameters are ignored. Numerical: Computes a numerical approximation of ``self`` and use PARI's algdep to get a candidate minpoly `f`. If `f(\mathtt{self})`, evaluated to a higher precision, is close enough to 0 then evaluate `f(\mathtt{self})` symbolically, attempting to prove vanishing. If this fails, and ``epsilon`` is non-zero, return `f` if and only if `f(\mathtt{self}) < \mathtt{epsilon}`. Otherwise raise a ``ValueError`` (if no suitable candidate was found) or a ``NotImplementedError`` (if a likely candidate was found but could not be proved correct). EXAMPLES: First some simple examples:: sage: sqrt(2).minpoly() x^2 - 2 sage: minpoly(2^(1/3)) x^3 - 2 sage: minpoly(sqrt(2) + sqrt(-1)) x^4 - 2*x^2 + 9 sage: minpoly(sqrt(2)-3^(1/3)) x^6 - 6*x^4 + 6*x^3 + 12*x^2 + 36*x + 1 Works with trig and exponential functions too. :: sage: sin(pi/3).minpoly() x^2 - 3/4 sage: sin(pi/7).minpoly() x^6 - 7/4*x^4 + 7/8*x^2 - 7/64 sage: minpoly(exp(I*pi/17)) x^16 - x^15 + x^14 - x^13 + x^12 - x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 - x^3 + x^2 - x + 1 Here we verify it gives the same result as the abstract number field. :: sage: (sqrt(2) + sqrt(3) + sqrt(6)).minpoly() x^4 - 22*x^2 - 48*x - 23 sage: K.<a,b> = NumberField([x^2-2, x^2-3]) sage: (a+b+a*b).absolute_minpoly() x^4 - 22*x^2 - 48*x - 23 The minpoly function is used implicitly when creating number fields:: sage: x = var('x') sage: eqn = x^3 + sqrt(2)*x + 5 == 0 sage: a = solve(eqn, x)[0].rhs() sage: QQ[a] Number Field in a with defining polynomial x^6 + 10*x^3 - 2*x^2 + 25 Here we solve a cubic and then recover it from its complicated radical expansion. :: sage: f = x^3 - x + 1 sage: a = f.solve(x)[0].rhs(); a -1/2*(I*sqrt(3) + 1)*(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) - 1/6*(-I*sqrt(3) + 1)/(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) sage: a.minpoly() x^3 - x + 1 Note that simplification may be necessary to see that the minimal polynomial is correct. :: sage: a = sqrt(2)+sqrt(3)+sqrt(5) sage: f = a.minpoly(); f x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576 sage: f(a) ((((sqrt(2) + sqrt(3) + sqrt(5))^2 - 40)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 352)*(sqrt(2) + sqrt(3) + sqrt(5))^2 - 960)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 576 sage: f(a).expand() 0 Here we show use of the ``epsilon`` parameter. That this result is actually exact can be shown using the addition formula for sin, but maxima is unable to see that. :: sage: a = sin(pi/5) sage: a.minpoly(algorithm='numerical') Traceback (most recent call last): ... NotImplementedError: Could not prove minimal polynomial x^4 - 5/4*x^2 + 5/16 (epsilon 0.00000000000000e-1) sage: f = a.minpoly(algorithm='numerical', epsilon=1e-100); f x^4 - 5/4*x^2 + 5/16 sage: f(a).numerical_approx(100) 0.00000000000000000000000000000 The degree must be high enough (default tops out at 24). :: sage: a = sqrt(3) + sqrt(2) sage: a.minpoly(algorithm='numerical', bits=100, degree=3) Traceback (most recent call last): ... ValueError: Could not find minimal polynomial (100 bits, degree 3). sage: a.minpoly(algorithm='numerical', bits=100, degree=10) x^4 - 10*x^2 + 1 There is a difference between algorithm='algebraic' and algorithm='numerical':: sage: cos(pi/33).minpoly(algorithm='algebraic') x^10 + 1/2*x^9 - 5/2*x^8 - 5/4*x^7 + 17/8*x^6 + 17/16*x^5 - 43/64*x^4 - 43/128*x^3 + 3/64*x^2 + 3/128*x + 1/1024 sage: cos(pi/33).minpoly(algorithm='numerical') Traceback (most recent call last): ... NotImplementedError: Could not prove minimal polynomial x^10 + 1/2*x^9 - 5/2*x^8 - 5/4*x^7 + 17/8*x^6 + 17/16*x^5 - 43/64*x^4 - 43/128*x^3 + 3/64*x^2 + 3/128*x + 1/1024 (epsilon ...) Sometimes it fails, as it must given that some numbers aren't algebraic:: sage: sin(1).minpoly(algorithm='numerical') Traceback (most recent call last): ... ValueError: Could not find minimal polynomial (1000 bits, degree 24). .. note:: Of course, failure to produce a minimal polynomial does not necessarily indicate that this number is transcendental. AUTHORS: - Robert Bradshaw (2007-10): numerical algorithm - Robert Bradshaw (2008-10): algebraic algorithm """ if algorithm is None or algorithm.startswith('numeric'): bits_list = [bits] if bits else [100,200,500,1000] degree_list = [degree] if degree else [2,4,8,12,24] for bits in bits_list: a = ex.numerical_approx(bits) check_bits = int(1.25 * bits + 80) aa = ex.numerical_approx(check_bits) for degree in degree_list: f = QQ[var](algdep(a, degree)) # TODO: use the known_bits parameter? # If indeed we have found a minimal polynomial, # it should be accurate to a much higher precision. error = abs(f(aa)) dx = ~RR(Integer(1) << (check_bits - degree - 2)) expected_error = abs(f.derivative()(CC(aa))) * dx if error < expected_error: # Degree might have been an over-estimate, factor because we want (irreducible) minpoly. ff = f.factor() for g, e in ff: lead = g.leading_coefficient() if lead != 1: g = g / lead expected_error = abs(g.derivative()(CC(aa))) * dx error = abs(g(aa)) if error < expected_error: # See if we can prove equality exactly if g(ex).simplify_trig().simplify_radical() == 0: return g # Otherwise fall back to numerical guess elif epsilon and error < epsilon: return g elif algorithm is not None: raise NotImplementedError, "Could not prove minimal polynomial %s (epsilon %s)" % (g, RR(error).str(no_sci=False)) if algorithm is not None: raise ValueError, "Could not find minimal polynomial (%s bits, degree %s)." % (bits, degree) if algorithm is None or algorithm == 'algebraic': from sage.rings.all import QQbar return QQ[var](QQbar(ex).minpoly()) raise ValueError, "Unknown algorithm: %s" % algorithm
|
def minpoly(ex, var='x', algorithm=None, bits=None, degree=None, epsilon=0): r""" Return the minimal polynomial of self, if possible. INPUT: - ``var`` - polynomial variable name (default 'x') - ``algorithm`` - 'algebraic' or 'numerical' (default both, but with numerical first) - ``bits`` - the number of bits to use in numerical approx - ``degree`` - the expected algebraic degree - ``epsilon`` - return without error as long as f(self) epsilon, in the case that the result cannot be proven. All of the above parameters are optional, with epsilon=0, bits and degree tested up to 1000 and 24 by default respectively. The numerical algorithm will be faster if bits and/or degree are given explicitly. The algebraic algorithm ignores the last three parameters. OUTPUT: The minimal polynomial of self. If the numerical algorithm is used then it is proved symbolically when epsilon=0 (default). If the minimal polynomial could not be found, two distinct kinds of errors are raised. If no reasonable candidate was found with the given bit/degree parameters, a ``ValueError`` will be raised. If a reasonable candidate was found but (perhaps due to limits in the underlying symbolic package) was unable to be proved correct, a ``NotImplementedError`` will be raised. ALGORITHM: Two distinct algorithms are used, depending on the algorithm parameter. By default, the numerical algorithm is attempted first, then the algebraic one. Algebraic: Attempt to evaluate this expression in QQbar, using cyclotomic fields to resolve exponential and trig functions at rational multiples of pi, field extensions to handle roots and rational exponents, and computing compositums to represent the full expression as an element of a number field where the minimal polynomial can be computed exactly. The bits, degree, and epsilon parameters are ignored. Numerical: Computes a numerical approximation of ``self`` and use PARI's algdep to get a candidate minpoly `f`. If `f(\mathtt{self})`, evaluated to a higher precision, is close enough to 0 then evaluate `f(\mathtt{self})` symbolically, attempting to prove vanishing. If this fails, and ``epsilon`` is non-zero, return `f` if and only if `f(\mathtt{self}) < \mathtt{epsilon}`. Otherwise raise a ``ValueError`` (if no suitable candidate was found) or a ``NotImplementedError`` (if a likely candidate was found but could not be proved correct). EXAMPLES: First some simple examples:: sage: sqrt(2).minpoly() x^2 - 2 sage: minpoly(2^(1/3)) x^3 - 2 sage: minpoly(sqrt(2) + sqrt(-1)) x^4 - 2*x^2 + 9 sage: minpoly(sqrt(2)-3^(1/3)) x^6 - 6*x^4 + 6*x^3 + 12*x^2 + 36*x + 1 Works with trig and exponential functions too. :: sage: sin(pi/3).minpoly() x^2 - 3/4 sage: sin(pi/7).minpoly() x^6 - 7/4*x^4 + 7/8*x^2 - 7/64 sage: minpoly(exp(I*pi/17)) x^16 - x^15 + x^14 - x^13 + x^12 - x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 - x^3 + x^2 - x + 1 Here we verify it gives the same result as the abstract number field. :: sage: (sqrt(2) + sqrt(3) + sqrt(6)).minpoly() x^4 - 22*x^2 - 48*x - 23 sage: K.<a,b> = NumberField([x^2-2, x^2-3]) sage: (a+b+a*b).absolute_minpoly() x^4 - 22*x^2 - 48*x - 23 The minpoly function is used implicitly when creating number fields:: sage: x = var('x') sage: eqn = x^3 + sqrt(2)*x + 5 == 0 sage: a = solve(eqn, x)[0].rhs() sage: QQ[a] Number Field in a with defining polynomial x^6 + 10*x^3 - 2*x^2 + 25 Here we solve a cubic and then recover it from its complicated radical expansion. :: sage: f = x^3 - x + 1 sage: a = f.solve(x)[0].rhs(); a -1/2*(I*sqrt(3) + 1)*(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) - 1/6*(-I*sqrt(3) + 1)/(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) sage: a.minpoly() x^3 - x + 1 Note that simplification may be necessary to see that the minimal polynomial is correct. :: sage: a = sqrt(2)+sqrt(3)+sqrt(5) sage: f = a.minpoly(); f x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576 sage: f(a) ((((sqrt(2) + sqrt(3) + sqrt(5))^2 - 40)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 352)*(sqrt(2) + sqrt(3) + sqrt(5))^2 - 960)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 576 sage: f(a).expand() 0 Here we show use of the ``epsilon`` parameter. That this result is actually exact can be shown using the addition formula for sin, but maxima is unable to see that. :: sage: a = sin(pi/5) sage: a.minpoly(algorithm='numerical') Traceback (most recent call last): ... NotImplementedError: Could not prove minimal polynomial x^4 - 5/4*x^2 + 5/16 (epsilon 0.00000000000000e-1) sage: f = a.minpoly(algorithm='numerical', epsilon=1e-100); f x^4 - 5/4*x^2 + 5/16 sage: f(a).numerical_approx(100) 0.00000000000000000000000000000 The degree must be high enough (default tops out at 24). :: sage: a = sqrt(3) + sqrt(2) sage: a.minpoly(algorithm='numerical', bits=100, degree=3) Traceback (most recent call last): ... ValueError: Could not find minimal polynomial (100 bits, degree 3). sage: a.minpoly(algorithm='numerical', bits=100, degree=10) x^4 - 10*x^2 + 1 There is a difference between algorithm='algebraic' and algorithm='numerical':: sage: cos(pi/33).minpoly(algorithm='algebraic') x^10 + 1/2*x^9 - 5/2*x^8 - 5/4*x^7 + 17/8*x^6 + 17/16*x^5 - 43/64*x^4 - 43/128*x^3 + 3/64*x^2 + 3/128*x + 1/1024 sage: cos(pi/33).minpoly(algorithm='numerical') Traceback (most recent call last): ... NotImplementedError: Could not prove minimal polynomial x^10 + 1/2*x^9 - 5/2*x^8 - 5/4*x^7 + 17/8*x^6 + 17/16*x^5 - 43/64*x^4 - 43/128*x^3 + 3/64*x^2 + 3/128*x + 1/1024 (epsilon ...) Sometimes it fails, as it must given that some numbers aren't algebraic:: sage: sin(1).minpoly(algorithm='numerical') Traceback (most recent call last): ... ValueError: Could not find minimal polynomial (1000 bits, degree 24). .. note:: Of course, failure to produce a minimal polynomial does not necessarily indicate that this number is transcendental. """ if algorithm is None or algorithm.startswith('numeric'): bits_list = [bits] if bits else [100,200,500,1000] degree_list = [degree] if degree else [2,4,8,12,24] for bits in bits_list: a = ex.numerical_approx(bits) check_bits = int(1.25 * bits + 80) aa = ex.numerical_approx(check_bits) for degree in degree_list: f = QQ[var](algdep(a, degree)) # TODO: use the known_bits parameter? # If indeed we have found a minimal polynomial, # it should be accurate to a much higher precision. error = abs(f(aa)) dx = ~RR(Integer(1) << (check_bits - degree - 2)) expected_error = abs(f.derivative()(CC(aa))) * dx if error < expected_error: # Degree might have been an over-estimate, factor because we want (irreducible) minpoly. ff = f.factor() for g, e in ff: lead = g.leading_coefficient() if lead != 1: g = g / lead expected_error = abs(g.derivative()(CC(aa))) * dx error = abs(g(aa)) if error < expected_error: # See if we can prove equality exactly if g(ex).simplify_trig().simplify_radical() == 0: return g # Otherwise fall back to numerical guess elif epsilon and error < epsilon: return g elif algorithm is not None: raise NotImplementedError, "Could not prove minimal polynomial %s (epsilon %s)" % (g, RR(error).str(no_sci=False)) if algorithm is not None: raise ValueError, "Could not find minimal polynomial (%s bits, degree %s)." % (bits, degree) if algorithm is None or algorithm == 'algebraic': from sage.rings.all import QQbar return QQ[var](QQbar(ex).minpoly()) raise ValueError, "Unknown algorithm: %s" % algorithm
| 472,986
|
def _limit_latex_(self, f, x, a): r""" Return latex expression for limit of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _limit_latex_ sage: var('x,a') (x, a) sage: f = function('f',x) sage: _limit_latex_(0, f, x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' sage: latex(limit(f, x=oo)) \lim_{x \to +\infty}\, f\left(x\right) AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
|
def _limit_latex_(self, f, x, a): r""" Return latex expression for limit of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _limit_latex_ sage: var('x,a') (x, a) sage: f = function('f',x) sage: _limit_latex_(0, f, x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' sage: latex(limit(f, x=oo)) \lim_{x \to +\infty}\, f\left(x\right) """ return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
| 472,987
|
def _laplace_latex_(self, *args): r""" Return LaTeX expression for Laplace transform of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _laplace_latex_ sage: var('s,t') (s, t) sage: f = function('f',t) sage: _laplace_latex_(0,f,t,s) '\\mathcal{L}\\left(f\\left(t\\right), t, s\\right)' sage: latex(laplace(f, t, s)) \mathcal{L}\left(f\left(t\right), t, s\right) AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ return "\\mathcal{L}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
|
def _laplace_latex_(self, *args): r""" Return LaTeX expression for Laplace transform of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _laplace_latex_ sage: var('s,t') (s, t) sage: f = function('f',t) sage: _laplace_latex_(0,f,t,s) '\\mathcal{L}\\left(f\\left(t\\right), t, s\\right)' sage: latex(laplace(f, t, s)) \mathcal{L}\left(f\left(t\right), t, s\right) """ return "\\mathcal{L}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
| 472,988
|
def _inverse_laplace_latex_(self, *args): r""" Return LaTeX expression for inverse Laplace transform of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _inverse_laplace_latex_ sage: var('s,t') (s, t) sage: F = function('F',s) sage: _inverse_laplace_latex_(0,F,s,t) '\\mathcal{L}^{-1}\\left(F\\left(s\\right), s, t\\right)' sage: latex(inverse_laplace(F,s,t)) \mathcal{L}^{-1}\left(F\left(s\right), s, t\right) AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ return "\\mathcal{L}^{-1}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
|
def _inverse_laplace_latex_(self, *args): r""" Return LaTeX expression for inverse Laplace transform of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _inverse_laplace_latex_ sage: var('s,t') (s, t) sage: F = function('F',s) sage: _inverse_laplace_latex_(0,F,s,t) '\\mathcal{L}^{-1}\\left(F\\left(s\\right), s, t\\right)' sage: latex(inverse_laplace(F,s,t)) \mathcal{L}^{-1}\left(F\left(s\right), s, t\right) """ return "\\mathcal{L}^{-1}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
| 472,989
|
def uname_specific(name, value, alternative): if name in os.uname()[0]: return value else: return alternative
|
def uname_specific(name, value, alternative): if name in os.uname()[0]: return value else: return alternative
| 472,990
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,991
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string of symbols over some alphabet. OUTPUT: - A table of frequency of each unique symbol in ``string``. If ``string`` is an empty string, return an empty table. EXAMPLES: The frequency table of a non-empty string:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,992
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Stop counting my characters!" sage: T = sorted(frequency_table(str).items()) sage: for symbol, code in T: ... print symbol, code ... 3 ! 1 S 1 a 2 c 3 e 1 g 1 h 1 i 1 m 1 n 2 o 2 p 1 r 2 s 1 t 3 u 1 y 1 The frequency of an empty string:: sage: frequency_table("") {} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,993
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for s in string: d[s] = d.get(s, 0) + 1 return d
| 472,994
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,995
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,996
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,997
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,998
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
|
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
| 472,999
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.