def cardinality(self): """ Returns the number of Lyndon words with the evaluation e. EXAMPLES:: sage: LyndonWords([]).cardinality() 0 sage: LyndonWords([2,2]).cardinality() 1 sage: LyndonWords([2,3,2]).cardinality() 30 Check to make sure that the count matches up with the number of Lyndon words generated. :: sage: comps = [[],[2,2],[3,2,7],[4,2]]+Compositions(4).list() sage: lws = [ LyndonWords(comp) for comp in comps] sage: all( [ lw.cardinality() == len(lw.list()) for lw in lws] ) True """ evaluation = self.e le = __builtin__.list(evaluation) if len(evaluation) == 0: return 0 n = sum(evaluation) return sum([moebius(j)*factorial(n/j) / prod([factorial(ni/j) for ni in evaluation]) for j in divisors(gcd(le))])/n
def cardinality(self): """ Returns the number of Lyndon words with the evaluation e. EXAMPLES:: sage: LyndonWords([]).cardinality() 0 sage: LyndonWords([2,2]).cardinality() 1 sage: LyndonWords([2,3,2]).cardinality() 30 Check to make sure that the count matches up with the number of Lyndon words generated. :: sage: comps = [[],[2,2],[3,2,7],[4,2]]+Compositions(4).list() sage: lws = [ LyndonWords(comp) for comp in comps] sage: all( [ lw.cardinality() == len(lw.list()) for lw in lws] ) True """ evaluation = self.e le = __builtin__.list(evaluation) if len(evaluation) == 0: return 0 n = sum(evaluation) return sum([ moebius(j) * factorial(n / j) / prod([factorial(ni / j) for ni in evaluation]) for j in divisors(gcd(le)) ]) / n
def cardinality(self): """ EXAMPLES:: sage: [ ContreTableaux(n).cardinality() for n in range(0, 11)] [1, 1, 2, 7, 42, 429, 7436, 218348, 10850216, 911835460, 129534272700] """ return prod( [ factorial(3*k+1)/factorial(self.n+k) for k in range(self.n)] )
def by_taylor_expansion(self, fs, k): """ We combine the theta decomposition and the heat operator as in [Sko]. This yields a bijections of Jacobi forms of weight `k` and `M_k \times S_{k+2} \times .. \times S_{k+2m}`. NOTE: To make ``phi_divs`` integral we introduce an extra factor `2^{\mathrm{index}} * \mathrm{factorial}(k + 2 * \mathrm{index} - 1)`. """ ## we introduce an abbreviations p = self.__p PS = self.power_series_ring() if not len(fs) == self.__precision.jacobi_index() + 1: raise ValueError( "fs must be a list of m + 1 elliptic modular forms or their fourier expansion" ) qexp_prec = self._qexp_precision() if qexp_prec is None: # there are no forms below the precision return dict() f_divs = dict() for (i, f) in enumerate(fs): f_divs[(i, 0)] = PS(f(qexp_prec), qexp_prec) for i in xrange(self.__precision.jacobi_index() + 1): for j in xrange(1, self.__precision.jacobi_index() - i + 1): f_divs[(i, j)] = f_divs[(i, j - 1)].derivative().shift(1) phi_divs = list() for i in xrange(self.__precision.jacobi_index() + 1): ## This is the formula in Skoruppas thesis. He uses d/ d tau instead of d / dz which yields ## a factor 4 m phi_divs.append( sum(f_divs[(j, i - j)] * (4 * self.__precision.jacobi_index())**i * binomial(i, j) * (2**self.index() // 2**i) * prod(2 * (i - l) + 1 for l in xrange(1, i)) * (factorial(k + 2 * self.index() - 1) // factorial(i + k + j - 1)) * factorial(2 * self.__precision.jacobi_index() + k - 1) for j in xrange(i + 1))) phi_coeffs = dict() for r in xrange(self.index() + 1): series = sum(map(operator.mul, self._theta_factors()[r], phi_divs)) series = self._eta_factor() * series for n in xrange(qexp_prec): phi_coeffs[(n, r)] = int(series[n].lift()) % p return phi_coeffs
def cardinality(self): r""" Return the cardinality of ``self``. EXAMPLES:: sage: [AlternatingSignMatrices(n).cardinality() for n in range(0, 11)] [1, 1, 2, 7, 42, 429, 7436, 218348, 10850216, 911835460, 129534272700] """ return prod( [ factorial(3*k+1)/factorial(self._n+k) for k in range(self._n)] )
def cardinality(self): r""" Cardinality of ``self``. EXAMPLES:: sage: M = MonotoneTriangles(4) sage: M.cardinality() 42 """ return prod( [ factorial(3*k+1)/factorial(self._n+k) for k in range(self._n)] )
def cardinality(self): r""" Return the cardinality of ``self``. EXAMPLES:: sage: [AlternatingSignMatrices(n).cardinality() for n in range(0, 11)] [1, 1, 2, 7, 42, 429, 7436, 218348, 10850216, 911835460, 129534272700] """ return prod([ factorial(3 * k + 1) / factorial(self._n + k) for k in range(self._n) ])
def cardinality(self): """ TESTS:: sage: [ AlternatingSignMatrices(n).cardinality() for n in range(0, 11)] [1, 1, 2, 7, 42, 429, 7436, 218348, 10850216, 911835460, 129534272700] :: sage: asms = [ AlternatingSignMatrices(n) for n in range(6) ] sage: all( [ asm.cardinality() == len(asm.list()) for asm in asms] ) True """ return prod( [ factorial(3*k+1)/factorial(self.n+k) for k in range(self.n)] )
def by_taylor_expansion(self, fs, k) : """ We combine the theta decomposition and the heat operator as in [Sko]. This yields a bijections of Jacobi forms of weight `k` and `M_k \times S_{k+2} \times .. \times S_{k+2m}`. NOTE: To make ``phi_divs`` integral we introduce an extra factor `2^{\mathrm{index}} * \mathrm{factorial}(k + 2 * \mathrm{index} - 1)`. """ ## we introduce an abbreviations p = self.__p PS = self.power_series_ring() if not len(fs) == self.__precision.jacobi_index() + 1 : raise ValueError("fs must be a list of m + 1 elliptic modular forms or their fourier expansion") qexp_prec = self._qexp_precision() if qexp_prec is None : # there are no forms below the precision return dict() f_divs = dict() for (i, f) in enumerate(fs) : f_divs[(i, 0)] = PS(f(qexp_prec), qexp_prec) for i in xrange(self.__precision.jacobi_index() + 1) : for j in xrange(1, self.__precision.jacobi_index() - i + 1) : f_divs[(i,j)] = f_divs[(i, j - 1)].derivative().shift(1) phi_divs = list() for i in xrange(self.__precision.jacobi_index() + 1) : ## This is the formula in Skoruppas thesis. He uses d/ d tau instead of d / dz which yields ## a factor 4 m phi_divs.append( sum( f_divs[(j, i - j)] * (4 * self.__precision.jacobi_index())**i * binomial(i,j) * ( 2**self.index() // 2**i) * prod(2*(i - l) + 1 for l in xrange(1, i)) * (factorial(k + 2*self.index() - 1) // factorial(i + k + j - 1)) * factorial(2*self.__precision.jacobi_index() + k - 1) for j in xrange(i + 1) ) ) phi_coeffs = dict() for r in xrange(self.index() + 1) : series = sum( map(operator.mul, self._theta_factors()[r], phi_divs) ) series = self._eta_factor() * series for n in xrange(qexp_prec) : phi_coeffs[(n, r)] = int(series[n].lift()) % p return phi_coeffs
def cardinality(self): r""" Cardinality of ``self``. EXAMPLES:: sage: M = MonotoneTriangles(4) sage: M.cardinality() 42 """ return prod([ factorial(3 * k + 1) / factorial(self._n + k) for k in range(self._n) ])
def cpi(self, p): """ Returns the centrally primitive idempotent for the symmetric group of order n for the irreducible corresponding indexed by the partition p. EXAMPLES:: sage: QS3 = SymmetricGroupAlgebra(QQ,3) sage: QS3.cpi([2,1]) 2/3*[1, 2, 3] - 1/3*[2, 3, 1] - 1/3*[3, 1, 2] sage: QS3.cpi([3]) 1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] sage: QS3.cpi([1,1,1]) 1/6*[1, 2, 3] - 1/6*[1, 3, 2] - 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] - 1/6*[3, 2, 1] """ if p not in partition.Partitions_n(self.n): raise TypeError, "p must be a partition of %s"%self.n character_table = eval(gap.eval("Display(Irr(SymmetricGroup(%d)));"%self.n)) cpi = self(0) np = partition.Partitions_n(self.n).list() np.reverse() p_index = np.index(p) big_coeff = character_table[p_index][0]/factorial(self.n) for g in permutation.StandardPermutations_n(self.n): cpi += big_coeff * character_table[p_index][np.index(g.inverse().cycle_type())] * self(g) return cpi
def cardinality(self): r""" Return the cardinality of ``self``. The number of `n \times n` alternating sign matrices is equal to .. MATH:: \prod_{k=0}^{n-1} \frac{(3k+1)!}{(n+k)!} = \frac{1! 4! 7! 10! \cdots (3n-2)!}{n! (n+1)! (n+2)! (n+3)! \cdots (2n-1)!} EXAMPLES:: sage: [AlternatingSignMatrices(n).cardinality() for n in range(0, 11)] [1, 1, 2, 7, 42, 429, 7436, 218348, 10850216, 911835460, 129534272700] """ return Integer(prod([factorial(3 * k + 1) / factorial(self._n + k) for k in range(self._n)]))
def cardinality(self): r""" Return the cardinality of ``self``. The number of `n \times n` alternating sign matrices is equal to .. MATH:: \prod_{k=0}^{n-1} \frac{(3k+1)!}{(n+k)!} = \frac{1! 4! 7! 10! \cdots (3n-2)!}{n! (n+1)! (n+2)! (n+3)! \cdots (2n-1)!} EXAMPLES:: sage: [AlternatingSignMatrices(n).cardinality() for n in range(0, 11)] [1, 1, 2, 7, 42, 429, 7436, 218348, 10850216, 911835460, 129534272700] """ return Integer(prod( [ factorial(3*k+1)/factorial(self._n+k) for k in range(self._n)] ))
def cardinality(self): r""" Cardinality of ``self``. The number of monotone triangles with `n` rows is equal to .. MATH:: \prod_{k=0}^{n-1} \frac{(3k+1)!}{(n+k)!} = \frac{1! 4! 7! 10! \cdots (3n-2)!}{n! (n+1)! (n+2)! (n+3)! \cdots (2n-1)!} EXAMPLES:: sage: M = MonotoneTriangles(4) sage: M.cardinality() 42 """ return Integer(prod([factorial(3 * k + 1) / factorial(self._n + k) for k in range(self._n)]))
def cardinality(self): r""" Cardinality of ``self``. The number of monotone triangles with `n` rows is equal to .. MATH:: \prod_{k=0}^{n-1} \frac{(3k+1)!}{(n+k)!} = \frac{1! 4! 7! 10! \cdots (3n-2)!}{n! (n+1)! (n+2)! (n+3)! \cdots (2n-1)!} EXAMPLES:: sage: M = MonotoneTriangles(4) sage: M.cardinality() 42 """ return Integer(prod( [ factorial(3*k+1)/factorial(self._n+k) for k in range(self._n)] ))
def cpi(self, p): """ Return the centrally primitive idempotent for the symmetric group of order `n` corresponding to the irreducible representation indexed by the partition ``p``. EXAMPLES:: sage: QS3 = SymmetricGroupAlgebra(QQ,3) sage: QS3.cpi([2,1]) 2/3*[1, 2, 3] - 1/3*[2, 3, 1] - 1/3*[3, 1, 2] sage: QS3.cpi([3]) 1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] sage: QS3.cpi([1,1,1]) 1/6*[1, 2, 3] - 1/6*[1, 3, 2] - 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] - 1/6*[3, 2, 1] sage: QS0 = SymmetricGroupAlgebra(QQ, 0) sage: QS0.cpi(Partition([])) [] TESTS:: sage: QS3.cpi([2,2]) Traceback (most recent call last): ... TypeError: p (= [2, 2]) must be a partition of n (= 3) """ if p not in partition.Partitions_n(self.n): raise TypeError( "p (= {p}) must be a partition of n (= {n})".format(p=p, n=self.n)) character_table = eval( gap.eval("Display(Irr(SymmetricGroup(%d)));" % self.n)) cpi = self.zero() np = partition.Partitions_n(self.n).list() np.reverse() p_index = np.index(p) big_coeff = character_table[p_index][0] / factorial(self.n) character_row = character_table[p_index] dct = { g: big_coeff * character_row[np.index(g.cycle_type())] for g in permutation.StandardPermutations_n(self.n) } return self._from_dict(dct)
def cpi(self, p): """ Return the centrally primitive idempotent for the symmetric group of order `n` corresponding to the irreducible representation indexed by the partition ``p``. EXAMPLES:: sage: QS3 = SymmetricGroupAlgebra(QQ,3) sage: QS3.cpi([2,1]) 2/3*[1, 2, 3] - 1/3*[2, 3, 1] - 1/3*[3, 1, 2] sage: QS3.cpi([3]) 1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] sage: QS3.cpi([1,1,1]) 1/6*[1, 2, 3] - 1/6*[1, 3, 2] - 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] - 1/6*[3, 2, 1] sage: QS0 = SymmetricGroupAlgebra(QQ, 0) sage: QS0.cpi(Partition([])) [] TESTS:: sage: QS3.cpi([2,2]) Traceback (most recent call last): ... TypeError: p (= [2, 2]) must be a partition of n (= 3) """ if p not in partition.Partitions_n(self.n): raise TypeError("p (= {p}) must be a partition of n (= {n})".format(p=p, n=self.n)) character_table = eval(gap.eval("Display(Irr(SymmetricGroup(%d)));"%self.n)) cpi = self.zero() np = partition.Partitions_n(self.n).list() np.reverse() p_index = np.index(p) big_coeff = character_table[p_index][0] / factorial(self.n) character_row = character_table[p_index] dct = { g : big_coeff * character_row[np.index(g.cycle_type())] for g in permutation.StandardPermutations_n(self.n) } return self._from_dict(dct)
def kappa(alpha): r""" Returns `\kappa_\alpha` which is n! divided by the number of standard tableaux of shape `\alpha`. EXAMPLES:: sage: from sage.combinat.symmetric_group_algebra import kappa sage: kappa(Partition([2,1])) 3 sage: kappa([2,1]) 3 """ try: n = alpha.size() except AttributeError: n = sum(alpha) return factorial(n)/StandardTableaux(alpha).cardinality()
def by_taylor_expansion(self, fs, k): r""" We combine the theta decomposition and the heat operator as in the thesis of Nils Skoruppa. This yields a bijections of the space of weak Jacobi forms of weight `k` and index `m` with the product of spaces of elliptic modular forms `M_k \times S_{k+2} \times .. \times S_{k+2m}`. INPUT: - ``fs`` -- A list of functions that given an integer `p` return the q-expansion of a modular form with rational coefficients up to precision `p`. These modular forms correspond to the components of the above product. - `k` -- An integer. The weight of the weak Jacobi form to be computed. NOTE: In order to make ``phi_divs`` integral we introduce an extra factor `2^{\mathrm{index}} * \mathrm{factorial}(k + 2 * \mathrm{index} - 1)`. """ ## we introduce an abbreviations p = self.__p PS = self.power_series_ring() if not len(fs) == self.__precision.jacobi_index() + 1: raise ValueError( "fs (which has length {0}) must be a list of {1} Fourier expansions" \ .format(len(fs), self.__precision.jacobi_index() + 1) ) qexp_prec = self._qexp_precision() if qexp_prec is None: # there are no forms below the precision return dict() f_divs = dict() for (i, f) in enumerate(fs): f_divs[(i, 0)] = PS(f(qexp_prec), qexp_prec) for i in xrange(self.__precision.jacobi_index() + 1): for j in xrange(1, self.__precision.jacobi_index() - i + 1): f_divs[(i, j)] = f_divs[(i, j - 1)].derivative().shift(1) phi_divs = list() for i in xrange(self.__precision.jacobi_index() + 1): ## This is the formula in Skoruppas thesis. He uses d/ d tau instead of d / dz which yields ## a factor 4 m phi_divs.append( sum(f_divs[(j, i - j)] * (4 * self.__precision.jacobi_index())**i * binomial(i, j) * (2**self.index() // 2**i) * prod(2 * (i - l) + 1 for l in xrange(1, i)) * (factorial(k + 2 * self.index() - 1) // factorial(i + k + j - 1)) * factorial(2 * self.__precision.jacobi_index() + k - 1) for j in xrange(i + 1))) phi_coeffs = dict() for r in xrange(self.index() + 1): series = sum(map(operator.mul, self._theta_factors()[r], phi_divs)) series = self._eta_factor() * series for n in xrange(qexp_prec): phi_coeffs[(n, r)] = int(series[n].lift()) % p return phi_coeffs
def by_taylor_expansion(self, fs, k) : r""" We combine the theta decomposition and the heat operator as in the thesis of Nils Skoruppa. This yields a bijections of the space of weak Jacobi forms of weight `k` and index `m` with the product of spaces of elliptic modular forms `M_k \times S_{k+2} \times .. \times S_{k+2m}`. INPUT: - ``fs`` -- A list of functions that given an integer `p` return the q-expansion of a modular form with rational coefficients up to precision `p`. These modular forms correspond to the components of the above product. - `k` -- An integer. The weight of the weak Jacobi form to be computed. NOTE: In order to make ``phi_divs`` integral we introduce an extra factor `2^{\mathrm{index}} * \mathrm{factorial}(k + 2 * \mathrm{index} - 1)`. """ ## we introduce an abbreviations p = self.__p PS = self.power_series_ring() if not len(fs) == self.__precision.jacobi_index() + 1 : raise ValueError( "fs (which has length {0}) must be a list of {1} Fourier expansions" \ .format(len(fs), self.__precision.jacobi_index() + 1) ) qexp_prec = self._qexp_precision() if qexp_prec is None : # there are no forms below the precision return dict() f_divs = dict() for (i, f) in enumerate(fs) : f_divs[(i, 0)] = PS(f(qexp_prec), qexp_prec) for i in xrange(self.__precision.jacobi_index() + 1) : for j in xrange(1, self.__precision.jacobi_index() - i + 1) : f_divs[(i,j)] = f_divs[(i, j - 1)].derivative().shift(1) phi_divs = list() for i in xrange(self.__precision.jacobi_index() + 1) : ## This is the formula in Skoruppas thesis. He uses d/ d tau instead of d / dz which yields ## a factor 4 m phi_divs.append( sum( f_divs[(j, i - j)] * (4 * self.__precision.jacobi_index())**i * binomial(i,j) * ( 2**self.index() // 2**i) * prod(2*(i - l) + 1 for l in xrange(1, i)) * (factorial(k + 2*self.index() - 1) // factorial(i + k + j - 1)) * factorial(2*self.__precision.jacobi_index() + k - 1) for j in xrange(i + 1) ) ) phi_coeffs = dict() for r in xrange(self.index() + 1) : series = sum( map(operator.mul, self._theta_factors()[r], phi_divs) ) series = self._eta_factor() * series for n in xrange(qexp_prec) : phi_coeffs[(n, r)] = int(series[n].lift()) % p return phi_coeffs