rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
X3 = singular.extcurve(1, X2) R = X3[1][5] | v = X2[3].sage_flattened_str_list() v = [ v[i].partition(',') for i in range(len(v)) ] pnts = [ ( int(v[i][0]), int(v[i][2])-1 ) for i in range(len(v))] R = X2[5][1][1] | def riemann_roch_basis(self, D): r""" Return a basis for the Riemann-Roch space corresponding to `D`. |
pnts = [self(int(v[3*i]), int(v[3*i+1]), int(v[3*i+2])) for i in range(len(v)/3)] | coords = [self(int(v[3*i]), int(v[3*i+1]), int(v[3*i+2])) for i in range(len(v)/3)] | def riemann_roch_basis(self, D): r""" Return a basis for the Riemann-Roch space corresponding to `D`. |
Dcoeffs.append(D.coefficient(x)) | if x[0] == 1: Dcoeffs.append(D.coefficient(coords[x[1]])) else: Dcoeffs.append(0) | def riemann_roch_basis(self, D): r""" Return a basis for the Riemann-Roch space corresponding to `D`. |
command = 'magma' | command = 'sage-native-execute magma' | def __init__(self, maxread=10000, script_subdirectory=None, logfile=None, server=None, server_tmpdir=None, user_config=False): """ INPUT: |
if self.ambient_vector_space() != other.ambient_vector_space(): return False if other == other.ambient_vector_space(): return True | try: if self.ambient_vector_space() != other.ambient_vector_space(): return False if other == other.ambient_vector_space(): return True except AttributeError: pass | def is_submodule(self, other): """ Return True if self is a submodule of other. |
""" | r""" | def eigenvalues(self,extend=True): """ Returns a list with the eigenvalues of the endomorphism of vector spaces. |
If the option extend is set to True (default), then eigenvalues in extensions of the base field are considered. | INPUT: - ``extend`` -- boolean (default: True) decides if base field extensions should be considered or not. | def eigenvalues(self,extend=True): """ Returns a list with the eigenvalues of the endomorphism of vector spaces. |
We compute the eigenvalues of an endomorphism of QQ^3:: | We compute the eigenvalues of an endomorphism of `\QQ^3`:: | def eigenvalues(self,extend=True): """ Returns a list with the eigenvalues of the endomorphism of vector spaces. |
Note the effect of the extend option:: | Note the effect of the ``extend`` option:: | def eigenvalues(self,extend=True): """ Returns a list with the eigenvalues of the endomorphism of vector spaces. |
- extend (True) decides if base field extensions should be considered or not. | - ``extend`` -- boolean (default: True) decides if base field extensions should be considered or not. | def eigenvectors(self,extend=True): """ Computes the subspace of eigenvectors of a given eigenvalue. |
A sequence of tuples. Each tuple contains an eigenvalue, a list with a basis of the corresponding subspace of eigenvectors, and the algebraic multiplicity of the eigenvalue. | A sequence of tuples. Each tuple contains an eigenvalue, a sequence with a basis of the corresponding subspace of eigenvectors, and the algebraic multiplicity of the eigenvalue. | def eigenvectors(self,extend=True): """ Computes the subspace of eigenvectors of a given eigenvalue. |
svectors=map(lambda j: V(j * V.basis_matrix()),i[1]) resu.append(tuple([i[0],svectors,i[2]])) | svectors=Sequence(map(lambda j: V(j * V.basis_matrix()),i[1]), cr=True) resu.append((i[0],svectors,i[2])) | def eigenvectors(self,extend=True): """ Computes the subspace of eigenvectors of a given eigenvalue. |
- ``var`` - string (default: 'x') a variable | - ``var`` - string (default: 'x') a variable name | def minpoly(self,var='x'): """ Computes the minimal polynomial. |
if x == 0: | if x == 0 and not x in self._space: | def __call__(self, *args): """ Coerces the element into the ring. |
K = self.base_ring()._magma_init_(magma) | K = magma(self.base_ring()) | def _magma_init_(self, magma): r""" EXAMPLES: We first coerce a square matrix. |
s = 'MatrixAlgebra(%s,%s)'%(K, self.__nrows) | s = 'MatrixAlgebra(%s,%s)'%(K.name(), self.__nrows) | def _magma_init_(self, magma): r""" EXAMPLES: We first coerce a square matrix. |
s = 'RMatrixSpace(%s,%s,%s)'%(K, self.__nrows, self.__ncols) | s = 'RMatrixSpace(%s,%s,%s)'%(K.name(), self.__nrows, self.__ncols) | def _magma_init_(self, magma): r""" EXAMPLES: We first coerce a square matrix. |
""" | TESTS:: sage: P = PolynomialRing(QQ, 0, '') sage: P(5).univariate_polynomial() 5 """ if self.parent().ngens() == 0: if R is None: return self.base_ring()(self) else: return R(self) | def univariate_polynomial(self, R=None): """ Returns a univariate polynomial associated to this multivariate polynomial. |
if self == 0: raise ArithmeticError, "Prime factorization of 0 not defined." if R.ngens() == 0: base_ring = self.base_ring() if base_ring.is_field(): return Factorization([],unit=self.base_ring()(self)) else: F = base_ring(self).factor() return Factorization([(R(f),m) for f,m in F], unit=F.unit()) | def factor(self, proof=True): r""" Compute the irreducible factorization of this polynomial. |
|
return 0 | return ZZ(0) | def _eval_(self, x): """ |
return 1 | return ZZ(1) | def _eval_(self, x): """ |
return -1 | return ZZ(-1) | def _eval_(self, x): """ |
We can plot with this transform. Remember that the independent variable is the radius, and the dependent variables are the | We can plot with this transform. Remember that the dependent variable is the radius, and the independent variables are the | def transform(self, **kwds): """ EXAMPLE:: |
R = self.base_ring()[str(self.variables()[0])] | if self.is_constant(): R = self.base_ring()[self.parent().variable_names()[0]] else: R = self.base_ring()[str(self.variables()[0])] | def univariate_polynomial(self, R=None): """ Returns a univariate polynomial associated to this multivariate polynomial. |
This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S NOTE: This function assumes S is a list of prime ideals, it does not check this. This function will fail if S is not a list of prime ideals. | Return the part of this fractional ideal which is coprime to the prime ideals in the list ``S``. .. note:: This function assumes that `S` is a list of prime ideals, but does not check this. This function will fail if `S` is not a list of prime ideals. | def prime_to_S_part(self,S): r""" This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S |
- "self" - fractional ideal - "S" - a list of prime ideals | - `S` - a list of prime ideals | def prime_to_S_part(self,S): r""" This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S |
- an ideal coprime to the ideals in S EXAMPLES:: | A fractional ideal coprime to the primes in `S`, whose prime factorization is that of ``self`` withe the primes in `S` removed. EXAMPLES:: | def prime_to_S_part(self,S): r""" This function returns the part of the fractional ideal self which is coprime to the prime ideals in the list S |
sage: S == loads(dumps(S)) True | sage: TestSuite(S).run() | def __init__(self, s): """ TESTS:: |
element_class = Set_generic | def _element_constructor_(self, x): """ TESTS:: sage: S3 = Subsets(3); S3([1,2]) {1, 2} sage: S3([0,1,2]) Traceback (most recent call last): ... ValueError: [0, 1, 2] not in Subsets of {1, 2, 3} """ return Set(x) element_class = Set_object_enumerated | def unrank(self, r): """ Returns the subset of s that has rank k. |
sage: S == loads(dumps(S)) True | sage: TestSuite(S).run() | def __init__(self, s, k): """ TESTS:: |
element_class = Set_generic | def _element_constructor_(self, x): """ TESTS:: sage: S32 = Subsets(3,2); S32([1,2]) {1, 2} sage: S32([0,1,2]) Traceback (most recent call last): ... ValueError: [0, 1, 2] not in Subsets of {1, 2, 3} of size 2 """ return Set(x) element_class = Set_object_enumerated | def unrank(self, r): """ Returns the subset of s that has rank k. |
sage: S == loads(dumps(S)) True | sage: TestSuite(S).run() | def unrank(self, r): """ Returns the subset of s that has rank k. |
img = self(letter) | img = self.image(letter) | def is_identity(self): r""" Returns ``True`` if ``self`` is the identity morphism. |
([0], [0]) | ([0], []) | 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. |
return [s],[s] | return [s],[] | 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. |
Computes the matching polynomial of the graph G. The algorithm used is a recursive one, based on the following observation: - If e is an edge of G, G' is the result of deleting the edge e, and G'' is the result of deleting each vertex in e, then the matching polynomial of G is equal to that of G' minus that of G''. | Computes the matching polynomial of the graph `G`. If `p(G, k)` denotes the number of `k`-matchings (matchings with `k` edges) in `G`, then the matching polynomial is defined as [Godsil93]_: .. MATH:: \mu(x)=\sum_{k \geq 0} (-1)^k p(G,k) x^{n-2k} | def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G. |
- ``complement`` - (default: True) whether to use a simple formula to compute the matching polynomial from that of the graphs complement | - ``complement`` - (default: ``True``) whether to use Godsil's duality theorem to compute the matching polynomial from that of the graphs complement (see ALGORITHM). | def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G. |
NOTE: The ``complement`` option uses matching polynomials of complete graphs, which are cached. So if you are crazy enough to try computing the matching polynomial on a graph with millions of vertices, you might not want to use this option, since it will end up caching millions of polynomials of degree in the millions. | def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G. |
|
sage: V = VectorSpace(QQ,5,sparse=True) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U | sage: VV = VectorSpace(QQ,5,sparse=True) sage: UU = VV.submodule([ VV.gen(i) - VV.gen(0) for i in range(1,5) ]) sage: print UU | def _repr_(self): """ The printing representation of self. |
sage: V = VectorSpace(QQ,5,sparse=True) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U | sage: VV = VectorSpace(QQ,5,sparse=True) sage: UU = VV.submodule([ VV.gen(i) - VV.gen(0) for i in range(1,5) ]) sage: print UU | def _repr_(self): """ The default printing representation of self. |
def parse_deps(self, filename, verify=True): | def parse_deps(self, filename, ext_module, verify=True): | def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies. |
if filename[-4:] not in ('.pyx', '.pxd', '.pxi'): | if not is_cython_file(filename): | def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies. |
for idir in CYTHON_INCLUDE_DIRS: new_path = os.path.normpath(idir + base_dependency_name) | for idir in ext_module.include_dirs + CYTHON_INCLUDE_DIRS + include_dirs + extra_include_dirs: new_path = os.path.normpath(idir + '/' + base_dependency_name) | def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies. |
if path[-2:] != '.h': raise IOError, "could not find dependency %s included in %s."%(path, filename) | msg = 'could not find dependency %s included in %s.'%(path, filename) if is_cython_file(filename): raise IOError, msg else: warnings.warn(msg+' I will assume it is a system C/C++ header.') | def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies. |
def all_deps(self, filename, path=None): | def all_deps(self, filename, ext_module, path=None): | def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file. |
for f in self.immediate_deps(filename): | for f in self.immediate_deps(filename, ext_module): | def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file. |
deps.update(self.all_deps(f, path)) | deps.update(self.all_deps(f, ext_module, path)) | def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file. |
Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | Constructs a Huffman code corresponding to an alphabet with the given weight table. INPUT: - ``dic`` -- a dictionary that associates to each symbol of an alphabet a numeric value. If we consider the frequency of each alphabetic symbol, then ``dic`` is considered as the frequency table of the alphabet with each numeric (non-negative integer) value being the number of occurrences of a symbol. The numeric values can also represent weights of the symbols. In that case, the numeric values are not necessarily integers, but can be real numbers. In general, we refer to ``dic`` as a weight table. | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. |
index = dic.items() | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. |
|
for i,(e,w) in enumerate(index): heappush(heap, (w, i) ) while len(heap)>=2: (w1, i1) = heappop(heap) (w2, i2) = heappop(heap) heappush(heap, (w1+w2,[i1,i2])) | for i, (s, w) in enumerate(dic.items()): heappush(heap, (w, i)) for i in range(1, len(dic)): weight_a, node_a = heappop(heap) weight_b, node_b = heappop(heap) heappush(heap, (weight_a + weight_b, [node_a, node_b])) | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. |
self._build_code_from_tree(self._tree, d) self._index = dict([(i,e) for i,(e,w) in enumerate(index)]) self._character_to_code = dict([(e,d[i]) for i,(e,w) in enumerate(index)]) | self._build_code_from_tree(self._tree, d, prefix="") self._index = dict((i, s) for i, (s, w) in enumerate(dic.items())) self._character_to_code = dict( (s, d[i]) for i, (s, w) in enumerate(dic.items())) | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. |
gens = [ "()" ] | k = max(self.entries()) gens = [range(1,k+1)] | def row_stabilizer(self): """ Return the PermutationGroup corresponding to the row stabilizer of self. |
Bijection of Biane from Dyck words to non crossing partitions | Bijection of Biane from Dyck words to non-crossing partitions. | def to_noncrossing_partition(self): r""" Bijection of Biane from Dyck words to non crossing partitions Thanks to Mathieu Dutour for describing the bijection. |
Returns the a-statistic for the Dyck word correspond to the area of the Dyck path. | Returns the a-statistic for the Dyck word corresponding to the area of the Dyck path. | def a_statistic(self): """ Returns the a-statistic for the Dyck word correspond to the area of the Dyck path. |
$(0, 0), (j_1, j_1), (j_2, j_2), ... , (j_r-1, j_r-1), (j_r, j_r) = (n, n).$ | .. MATH:: (0, 0), (j_1, j_1), (j_2, j_2), \dots , (j_r-1, j_r-1), (j_r, j_r) = (n, n). | def b_statistic(self): r""" Returns the b-statistic for the Dyck word corresponding to the bounce statistic of the Dyck word. |
def order(self, *gens, **kwds): | def order(self, *args, **kwds): | def order(self, *gens, **kwds): r""" Return the order with given ring generators in the maximal order of this number field. |
""" | sage: K.<a> = NumberField(x^3 - 2) sage: ZZ[a] Order in Number Field in a0 with defining polynomial x^3 - 2 TESTS: We verify that trac sage: K.<a> = NumberField(x^4 + 4*x^2 + 2) sage: B = K.integral_basis() sage: K.order(*B) Order in Number Field in a with defining polynomial x^4 + 4*x^2 + 2 sage: K.order(B) Order in Number Field in a with defining polynomial x^4 + 4*x^2 + 2 sage: K.order(gens=B) Order in Number Field in a with defining polynomial x^4 + 4*x^2 + 2 """ gens = kwds.pop('gens', args) | def order(self, *gens, **kwds): r""" Return the order with given ring generators in the maximal order of this number field. |
if any([type(arg).__module__ == 'numpy' for arg in args]): | if any([type(arg).__module__ == 'numpy' and type(arg).__name__ == "ndarray" for arg in args]): | def _call_element_(self, _the_element, *args, **kwds): """ Calling a callable symbolic expression returns a symbolic expression with the appropriate arguments substituted. |
sage: GenericDeclaration(x, 'rational').contradicts(y==pi) False sage: GenericDeclaration(x, 'rational').contradicts(y==pi) | sage: GenericDeclaration(x, 'rational').contradicts(x==pi) True sage: GenericDeclaration(x, 'irrational').contradicts(x!=pi) | def contradicts(self, soln): """ Returns ``True`` if this assumption is violated by the given variable assignment(s). |
sage: F = e.formal_group().group_law(5); F t1 + O(t1^5) + (1 - 2*t1^4 + O(t1^5))*t2 + (-4*t1^3 + O(t1^5))*t2^2 + (-4*t1^2 - 30*t1^4 + O(t1^5))*t2^3 + (-2*t1 - 30*t1^3 + O(t1^5))*t2^4 + O(t2^5) sage: i = e.formal_group().inverse(5) | sage: e.formal_group().group_law(5) t1 + O(t1^5) + (1 - 2*t1^4 + O(t1^5))*t2 + (-4*t1^3 + O(t1^5))*t2^2 + (-4*t1^2 - 30*t1^4 + O(t1^5))*t2^3 + (-2*t1 - 30*t1^3 + O(t1^5))*t2^4 + O(t2^5) sage: e = EllipticCurve('14a1') sage: ehat = e.formal() sage: ehat.group_law(3) t1 + O(t1^3) + (1 - t1 - 4*t1^2 + O(t1^3))*t2 + (-4*t1 + O(t1^3))*t2^2 + O(t2^3) sage: ehat.group_law(5) t1 + O(t1^5) + (1 - t1 - 2*t1^3 - 32*t1^4 + O(t1^5))*t2 + (-3*t1^2 - 59*t1^3 - 120*t1^4 + O(t1^5))*t2^2 + (-2*t1 - 59*t1^2 - 141*t1^3 - 347*t1^4 + O(t1^5))*t2^3 + (-32*t1 - 120*t1^2 - 347*t1^3 - 951*t1^4 + O(t1^5))*t2^4 + O(t2^5) sage: e = EllipticCurve(GF(7),[3,4]) sage: ehat = e.formal() sage: ehat.group_law(3) t1 + O(t1^3) + (1 + O(t1^3))*t2 + O(t2^3) sage: F = ehat.group_law(7); F t1 + O(t1^7) + (1 + t1^4 + 2*t1^6 + O(t1^7))*t2 + (2*t1^3 + 6*t1^5 + O(t1^7))*t2^2 + (2*t1^2 + 3*t1^4 + 2*t1^6 + O(t1^7))*t2^3 + (t1 + 3*t1^3 + 4*t1^5 + O(t1^7))*t2^4 + (6*t1^2 + 4*t1^4 + O(t1^7))*t2^5 + (2*t1 + 2*t1^3 + O(t1^7))*t2^6 + O(t2^7) TESTS:: sage: i = e.formal_group().inverse(7) | def group_law(self, prec=10): r""" The formal group law. |
O(t^5) | O(t^7) | def group_law(self, prec=10): r""" The formal group law. |
t1 + O(t1^4) + (1 + O(t1^4))*t2 + (-4*t1^3 + O(t1^4))*t2^2 + (-4*t1^2 + O(t1^4))*t2^3 + O(t2^4) | t1 + O(t1^4) + (1 + O(t1^4))*t2 + (2*t1^3 + O(t1^4))*t2^2 + (2*t1^2 + O(t1^4))*t2^3 + O(t2^4) Test for trac ticket 9646:: sage: P.<a1, a2, a3, a4, a6> = PolynomialRing(ZZ, 5) sage: E = EllipticCurve(list(P.gens())) sage: F = E.formal().group_law(prec = 4) sage: t2 = F.parent().gen() sage: t1 = F.parent().base_ring().gen() sage: F(t1, 0) t1 sage: F(0, t2) t2 sage: F[2][1] -a2 | def group_law(self, prec=10): r""" The formal group law. |
w = self.w(prec) | w = self.w(prec+1) | def group_law(self, prec=10): r""" The formal group law. |
lam = sum([tsum(n)*w[n] for n in range(3,prec)]) w1 = R1(w, prec) | lam = sum([tsum(n)*w[n] for n in range(3,prec+1)]) w1 = R1(w, prec+1) | def group_law(self, prec=10): r""" The formal group law. |
**NOTE: precision loss if P,Q in the infinite disc INPUT: - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points) OUTPUT: the Coleman integrals \int_P^Q w_i for w_i basis elements EXAMPLES: sage: K = pAdicField(11, 5) sage: x = polygen(K) sage: C = HyperellipticCurve(x^5 + 33/16*x^4 + 3/4*x^3 + 3/8*x^2 - 1/4*x + 1/16) sage: P = C.lift_x(2) sage: Q = C.lift_x(3) sage: C.coleman_integrals_on_basis(P, Q) (9*11 + 11^2 + 11^3 + 5*11^4 + O(11^5), 2*11 + 7*11^2 + 4*11^3 + 8*11^4 + O(11^5), 6 + 9*11 + 8*11^3 + 9*11^4 + O(11^5), 6 + 2*11 + 10*11^2 + 8*11^4 + O(11^5)) sage: C.coleman_integrals_on_basis(P, Q, algorithm='teichmuller') (9*11 + 11^2 + 11^3 + 5*11^4 + O(11^5), 2*11 + 7*11^2 + 4*11^3 + 8*11^4 + O(11^5), 6 + 9*11 + 8*11^3 + 9*11^4 + O(11^5), 6 + 2*11 + 10*11^2 + 8*11^4 + O(11^5)) | Computes the Coleman integrals on basis differentials INPUT: - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points) OUTPUT: the Coleman integrals \int_P^Q w_i for w_i basis elements EXAMPLES: sage: K = pAdicField(11, 5) sage: x = polygen(K) sage: C = HyperellipticCurve(x^5 + 33/16*x^4 + 3/4*x^3 + 3/8*x^2 - 1/4*x + 1/16) sage: P = C.lift_x(2) sage: Q = C.lift_x(3) sage: C.coleman_integrals_on_basis(P, Q) (9*11 + 11^2 + 11^3 + 5*11^4 + O(11^5), 2*11 + 7*11^2 + 4*11^3 + 8*11^4 + O(11^5), 6 + 9*11 + 8*11^3 + 9*11^4 + O(11^5), 6 + 2*11 + 10*11^2 + 8*11^4 + O(11^5)) sage: C.coleman_integrals_on_basis(P, Q, algorithm='teichmuller') (9*11 + 11^2 + 11^3 + 5*11^4 + O(11^5), 2*11 + 7*11^2 + 4*11^3 + 8*11^4 + O(11^5), 6 + 9*11 + 8*11^3 + 9*11^4 + O(11^5), 6 + 2*11 + 10*11^2 + 8*11^4 + O(11^5)) | def coleman_integrals_on_basis(self, P, Q, algorithm=None): """ |
self that are filled with a number less than | self that are filled with a number less than `n`. | def anti_restrict(self, n): """ Returns the skew tableau formed by removing all of the cells from self that are filled with a number less than |
def __repr__(self): | def _repr_(self): | def __repr__(self): """ TESTS:: |
def __init__(self): | def __init__(self, max_entry=None): | def __init__(self): """ TESTS:: |
""" | sage: SST = SemistandardTableaux(max_entry=5) sage: SST == loads(dumps(SST)) True """ self.max_entry = None if max_entry is not PlusInfinity(): self.max_entry = max_entry def _repr_(self): """ TESTS:: sage: SST = SemistandardTableaux() sage: SST Semistandard tableaux sage: SemistandardTableaux(max_entry=3) Semistandard tableaux with maximum entry 3 """ if self.max_entry is not None: return "Semistandard tableaux with maximum entry %s"%str(self.max_entry) return "Semistandard tableaux" | def __init__(self): """ TESTS:: |
sage: [[1,1],[2]] in SemistandardTableaux() True """ | sage: [[1,1],[5]] in SemistandardTableaux(max_entry=4) False """ | def __contains__(self, x): """ TESTS:: |
for row in t: for i in row: if not isinstance(i, (int, Integer)): | for i, row in enumerate(t): for j, entry in enumerate(row): if not isinstance(entry, (int, Integer)): | def __contains__(self, x): """ TESTS:: |
for row in t: for i in range(1, len(row)): if row[i] < row[i-1]: | if j > 0 and entry < row[j-1]: | def __contains__(self, x): """ TESTS:: |
conj = t.conjugate() for row in conj: for i in range(1, len(row)): if row[i] <= row[i-1]: | if i > 0 and entry <= t[i-1][j]: | def __contains__(self, x): """ TESTS:: |
def __init__(self, n): | def __init__(self, n, max_entry=None): | def __init__(self, n): """ TESTS:: |
def __repr__(self): | self.max_entry = None if max_entry is None: self.max_entry = n else: self.max_entry = max_entry def _repr_(self): | def __repr__(self): """ TESTS:: |
'Semistandard tableaux of size 3' """ return "Semistandard tableaux of size %s"%str(self.n) | 'Semistandard tableaux of size 3 and maximum entry 3' sage: repr(SemistandardTableaux(3, max_entry=6)) 'Semistandard tableaux of size 3 and maximum entry 6' """ return "Semistandard tableaux of size %s and maximum entry %s"%(str(self.n), str(self.max_entry)) | def __repr__(self): """ TESTS:: |
return x in SemistandardTableaux() and sum(map(len, x)) == self.n | return x in SemistandardTableaux_all(self.max_entry) and sum(map(len, x)) == self.n | def __contains__(self, x): """ EXAMPLES:: |
c += SemistandardTableaux(part).cardinality() | c += SemistandardTableaux_p(part, self.max_entry).cardinality() | def cardinality(self): """ EXAMPLES:: |
for sst in SemistandardTableaux(part): | for sst in SemistandardTableaux_p(part, self.max_entry): | def __iter__(self): """ EXAMPLES:: |
if not x in SemistandardTableaux(self.p): | if x not in SemistandardTableaux_p(self.p, self.max_entry): | def __contains__(self, x): """ EXAMPLES:: |
def __init__(self, p): | def __init__(self, p, max_entry=None): | def __init__(self, p): """ TESTS:: |
""" return x in SemistandardTableaux_all() and map(len, x) == self.p def __repr__(self): | sage: SST = SemistandardTableaux([2,1], max_entry=4) sage: all([sst in SST for sst in SST]) True sage: SST.cardinality() 20 """ return x in SemistandardTableaux_all(self.max_entry) and map(len, x) == self.p def _repr_(self): | def __contains__(self, x): """ EXAMPLES:: |
'Semistandard tableaux of shape [2, 1]' """ return "Semistandard tableaux of shape %s" % str(self.p) | 'Semistandard tableaux of shape [2, 1] and maximum entry 3' sage: repr(SemistandardTableaux([2,1], max_entry=5)) 'Semistandard tableaux of shape [2, 1] and maximum entry 5' """ return "Semistandard tableaux of shape %s and maximum entry %s" %(str(self.p), str(self.max_entry)) | def __repr__(self): """ TESTS:: |
for comp in IntegerVectors(sum(self.p), sum(self.p)): | for comp in IntegerVectors(sum(self.p), self.max_entry): | def cardinality(self): """ EXAMPLES:: |
""" for c in IntegerVectors(sum(self.p), sum(self.p)): for sst in SemistandardTableaux(self.p, c): | sage: [ t for t in SemistandardTableaux([1,1,1], max_entry=4) ] [[[1], [2], [3]], [[1], [2], [4]], [[1], [3], [4]], [[2], [3], [4]]] """ for c in IntegerVectors(sum(self.p), self.max_entry): for sst in SemistandardTableaux_pmu(self.p, c): | def __iter__(self): """ An iterator for the semistandard partitions of shape p. |
def __repr__(self): | self.max_entry = len(mu) def _repr_(self): | def __init__(self, n, mu): """ TESTS:: |
return x in SemistandardTableaux_all() and x in SemistandardTableaux(map(len, x), self.mu) | return x in SemistandardTableaux_pmu(map(len, x), self.mu) | def __contains__(self, x): """ TESTS:: |
""" | Multi-edged and looped graphs are partially supported:: sage: G = Graph({0:[1,1]}, multiedges=True) sage: G.is_planar() True sage: G.is_planar(on_embedding={}) Traceback (most recent call last): ... NotImplementedError: Cannot compute with embeddings of multiple-edged or looped graphs. sage: G.is_planar(set_pos=True) Traceback (most recent call last): ... NotImplementedError: Cannot compute with embeddings of multiple-edged or looped graphs. sage: G.is_planar(set_embedding=True) Traceback (most recent call last): ... NotImplementedError: Cannot compute with embeddings of multiple-edged or looped graphs. sage: G.is_planar(kuratowski=True) (True, None) :: sage: G = graphs.CompleteGraph(5) sage: G = Graph(G, multiedges=True) sage: G.add_edge(0,1) sage: G.is_planar() False sage: b,k = G.is_planar(kuratowski=True) sage: b False sage: k.vertices() [0, 1, 2, 3, 4] """ if self.has_multiple_edges() or self.has_loops(): if set_embedding or (on_embedding is not None) or set_pos: raise NotImplementedError("Cannot compute with embeddings of multiple-edged or looped graphs.") else: return self.to_simple().is_planar(kuratowski=kuratowski) | def is_planar(self, on_embedding=None, kuratowski=False, set_embedding=False, set_pos=False): """ Returns True if the graph is planar, and False otherwise. This wraps the reference implementation provided by John Boyer of the linear time planarity algorithm by edge addition due to Boyer Myrvold. (See reference code in graphs.planarity). |
Returns the Duursama data `v` and `m` of this formally s.d. code `C` | Returns the Duursma data `v` and `m` of this formally s.d. code `C` | def sd_duursma_data(C, i): r""" Returns the Duursama data `v` and `m` of this formally s.d. code `C` and the type number `i` in (1,2,3,4). Does *not* check if this code is actually sd. |
- Pair ``(v, m)`` as in Duursama [D]_ | - Pair ``(v, m)`` as in Duursma [D]_ | def sd_duursma_data(C, i): r""" Returns the Duursama data `v` and `m` of this formally s.d. code `C` and the type number `i` in (1,2,3,4). Does *not* check if this code is actually sd. |
- [D] - I. Duursma, "Extremal weight enumerators and ultraspherical polynomials" | .. [D] I. Duursma, "Extremal weight enumerators and ultraspherical polynomials" | def sd_duursma_data(C, i): r""" Returns the Duursama data `v` and `m` of this formally s.d. code `C` and the type number `i` in (1,2,3,4). Does *not* check if this code is actually sd. |
- Coefficients `q_0, q_1, ...` of `q(T)` as in Duursama [D]_ | - Coefficients `q_0, q_1, ...` of `q(T)` as in Duursma [D]_ | def sd_duursma_q(C,i,d0): r""" INPUT: |
return (self._sublattice_polytope.facet_constant(i) - self.facet_normal(i) * self._shift_vector) | return (self._sublattice_polytope.facet_constant(i) * self._dual_embedding_scale - self.facet_normal(i) * self._shift_vector ) | def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope. |
return (self._embedding_matrix * self._sublattice_polytope.facet_normal(i)) | return ( self._sublattice_polytope.facet_normal(i) * self._dual_embedding_matrix ) | def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope. |
basis = matrix( M.columns() + M.integer_kernel().basis() ).transpose() self._dual_embedding_scale = basis.det() | basis = M.columns() + M.integer_kernel().basis() basis = matrix(basis).transpose() self._dual_embedding_scale = abs(basis.det()) | def _compute_dim(self, compute_vertices): r""" Compute the dimension of this polytope and its vertices, if necessary. |
A lattice polytope of strictly smaller dimension (=2) than the ambient dimension(=4):: sage: LatticePolytope(matrix([(1, -1, 0), (-1, -1, 0), (1, 1, 0), (3, 3, 0)])) | This is a 2-dimensional lattice polytope in a 4-dimensional space:: sage: m = matrix([(1,-1,1,3), (-1,-1,1,3), (0,0,0,0)]) sage: p = LatticePolytope(m.transpose()) sage: p | def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope. |
sage: lp = LatticePolytope(matrix([(1, -1, 0), (-1, -1, 0), (1, 1, 0), (3, 3, 0)])) sage: lp.vertices() | sage: p.vertices() | def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope. |
sage: matrix([[ lp.facet_normal(i)*lp.vertex(j) + lp.facet_constant(i) for i in range(0,3)] for j in range(0,3)]) [-22 0 0] [ 0 -22 0] [ 0 0 -11] | sage: fns = [p.facet_normal(i) for i in range(p.nfacets())] sage: fns [(11, -1, 1, 3), (-11, -1, 1, 3), (0, 1, -1, -3)] sage: fcs = [p.facet_constant(i) for i in range(p.nfacets())] sage: fcs [0, 0, 11] Now we manually compute the distance matrix of this polytope. Since it is a triangle, each line (corresponding to a facet) should have two zeros (vertices of the corresponding facet) and one positive number (since our normals are inner):: sage: matrix([[fns[i] * p.vertex(j) + fcs[i] ... for j in range(p.nvertices())] ... for i in range(p.nfacets())]) [22 0 0] [ 0 22 0] [ 0 0 11] | def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope. |
parallel to the affine subspace spanned by this polytope. | orthogonal to the integer kernel of the affine subspace spanned by this polytope. | def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope. |
Here is an example of a 3-dimensional polytope in 4d:: sage: lp = LatticePolytope(matrix([[1,1,-1,0],[1,-1,-1,0],[1,1,1,0],[3,3,3,0]])) sage: lp.vertices() [ 1 1 -1 0] [ 1 -1 -1 0] [ 1 1 1 0] [ 3 3 3 0] sage: ker = lp.vertices().integer_kernel().matrix() | Here is an example of a 3-dimensional polytope in a 4-dimensional space:: sage: m = matrix([(0,0,0,0), (1,1,1,3), (1,-1,1,3), (-1,-1,1,3)]) sage: p = LatticePolytope(m.transpose()) sage: p.vertices() [ 0 1 1 -1] [ 0 1 -1 -1] [ 0 1 1 1] [ 0 3 3 3] sage: ker = p.vertices().integer_kernel().matrix() | def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.