bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def identity(self): """ Returns the identity projection.
def identity(self): """ Returns the identity projection.
473,100
def _call_element_(self, _the_element, *args, **kwds): """ Calling a callable symbolic expression returns a symbolic expression with the appropriate arguments substituted.
def _call_element_(self, _the_element, *args, **kwds): """ Calling a callable symbolic expression returns a symbolic expression with the appropriate arguments substituted.
473,101
def contradicts(self, soln): """ Returns ``True`` if this assumption is violated by the given variable assignment(s).
def contradicts(self, soln): """ Returns ``True`` if this assumption is violated by the given variable assignment(s).
473,102
def group_law(self, prec=10): r""" The formal group law.
def group_law(self, prec=10): r""" The formal group law.
473,103
def group_law(self, prec=10): r""" The formal group law.
def group_law(self, prec=10): r""" The formal group law.
473,104
def group_law(self, prec=10): r""" The formal group law.
def group_law(self, prec=10): r""" The formal group law.
473,105
def group_law(self, prec=10): r""" The formal group law.
def group_law(self, prec=10): r""" The formal group law.
473,106
def group_law(self, prec=10): r""" The formal group law.
def group_law(self, prec=10): r""" The formal group law.
473,107
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
473,108
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
473,109
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
473,110
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
defcoleman_integrals_on_basis(self,P,Q,algorithm=None):"""
473,111
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
defcoleman_integrals_on_basis(self,P,Q,algorithm=None):"""
473,112
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
defcoleman_integrals_on_basis(self,P,Q,algorithm=None):"""
473,113
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
473,114
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
defcoleman_integrals_on_basis(self,P,Q,algorithm=None):"""
473,115
def coleman_integrals_on_basis(self, P, Q, algorithm=None): """
defcoleman_integrals_on_basis(self,P,Q,algorithm=None):"""
473,116
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
473,117
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
473,118
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
473,119
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
def coleman_integral(self, w, P, Q, algorithm = 'None'): """ INPUT: - w differential (if one of P,Q is Weierstrass, w must be odd) - P point on self - Q point on self - algorithm (optional) = None (uses Frobenius) or teichmuller (uses Teichmuller points)
473,120
def log(x, base=None): """ Return the logarithm of x to the given base. Calls the ``log`` method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a ``log`` method. In other words, log works on more than just real numbers. EXAMPLES:: sage: log(e^2) 2 sage: log(1024, 2); RDF(log(1024, 2)) 10 10.0 sage: log(10, 4); RDF(log(10, 4)) log(10)/log(4) 1.66096404744 :: sage: log(10, 2) log(10)/log(2) sage: n(log(10, 2)) 3.32192809488736 sage: log(10, e) log(10) sage: n(log(10, e)) 2.30258509299405 The log function works for negative numbers, complex numbers, and symbolic numbers too, picking the branch with angle between `-pi` and `pi`:: sage: log(-1+0*I) I*pi sage: log(CC(-1)) 3.14159265358979*I sage: log(-1.0) 3.14159265358979*I For input zero, the following behavior occurs:: sage: log(0) -Infinity sage: log(CC(0)) -infinity sage: log(0.0) -infinity The log function also works in finite fields as long as the base is generator of the multiplicative group:: sage: F = GF(13); g = F.multiplicative_generator(); g 2 sage: a = F(8) sage: log(a,g); g^log(a,g) 3 8 sage: log(a,3) Traceback (most recent call last): ... ValueError: base (=3) for discrete log must generate multiplicative group The log function also works for p-adics (see documentation for p-adics for more information):: sage: R = Zp(5); R 5-adic Ring with capped relative precision 20 sage: a = R(16); a 1 + 3*5 + O(5^20) sage: log(a) 3*5 + 3*5^2 + 3*5^4 + 3*5^5 + 3*5^6 + 4*5^7 + 2*5^8 + 5^9 + 5^11 + 2*5^12 + 5^13 + 3*5^15 + 2*5^16 + 4*5^17 + 3*5^18 + 3*5^19 + O(5^20) """ if base is None: try: return x.log() except AttributeError: return ln(x) else: try: return x.log(base) except (AttributeError, TypeError): return log(x) / log(base)
def log(x, base=None): """ Return the logarithm of x to the given base. Calls the ``log`` method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a ``log`` method. In other words, log works on more than just real numbers. EXAMPLES:: sage: log(e^2) 2 sage: log(1024, 2); RDF(log(1024, 2)) 10 10.0 sage: log(10, 4); RDF(log(10, 4)) log(10)/log(4) 1.66096404744 :: sage: log(10, 2) log(10)/log(2) sage: n(log(10, 2)) 3.32192809488736 sage: log(10, e) log(10) sage: n(log(10, e)) 2.30258509299405 The log function works for negative numbers, complex numbers, and symbolic numbers too, picking the branch with angle between `-pi` and `pi`:: sage: log(-1+0*I) I*pi sage: log(CC(-1)) 3.14159265358979*I sage: log(-1.0) 3.14159265358979*I For input zero, the following behavior occurs:: sage: log(0) -Infinity sage: log(CC(0)) -infinity sage: log(0.0) -infinity The log function also works in finite fields as long as the argument lies in the multiplicative group generated by the base:: sage: F = GF(13); g = F.multiplicative_generator(); g 2 sage: a = F(8) sage: log(a,g); g^log(a,g) 3 8 sage: log(a,3) Traceback (most recent call last): ... ValueError: base (=3) for discrete log must generate multiplicative group The log function also works for p-adics (see documentation for p-adics for more information):: sage: R = Zp(5); R 5-adic Ring with capped relative precision 20 sage: a = R(16); a 1 + 3*5 + O(5^20) sage: log(a) 3*5 + 3*5^2 + 3*5^4 + 3*5^5 + 3*5^6 + 4*5^7 + 2*5^8 + 5^9 + 5^11 + 2*5^12 + 5^13 + 3*5^15 + 2*5^16 + 4*5^17 + 3*5^18 + 3*5^19 + O(5^20) """ if base is None: try: return x.log() except AttributeError: return ln(x) else: try: return x.log(base) except (AttributeError, TypeError): return log(x) / log(base)
473,121
def log(x, base=None): """ Return the logarithm of x to the given base. Calls the ``log`` method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a ``log`` method. In other words, log works on more than just real numbers. EXAMPLES:: sage: log(e^2) 2 sage: log(1024, 2); RDF(log(1024, 2)) 10 10.0 sage: log(10, 4); RDF(log(10, 4)) log(10)/log(4) 1.66096404744 :: sage: log(10, 2) log(10)/log(2) sage: n(log(10, 2)) 3.32192809488736 sage: log(10, e) log(10) sage: n(log(10, e)) 2.30258509299405 The log function works for negative numbers, complex numbers, and symbolic numbers too, picking the branch with angle between `-pi` and `pi`:: sage: log(-1+0*I) I*pi sage: log(CC(-1)) 3.14159265358979*I sage: log(-1.0) 3.14159265358979*I For input zero, the following behavior occurs:: sage: log(0) -Infinity sage: log(CC(0)) -infinity sage: log(0.0) -infinity The log function also works in finite fields as long as the base is generator of the multiplicative group:: sage: F = GF(13); g = F.multiplicative_generator(); g 2 sage: a = F(8) sage: log(a,g); g^log(a,g) 3 8 sage: log(a,3) Traceback (most recent call last): ... ValueError: base (=3) for discrete log must generate multiplicative group The log function also works for p-adics (see documentation for p-adics for more information):: sage: R = Zp(5); R 5-adic Ring with capped relative precision 20 sage: a = R(16); a 1 + 3*5 + O(5^20) sage: log(a) 3*5 + 3*5^2 + 3*5^4 + 3*5^5 + 3*5^6 + 4*5^7 + 2*5^8 + 5^9 + 5^11 + 2*5^12 + 5^13 + 3*5^15 + 2*5^16 + 4*5^17 + 3*5^18 + 3*5^19 + O(5^20) """ if base is None: try: return x.log() except AttributeError: return ln(x) else: try: return x.log(base) except (AttributeError, TypeError): return log(x) / log(base)
def log(x, base=None): """ Return the logarithm of x to the given base. Calls the ``log`` method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a ``log`` method. In other words, log works on more than just real numbers. EXAMPLES:: sage: log(e^2) 2 sage: log(1024, 2); RDF(log(1024, 2)) 10 10.0 sage: log(10, 4); RDF(log(10, 4)) log(10)/log(4) 1.66096404744 :: sage: log(10, 2) log(10)/log(2) sage: n(log(10, 2)) 3.32192809488736 sage: log(10, e) log(10) sage: n(log(10, e)) 2.30258509299405 The log function works for negative numbers, complex numbers, and symbolic numbers too, picking the branch with angle between `-pi` and `pi`:: sage: log(-1+0*I) I*pi sage: log(CC(-1)) 3.14159265358979*I sage: log(-1.0) 3.14159265358979*I For input zero, the following behavior occurs:: sage: log(0) -Infinity sage: log(CC(0)) -infinity sage: log(0.0) -infinity The log function also works in finite fields as long as the base is generator of the multiplicative group:: sage: F = GF(13); g = F.multiplicative_generator(); g 2 sage: a = F(8) sage: log(a,g); g^log(a,g) 3 8 sage: log(a,3) Traceback (most recent call last): ... ValueError: No discrete log of 8 found to base 3 sage: log(F(9), 3) 2 The log function also works for p-adics (see documentation for p-adics for more information):: sage: R = Zp(5); R 5-adic Ring with capped relative precision 20 sage: a = R(16); a 1 + 3*5 + O(5^20) sage: log(a) 3*5 + 3*5^2 + 3*5^4 + 3*5^5 + 3*5^6 + 4*5^7 + 2*5^8 + 5^9 + 5^11 + 2*5^12 + 5^13 + 3*5^15 + 2*5^16 + 4*5^17 + 3*5^18 + 3*5^19 + O(5^20) """ if base is None: try: return x.log() except AttributeError: return ln(x) else: try: return x.log(base) except (AttributeError, TypeError): return log(x) / log(base)
473,122
def Tableau(t): """ Returns the tableau object corresponding to t. Note that Sage uses the English convention for partitions and tableaux. EXAMPLES:: sage: t = Tableau([[1,2,3],[4,5]]); t [[1, 2, 3], [4, 5]] sage: t.shape() [3, 2] sage: t.is_standard() True """ if isinstance(t, Tableau_class): return t elif t in Tableaux_all(): return Tableau_class(t) raise ValueError, "invalid tableau"
def Tableau(t): """ Returns the tableau object corresponding to t. A tableau in sage is a finite list of lists, whose lengths are weakly decreasing, or an empty list, representing the empty tableau. The entries of a tableau can be any sage object. Note that Sage uses the English convention for partitions and tableaux. EXAMPLES:: sage: t = Tableau([[1,2,3],[4,5]]); t [[1, 2, 3], [4, 5]] sage: t.shape() [3, 2] sage: t.is_standard() True """ if isinstance(t, Tableau_class): return t elif t in Tableaux_all(): return Tableau_class(t) raise ValueError, "invalid tableau"
473,123
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 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
473,124
def up(self): """ An iterator for all the tableaux that can be obtained from self by adding a cell. EXAMPLES::
def up(self): """ An iterator for all the tableaux that can be obtained from self by adding a cell. EXAMPLES::
473,125
def Tableaux(n=None): """ Returns the combinatorial class of tableaux. If n is specified, then it returns the combinatorial class of all tableaux of size n. EXAMPLES:: sage: T = Tableaux(); T Tableaux sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T True sage: [1,2,3] in T False :: sage: T = Tableaux(4); T Tableaux of size 4 sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T False sage: [1,2,3] in T False """ if n == None: return Tableaux_all() else: return Tableaux_n(n)
def Tableaux(n=None): """ Returns the combinatorial class of tableaux. If n is specified, then it returns the combinatorial class of all tableaux of size n. A tableau in sage is a finite list of lists, whose lengths are weakly decreasing. The entries can be anything at all. EXAMPLES:: sage: T = Tableaux(); T Tableaux sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T True sage: [1,2,3] in T False :: sage: T = Tableaux(4); T Tableaux of size 4 sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T False sage: [1,2,3] in T False """ if n == None: return Tableaux_all() else: return Tableaux_n(n)
473,126
def Tableaux(n=None): """ Returns the combinatorial class of tableaux. If n is specified, then it returns the combinatorial class of all tableaux of size n. EXAMPLES:: sage: T = Tableaux(); T Tableaux sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T True sage: [1,2,3] in T False :: sage: T = Tableaux(4); T Tableaux of size 4 sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T False sage: [1,2,3] in T False """ if n == None: return Tableaux_all() else: return Tableaux_n(n)
def Tableaux(n=None): """ Returns the combinatorial class of tableaux. If n is specified, then it returns the combinatorial class of all tableaux of size n. EXAMPLES:: sage: T = Tableaux(); T Tableaux sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T True :: sage: T = Tableaux(4); T Tableaux of size 4 sage: [[1,2],[3,4]] in T True sage: [[1,2],[3]] in T False """ if n == None: return Tableaux_all() else: return Tableaux_n(n)
473,127
def __repr__(self): """ TESTS::
def _repr_(self): """ TESTS::
473,128
def __repr__(self): """ TESTS::
def _repr_(self): """ TESTS::
473,129
def __repr__(self): """ TESTS::
def _repr_(self): """ TESTS::
473,130
def __repr__(self): """ TESTS::
def _repr_(self): """ TESTS::
473,131
def __repr__(self): """ TESTS::
def _repr_(self): """ TESTS::
473,132
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None, max_entry=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,133
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p. If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,134
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,135
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] and maximum entry 3 sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,136
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLESsage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,137
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 and maximum entry 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,138
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ is_inf = max_entry is PlusInfinity() if max_entry is not None and not is_inf: if not isinstance(max_entry, (int, Integer)): raise ValueError, "max_entry must be an integer" elif max_entry < 0: raise ValueError, "max_entry must be non-negative" if p is None: if mu is None: return SemistandardTableaux_all(max_entry) else: return SemistandardTableaux_nmu(sum(mu), mu) elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,139
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu is None: if is_inf: if sum(p) != 0: return SemistandardTableaux_p_inf(p) else: return SemistandardTableaux_p(p) else: return SemistandardTableaux_p(p, max_entry) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,140
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if p >= 0: if mu is None: if is_inf: if p != 0: return SemistandardTableaux_n_inf(p) else: return SemistandardTableaux_n(p) else: return SemistandardTableaux_n(p, max_entry) else: if p != sum(mu): raise ValueError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,141
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
def SemistandardTableaux(p=None, mu=None): """ Returns the combinatorial class of semistandard tableaux. If p is specified and is a partition, then it returns the class of semistandard tableaux of shape p (and max entry sum(p)) If p is specified and is an integer, it returns the class of semistandard tableaux of size p. If mu is also specified, then it returns the class of semistandard tableaux with evaluation/content mu. EXAMPLES:: sage: SST = SemistandardTableaux([2,1]); SST Semistandard tableaux of shape [2, 1] sage: SST.list() [[[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]]] :: sage: SST = SemistandardTableaux(3); SST Semistandard tableaux of size 3 sage: SST.list() [[[1, 1, 1]], [[1, 1, 2]], [[1, 1, 3]], [[1, 2, 2]], [[1, 2, 3]], [[1, 3, 3]], [[2, 2, 2]], [[2, 2, 3]], [[2, 3, 3]], [[3, 3, 3]], [[1, 1], [2]], [[1, 1], [3]], [[1, 2], [2]], [[1, 2], [3]], [[1, 3], [2]], [[1, 3], [3]], [[2, 2], [3]], [[2, 3], [3]], [[1], [2], [3]]] """ if p == None: return SemistandardTableaux_all() elif p in partition.Partitions(): if mu == None: return SemistandardTableaux_p(p) else: if sum(p) != sum(mu): #Error size mismatch raise TypeError, "p and mu must be of the same size" else: return SemistandardTableaux_pmu(p, mu) elif isinstance(p, (int, Integer)): if mu == None: return SemistandardTableaux_n(p) else: if p != sum(mu): #Error size mismatch raise TypeError, "mu must be of size p (= %s)"%p else: return SemistandardTableaux_nmu(p, mu) else: raise ValueError
473,142
def __init__(self): """ TESTS::
def __init__(self, max_entry=None): """ TESTS::
473,143
def __init__(self): """ TESTS::
def __init__(self): 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" TESTS::
473,144
def __contains__(self, x): """ TESTS::
def __contains__(self, x): """ TESTS::
473,145
def __contains__(self, x): """ TESTS::
def __contains__(self, x): """ TESTS::
473,146
def __contains__(self, x): """ TESTS::
def __contains__(self, x): """ TESTS::
473,147
def __contains__(self, x): """ TESTS::
def __contains__(self, x): """ TESTS::
473,148
def __init__(self, n): """ TESTS::
def __init__(self, n, max_entry=None): """ TESTS::
473,149
def __repr__(self): """ TESTS::
self.max_entry = None if max_entry is None: self.max_entry = n else: self.max_entry = max_entry def _repr_(self): """ TESTS::
473,150
def __repr__(self): """ TESTS::
def __repr__(self): """ TESTS::
473,151
def __contains__(self, x): """ EXAMPLES::
def __contains__(self, x): """ EXAMPLES::
473,152
def cardinality(self): """ EXAMPLES::
def cardinality(self): """ EXAMPLES::
473,153
def __iter__(self): """ EXAMPLES::
def __iter__(self): """ EXAMPLES::
473,154
def __repr__(self): """ TESTS::
def _repr_(self): """ TESTS::
473,155
def __contains__(self, x): """ EXAMPLES::
def __contains__(self, x): """ EXAMPLES::
473,156
def __init__(self, p): """ TESTS::
def __init__(self, p, max_entry=None): """ TESTS::
473,157
def __contains__(self, x): """ EXAMPLES::
def __contains__(self, x): """ EXAMPLES::
473,158
def __repr__(self): """ TESTS::
def __repr__(self): """ TESTS::
473,159
def cardinality(self): """ EXAMPLES::
def cardinality(self): """ EXAMPLES::
473,160
def __iter__(self): """ An iterator for the semistandard partitions of shape p.
def __iter__(self): """ An iterator for the semistandard partitions of shape p.
473,161
def __init__(self, n, mu): """ TESTS::
def __init__(self, n, mu): """ TESTS::
473,162
def __contains__(self, x): """ TESTS::
def __contains__(self, x): """ TESTS::
473,163
def _limit_latex_(*args): 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(x) = function('f',x) sage: _limit_latex_(f(x), x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ # Read f,x,a from arguments f = args[0] x = args[1] a = args[2] 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(x) = function('f',x) sage: _limit_latex_(f(x), x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ # Read f,x,a from arguments f = args[0] x = args[1] a = args[2] return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
473,164
def _limit_latex_(*args): 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(x) = function('f',x) sage: _limit_latex_(f(x), x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ # Read f,x,a from arguments f = args[0] x = args[1] a = args[2] return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
def _limit_latex_(*args): 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)' AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ # Read f,x,a from arguments f = args[0] x = args[1] a = args[2] return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
473,165
def _limit_latex_(*args): 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(x) = function('f',x) sage: _limit_latex_(f(x), x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ # Read f,x,a from arguments f = args[0] x = args[1] a = args[2] return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
def _limit_latex_(*args): 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(x) = function('f',x) sage: _limit_latex_(f(x), x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ # Read f,x,a from argumentsreturn "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
473,166
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
def _integrate_latex_(self, f, x, *args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
473,167
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f = function('f',x) sage: _integrate_latex_(0,f,x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
473,168
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(0,f,x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
473,169
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
473,170
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 4: a = args[2] b = args[3] return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
def _integrate_latex_(*args): r""" Return LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _integrate_latex_ sage: var('x,a,b') (x, a, b) sage: f(x) = function('f',x) sage: _integrate_latex_(f(x),x) '\\int f\\left(x\\right)\\,{d x}' sage: _integrate_latex_(f(x),x,a,b) '\\int_{a}^{b} f\\left(x\\right)\\,{d x}' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ f = args[0] x = args[1] # Check whether its a definite integral if len(args) == 2: a, b = args return "\\int_{%s}^{%s} %s\\,{d %s}"%(latex(a), latex(b), latex(f), latex(x)) # Typeset as indefinite integral return "\\int %s\\,{d %s}"%(latex(f), latex(x))
473,171
def _laplace_latex_(*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(t) = function('f',t) sage: _laplace_latex_(f(t),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(t) = function('f',t) sage: _laplace_latex_(f(t),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]))
473,172
def _laplace_latex_(*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(t) = function('f',t) sage: _laplace_latex_(f(t),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_(*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)' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ return "\\mathcal{L}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
473,173
def _inverse_laplace_latex_(*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(s) = function('F',s) sage: _inverse_laplace_latex_(F(s),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(s) = function('F',s) sage: _inverse_laplace_latex_(F(s),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]))
473,174
def _inverse_laplace_latex_(*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(s) = function('F',s) sage: _inverse_laplace_latex_(F(s),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_(*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)' AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ return "\\mathcal{L}^{-1}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
473,175
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).
def is_planar(self, on_embedding=None, kuratowski=False, set_embedding=False, set_pos=False): 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) 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).
473,176
def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all vectors of length i. Reference: This is a slightly modified version of Cohn's Algorithm 2.7.5 in "A Course in Computational Number Theory", with the increment step moved around and slightly re-indexed to allow clean looping. Note: We could speed this up for very skew matrices by using LLL first, and then changing coordinates back, but for our purposes the simpler method is efficient enough. =) EXAMPLES: sage: Q = DiagonalQuadraticForm(ZZ, [1,1]) sage: Q.vectors_by_length(5) [[[0, 0]], [[0, -1], [-1, 0]], [[-1, -1], [1, -1]], [], [[0, -2], [-2, 0]], [[-1, -2], [1, -2], [-2, -1], [2, -1]]] sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) sage: Q1.vectors_by_length(5) [[[0, 0, 0, 0]], [[-1, 0, 0, 0]], [], [[0, -1, 0, 0]], [[-1, -1, 0, 0], [1, -1, 0, 0], [-2, 0, 0, 0]], [[0, 0, -1, 0]]] sage: Q = QuadraticForm(ZZ, 4, [1,1,1,1, 1,0,0, 1,0, 1]) sage: map(len, Q.vectors_by_length(2)) [1, 12, 12] """ # pari uses eps = 1e-6 ; nothing bad should happen if eps is too big # but if eps is too small, roundoff errors may knock off some # vectors of norm = bound (see #7100) eps = RDF(1e-6) bound = ZZ(floor(bound)) Theta_Precision = bound + eps n = self.dim() ## Make the vector of vectors which have a given value ## (So theta_vec[i] will have all vectors v with Q(v) = i.) theta_vec = [[] for i in range(bound + 1)] ## Initialize Q with zeros and Copy the Cholesky array into Q Q = self.cholesky_decomposition() ## 1. Initialize T = n * [RDF(0)] ## Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] i = n-1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) L = n * [0] x = n * [0] Z = RDF(0) ## 2. Compute bounds Z = (T[i] / Q[i][i]).sqrt(extend=False) L[i] = ( Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() done_flag = False Q_val_double = RDF(0) Q_val = 0 ## WARNING: Still need a good way of checking overflow for this value... ## Big loop which runs through all vectors while not done_flag: ## 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): #print " i = ", i #print " T[i] = ", T[i] #print " Q[i][i] = ", Q[i][i] #print " x[i] = ", x[i] #print " U[i] = ", U[i] #print " x[i] + U[i] = ", (x[i] + U[i]) #print " T[i-1] = ", T[i-1] T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) #print " T[i-1] = ", T[i-1] #print " x = ", x #print i = i - 1 U[i] = 0 for j in range(i+1, n): U[i] = U[i] + Q[i][j] * x[j] ## Now go back and compute the bounds... ## 2. Compute bounds Z = (T[i] / Q[i][i]).sqrt(extend=False) L[i] = ( Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() ## 4. Solution found (This happens when i = 0) #print "-- Solution found! --" #print " x = ", x #print " Q_val = Q(x) = ", Q_val Q_val_double = Theta_Precision - T[0] + Q[0][0] * (x[0] + U[0]) * (x[0] + U[0]) Q_val = Q_val_double.round() ## SANITY CHECK: Roundoff Error is < 0.001 if abs(Q_val_double - Q_val) > 0.001: print " x = ", x print " Float = ", Q_val_double, " Long = ", Q_val raise RuntimeError, "The roundoff error is bigger than 0.001, so we should use more precision somewhere..." #print " Float = ", Q_val_double, " Long = ", Q_val, " XX " #print " The float value is ", Q_val_double #print " The associated long value is ", Q_val if (Q_val <= bound): #print " Have vector ", x, " with value ", Q_val theta_vec[Q_val].append(deepcopy(x)) ## 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True while (j < n): if (x[j] != 0): done_flag = False j += 1 ## 3a. Increment (and carry if we go out of bounds) x[i] += 1 while (x[i] > L[i]) and (i < n-1): i += 1 x[i] += 1 #print " Leaving ThetaVectors()" return theta_vec
def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all vectors of length i. Reference: This is a slightly modified version of Cohn's Algorithm 2.7.5 in "A Course in Computational Number Theory", with the increment step moved around and slightly re-indexed to allow clean looping. Note: We could speed this up for very skew matrices by using LLL first, and then changing coordinates back, but for our purposes the simpler method is efficient enough. =) EXAMPLES: sage: Q = DiagonalQuadraticForm(ZZ, [1,1]) sage: Q.vectors_by_length(5) [[[0, 0]], [[0, -1], [-1, 0]], [[-1, -1], [1, -1]], [], [[0, -2], [-2, 0]], [[-1, -2], [1, -2], [-2, -1], [2, -1]]] sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) sage: Q1.vectors_by_length(5) [[[0, 0, 0, 0]], [[-1, 0, 0, 0]], [], [[0, -1, 0, 0]], [[-1, -1, 0, 0], [1, -1, 0, 0], [-2, 0, 0, 0]], [[0, 0, -1, 0]]] sage: Q = QuadraticForm(ZZ, 4, [1,1,1,1, 1,0,0, 1,0, 1]) sage: map(len, Q.vectors_by_length(2)) [1, 12, 12] """ # pari uses eps = 1e-6 ; nothing bad should happen if eps is too big # but if eps is too small, roundoff errors may knock off some # vectors of norm = bound (see #7100) eps = RDF(1e-6) bound = ZZ(floor(max(bound, 0))) Theta_Precision = bound + eps n = self.dim() ## Make the vector of vectors which have a given value ## (So theta_vec[i] will have all vectors v with Q(v) = i.) theta_vec = [[] for i in range(bound + 1)] ## Initialize Q with zeros and Copy the Cholesky array into Q Q = self.cholesky_decomposition() ## 1. Initialize T = n * [RDF(0)] ## Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] i = n-1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) L = n * [0] x = n * [0] Z = RDF(0) ## 2. Compute bounds Z = (T[i] / Q[i][i]).sqrt(extend=False) L[i] = ( Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() done_flag = False Q_val_double = RDF(0) Q_val = 0 ## WARNING: Still need a good way of checking overflow for this value... ## Big loop which runs through all vectors while not done_flag: ## 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): #print " i = ", i #print " T[i] = ", T[i] #print " Q[i][i] = ", Q[i][i] #print " x[i] = ", x[i] #print " U[i] = ", U[i] #print " x[i] + U[i] = ", (x[i] + U[i]) #print " T[i-1] = ", T[i-1] T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) #print " T[i-1] = ", T[i-1] #print " x = ", x #print i = i - 1 U[i] = 0 for j in range(i+1, n): U[i] = U[i] + Q[i][j] * x[j] ## Now go back and compute the bounds... ## 2. Compute bounds Z = (T[i] / Q[i][i]).sqrt(extend=False) L[i] = ( Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() ## 4. Solution found (This happens when i = 0) #print "-- Solution found! --" #print " x = ", x #print " Q_val = Q(x) = ", Q_val Q_val_double = Theta_Precision - T[0] + Q[0][0] * (x[0] + U[0]) * (x[0] + U[0]) Q_val = Q_val_double.round() ## SANITY CHECK: Roundoff Error is < 0.001 if abs(Q_val_double - Q_val) > 0.001: print " x = ", x print " Float = ", Q_val_double, " Long = ", Q_val raise RuntimeError, "The roundoff error is bigger than 0.001, so we should use more precision somewhere..." #print " Float = ", Q_val_double, " Long = ", Q_val, " XX " #print " The float value is ", Q_val_double #print " The associated long value is ", Q_val if (Q_val <= bound): #print " Have vector ", x, " with value ", Q_val theta_vec[Q_val].append(deepcopy(x)) ## 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True while (j < n): if (x[j] != 0): done_flag = False j += 1 ## 3a. Increment (and carry if we go out of bounds) x[i] += 1 while (x[i] > L[i]) and (i < n-1): i += 1 x[i] += 1 #print " Leaving ThetaVectors()" return theta_vec
473,177
def dimension(self): r""" Returns the dimension of this code.
def dimension(self): r""" Returns the dimension of this code.
473,178
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.
def sd_duursma_data(C, i): r""" Returns the Duursma 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.
473,179
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.
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.
473,180
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.
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.
473,181
def sd_duursma_q(C,i,d0): r""" INPUT:
def sd_duursma_q(C,i,d0): r""" INPUT:
473,182
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
473,183
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
473,184
def _compute_dim(self, compute_vertices): r""" Compute the dimension of this polytope and its vertices, if necessary.
def _compute_dim(self, compute_vertices): r""" Compute the dimension of this polytope and its vertices, if necessary.
473,185
def _compute_dim(self, compute_vertices): r""" Compute the dimension of this polytope and its vertices, if necessary.
def _compute_dim(self, compute_vertices): r""" Compute the dimension of this polytope and its vertices, if necessary.
473,186
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
473,187
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
473,188
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
473,189
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
def facet_constant(self, i): r""" Return the constant in the ``i``-th facet inequality of this polytope.
473,190
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
473,191
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
473,192
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
473,193
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
def facet_normal(self, i): r""" Return the inner normal to the ``i``-th facet of this polytope.
473,194
def __init__(self, deprecated=None, **renames): """ A decorator which renames keyword arguments and optionally deprecates the new keyword.
def __init__(self, deprecated=None, **renames): """ A decorator which renames keyword arguments and optionally deprecates the new keyword.
473,195
def __init__(self, deprecated=None, **renames): """ A decorator which renames keyword arguments and optionally deprecates the new keyword.
def __init__(self, deprecated=None, **renames): """ A decorator which renames keyword arguments and optionally deprecates the new keyword.
473,196
def __init__(self, deprecated=None, **renames): """ A decorator which renames keyword arguments and optionally deprecates the new keyword.
def__init__(self,deprecated=None,**renames):"""Adecoratorwhichrenameskeywordargumentsandoptionallydeprecatesthenewkeyword.
473,197
def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all vectors of length i. Reference: This is a slightly modified version of Cohn's Algorithm 2.7.5 in "A Course in Computational Number Theory", with the increment step moved around and slightly re-indexed to allow clean looping. Note: We could speed this up for very skew matrices by using LLL first, and then changing coordinates back, but for our purposes the simpler method is efficient enough. =) EXAMPLES: sage: Q = DiagonalQuadraticForm(ZZ, [1,1]) sage: Q.vectors_by_length(5) [[[0, 0]], [[0, -1], [-1, 0]], [[-1, -1], [1, -1]], [], [[0, -2], [-2, 0]], [[-1, -2], [1, -2], [-2, -1], [2, -1]]] sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) sage: Q1.vectors_by_length(5) [[[0, 0, 0, 0]], [[-1, 0, 0, 0]], [], [[0, -1, 0, 0]], [[-1, -1, 0, 0], [1, -1, 0, 0], [-2, 0, 0, 0]], [[0, 0, -1, 0]]] """ Theta_Precision = bound ## Unsigned long n = self.dim() ## Make the vector of vectors which have a given value ## (So theta_vec[i] will have all vectors v with Q(v) = i.) empty_vec_list = [[] for i in range(Theta_Precision + 1)] theta_vec = [[] for i in range(Theta_Precision + 1)] ## Initialize Q with zeros and Copy the Cholesky array into Q Q = self.cholesky_decomposition() ## 1. Initialize T = n * [RDF(0)] ## Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] i = n-1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) L = n * [0] x = n * [0] Z = RDF(0) ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) done_flag = False Q_val_double = RDF(0) Q_val = 0 ## WARNING: Still need a good way of checking overflow for this value... ## Big loop which runs through all vectors while not done_flag: ## 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): #print " i = ", i #print " T[i] = ", T[i] #print " Q[i][i] = ", Q[i][i] #print " x[i] = ", x[i] #print " U[i] = ", U[i] #print " x[i] + U[i] = ", (x[i] + U[i]) #print " T[i-1] = ", T[i-1] T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) #print " T[i-1] = ", T[i-1] #print " x = ", x #print i = i - 1 U[i] = 0 for j in range(i+1, n): U[i] = U[i] + Q[i][j] * x[j] ## Now go back and compute the bounds... ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) ## 4. Solution found (This happens when i = 0) #print "-- Solution found! --" #print " x = ", x #print " Q_val = Q(x) = ", Q_val Q_val_double = Theta_Precision - T[0] + Q[0][0] * (x[0] + U[0]) * (x[0] + U[0]) Q_val = ZZ(floor(round(Q_val_double))) ## SANITY CHECK: Roundoff Error is < 0.001 if abs(Q_val_double - Q_val) > 0.001: print " x = ", x print " Float = ", Q_val_double, " Long = ", Q_val raise RuntimeError, "The roundoff error is bigger than 0.001, so we should use more precision somewhere..." #print " Float = ", Q_val_double, " Long = ", Q_val, " XX " #print " The float value is ", Q_val_double #print " The associated long value is ", Q_val if (Q_val <= Theta_Precision): #print " Have vector ", x, " with value ", Q_val theta_vec[Q_val].append(deepcopy(x)) ## 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True while (j < n): if (x[j] != 0): done_flag = False j += 1 ## 3a. Increment (and carry if we go out of bounds) x[i] += 1 while (x[i] > L[i]) and (i < n-1): i += 1 x[i] += 1 #print " Leaving ThetaVectors()" return theta_vec
def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all vectors of length i. Reference: This is a slightly modified version of Cohn's Algorithm 2.7.5 in "A Course in Computational Number Theory", with the increment step moved around and slightly re-indexed to allow clean looping. Note: We could speed this up for very skew matrices by using LLL first, and then changing coordinates back, but for our purposes the simpler method is efficient enough. =) EXAMPLES: sage: Q = DiagonalQuadraticForm(ZZ, [1,1]) sage: Q.vectors_by_length(5) [[[0, 0]], [[0, -1], [-1, 0]], [[-1, -1], [1, -1]], [], [[0, -2], [-2, 0]], [[-1, -2], [1, -2], [-2, -1], [2, -1]]] sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) sage: Q1.vectors_by_length(5) [[[0, 0, 0, 0]], [[-1, 0, 0, 0]], [], [[0, -1, 0, 0]], [[-1, -1, 0, 0], [1, -1, 0, 0], [-2, 0, 0, 0]], [[0, 0, -1, 0]]] sage: Q = QuadraticForm(ZZ, 4, [1,1,1,1, 1,0,0, 1,0, 1]) sage: map(len, Q.vectors_by_length(2)) [1, 12, 12] """ eps = RDF(1e-6) bound = ZZ(floor(bound)) Theta_Precision = bound + eps ## Unsigned long n = self.dim() ## Make the vector of vectors which have a given value ## (So theta_vec[i] will have all vectors v with Q(v) = i.) empty_vec_list = [[] for i in range(Theta_Precision + 1)] theta_vec = [[] for i in range(Theta_Precision + 1)] ## Initialize Q with zeros and Copy the Cholesky array into Q Q = self.cholesky_decomposition() ## 1. Initialize T = n * [RDF(0)] ## Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] i = n-1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) L = n * [0] x = n * [0] Z = RDF(0) ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) done_flag = False Q_val_double = RDF(0) Q_val = 0 ## WARNING: Still need a good way of checking overflow for this value... ## Big loop which runs through all vectors while not done_flag: ## 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): #print " i = ", i #print " T[i] = ", T[i] #print " Q[i][i] = ", Q[i][i] #print " x[i] = ", x[i] #print " U[i] = ", U[i] #print " x[i] + U[i] = ", (x[i] + U[i]) #print " T[i-1] = ", T[i-1] T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) #print " T[i-1] = ", T[i-1] #print " x = ", x #print i = i - 1 U[i] = 0 for j in range(i+1, n): U[i] = U[i] + Q[i][j] * x[j] ## Now go back and compute the bounds... ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) ## 4. Solution found (This happens when i = 0) #print "-- Solution found! --" #print " x = ", x #print " Q_val = Q(x) = ", Q_val Q_val_double = Theta_Precision - T[0] + Q[0][0] * (x[0] + U[0]) * (x[0] + U[0]) Q_val = ZZ(floor(round(Q_val_double))) ## SANITY CHECK: Roundoff Error is < 0.001 if abs(Q_val_double - Q_val) > 0.001: print " x = ", x print " Float = ", Q_val_double, " Long = ", Q_val raise RuntimeError, "The roundoff error is bigger than 0.001, so we should use more precision somewhere..." #print " Float = ", Q_val_double, " Long = ", Q_val, " XX " #print " The float value is ", Q_val_double #print " The associated long value is ", Q_val if (Q_val <= Theta_Precision): #print " Have vector ", x, " with value ", Q_val theta_vec[Q_val].append(deepcopy(x)) ## 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True while (j < n): if (x[j] != 0): done_flag = False j += 1 ## 3a. Increment (and carry if we go out of bounds) x[i] += 1 while (x[i] > L[i]) and (i < n-1): i += 1 x[i] += 1 #print " Leaving ThetaVectors()" return theta_vec
473,198
def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all vectors of length i. Reference: This is a slightly modified version of Cohn's Algorithm 2.7.5 in "A Course in Computational Number Theory", with the increment step moved around and slightly re-indexed to allow clean looping. Note: We could speed this up for very skew matrices by using LLL first, and then changing coordinates back, but for our purposes the simpler method is efficient enough. =) EXAMPLES: sage: Q = DiagonalQuadraticForm(ZZ, [1,1]) sage: Q.vectors_by_length(5) [[[0, 0]], [[0, -1], [-1, 0]], [[-1, -1], [1, -1]], [], [[0, -2], [-2, 0]], [[-1, -2], [1, -2], [-2, -1], [2, -1]]] sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) sage: Q1.vectors_by_length(5) [[[0, 0, 0, 0]], [[-1, 0, 0, 0]], [], [[0, -1, 0, 0]], [[-1, -1, 0, 0], [1, -1, 0, 0], [-2, 0, 0, 0]], [[0, 0, -1, 0]]] """ Theta_Precision = bound ## Unsigned long n = self.dim() ## Make the vector of vectors which have a given value ## (So theta_vec[i] will have all vectors v with Q(v) = i.) empty_vec_list = [[] for i in range(Theta_Precision + 1)] theta_vec = [[] for i in range(Theta_Precision + 1)] ## Initialize Q with zeros and Copy the Cholesky array into Q Q = self.cholesky_decomposition() ## 1. Initialize T = n * [RDF(0)] ## Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] i = n-1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) L = n * [0] x = n * [0] Z = RDF(0) ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) done_flag = False Q_val_double = RDF(0) Q_val = 0 ## WARNING: Still need a good way of checking overflow for this value... ## Big loop which runs through all vectors while not done_flag: ## 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): #print " i = ", i #print " T[i] = ", T[i] #print " Q[i][i] = ", Q[i][i] #print " x[i] = ", x[i] #print " U[i] = ", U[i] #print " x[i] + U[i] = ", (x[i] + U[i]) #print " T[i-1] = ", T[i-1] T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) #print " T[i-1] = ", T[i-1] #print " x = ", x #print i = i - 1 U[i] = 0 for j in range(i+1, n): U[i] = U[i] + Q[i][j] * x[j] ## Now go back and compute the bounds... ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) ## 4. Solution found (This happens when i = 0) #print "-- Solution found! --" #print " x = ", x #print " Q_val = Q(x) = ", Q_val Q_val_double = Theta_Precision - T[0] + Q[0][0] * (x[0] + U[0]) * (x[0] + U[0]) Q_val = ZZ(floor(round(Q_val_double))) ## SANITY CHECK: Roundoff Error is < 0.001 if abs(Q_val_double - Q_val) > 0.001: print " x = ", x print " Float = ", Q_val_double, " Long = ", Q_val raise RuntimeError, "The roundoff error is bigger than 0.001, so we should use more precision somewhere..." #print " Float = ", Q_val_double, " Long = ", Q_val, " XX " #print " The float value is ", Q_val_double #print " The associated long value is ", Q_val if (Q_val <= Theta_Precision): #print " Have vector ", x, " with value ", Q_val theta_vec[Q_val].append(deepcopy(x)) ## 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True while (j < n): if (x[j] != 0): done_flag = False j += 1 ## 3a. Increment (and carry if we go out of bounds) x[i] += 1 while (x[i] > L[i]) and (i < n-1): i += 1 x[i] += 1 #print " Leaving ThetaVectors()" return theta_vec
def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all vectors of length i. Reference: This is a slightly modified version of Cohn's Algorithm 2.7.5 in "A Course in Computational Number Theory", with the increment step moved around and slightly re-indexed to allow clean looping. Note: We could speed this up for very skew matrices by using LLL first, and then changing coordinates back, but for our purposes the simpler method is efficient enough. =) EXAMPLES: sage: Q = DiagonalQuadraticForm(ZZ, [1,1]) sage: Q.vectors_by_length(5) [[[0, 0]], [[0, -1], [-1, 0]], [[-1, -1], [1, -1]], [], [[0, -2], [-2, 0]], [[-1, -2], [1, -2], [-2, -1], [2, -1]]] sage: Q1 = DiagonalQuadraticForm(ZZ, [1,3,5,7]) sage: Q1.vectors_by_length(5) [[[0, 0, 0, 0]], [[-1, 0, 0, 0]], [], [[0, -1, 0, 0]], [[-1, -1, 0, 0], [1, -1, 0, 0], [-2, 0, 0, 0]], [[0, 0, -1, 0]]] """ Theta_Precision = bound ## Unsigned long n = self.dim() ## Make the vector of vectors which have a given value ## (So theta_vec[i] will have all vectors v with Q(v) = i.) theta_vec = [[] for i in range(bound + 1)] ## Initialize Q with zeros and Copy the Cholesky array into Q Q = self.cholesky_decomposition() ## 1. Initialize T = n * [RDF(0)] ## Note: We index the entries as 0 --> n-1 U = n * [RDF(0)] i = n-1 T[i] = RDF(Theta_Precision) U[i] = RDF(0) L = n * [0] x = n * [0] Z = RDF(0) ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) done_flag = False Q_val_double = RDF(0) Q_val = 0 ## WARNING: Still need a good way of checking overflow for this value... ## Big loop which runs through all vectors while not done_flag: ## 3b. Main loop -- try to generate a complete vector x (when i=0) while (i > 0): #print " i = ", i #print " T[i] = ", T[i] #print " Q[i][i] = ", Q[i][i] #print " x[i] = ", x[i] #print " U[i] = ", U[i] #print " x[i] + U[i] = ", (x[i] + U[i]) #print " T[i-1] = ", T[i-1] T[i-1] = T[i] - Q[i][i] * (x[i] + U[i]) * (x[i] + U[i]) #print " T[i-1] = ", T[i-1] #print " x = ", x #print i = i - 1 U[i] = 0 for j in range(i+1, n): U[i] = U[i] + Q[i][j] * x[j] ## Now go back and compute the bounds... ## 2. Compute bounds Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) ## 4. Solution found (This happens when i = 0) #print "-- Solution found! --" #print " x = ", x #print " Q_val = Q(x) = ", Q_val Q_val_double = Theta_Precision - T[0] + Q[0][0] * (x[0] + U[0]) * (x[0] + U[0]) Q_val = ZZ(floor(round(Q_val_double))) ## SANITY CHECK: Roundoff Error is < 0.001 if abs(Q_val_double - Q_val) > 0.001: print " x = ", x print " Float = ", Q_val_double, " Long = ", Q_val raise RuntimeError, "The roundoff error is bigger than 0.001, so we should use more precision somewhere..." #print " Float = ", Q_val_double, " Long = ", Q_val, " XX " #print " The float value is ", Q_val_double #print " The associated long value is ", Q_val if (Q_val <= Theta_Precision): #print " Have vector ", x, " with value ", Q_val theta_vec[Q_val].append(deepcopy(x)) ## 5. Check if x = 0, for exit condition. =) j = 0 done_flag = True while (j < n): if (x[j] != 0): done_flag = False j += 1 ## 3a. Increment (and carry if we go out of bounds) x[i] += 1 while (x[i] > L[i]) and (i < n-1): i += 1 x[i] += 1 #print " Leaving ThetaVectors()" return theta_vec
473,199