def _multiply(self, left, right): """ Returns the product of ``left`` and ``right``. - ``self`` -- a monomial symmetric function basis - ``left``, ``right`` -- instances of the Schur basis ``self``. OUPUT: - an element of the Schur basis, the product of ``left`` and ``right`` EXAMPLES:: sage: m = SymmetricFunctions(QQ).m() sage: a = m([2,1]) sage: a^2 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] :: sage: QQx.<x> = QQ['x'] sage: m = SymmetricFunctions(QQx).m() sage: a = m([2,1])+x sage: 2*a # indirect doctest 2*x*m[] + 2*m[2, 1] sage: a^2 x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] """ #Use symmetrica to do the multiplication A = left.parent() R = A.base_ring() #Hack due to symmetrica crashing when both of the #partitions are the empty partition #if R is ZZ or R is QQ: # return symmetrica.mult_monomial_monomial(left, right) z_elt = {} for (left_m, left_c) in left._monomial_coefficients.iteritems(): for (right_m, right_c) in right._monomial_coefficients.iteritems(): #Hack due to symmetrica crashing when both of the #partitions are the empty partition if left_m == [] and right_m == []: z_elt[left_m] = left_c * right_c continue d = symmetrica.mult_monomial_monomial({ left_m: Integer(1) }, { right_m: Integer(1) }).monomial_coefficients() for m in d: if m in z_elt: z_elt[m] = z_elt[m] + left_c * right_c * d[m] else: z_elt[m] = left_c * right_c * d[m] return z_elt
def _multiply(self, left, right): """ Return the product of ``left`` and ``right``. - ``left``, ``right`` -- symmetric functions written in the monomial basis ``self``. OUTPUT: - the product of ``left`` and ``right``, expanded in the monomial basis, as a dictionary whose keys are partitions and whose values are the coefficients of these partitions (more precisely, their respective monomial symmetric functions) in the product. EXAMPLES:: sage: m = SymmetricFunctions(QQ).m() sage: a = m([2,1]) sage: a^2 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] :: sage: QQx.<x> = QQ['x'] sage: m = SymmetricFunctions(QQx).m() sage: a = m([2,1])+x sage: 2*a # indirect doctest 2*x*m[] + 2*m[2, 1] sage: a^2 x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] """ #Use symmetrica to do the multiplication #A = left.parent() #Hack due to symmetrica crashing when both of the #partitions are the empty partition #if R is ZZ or R is QQ: # return symmetrica.mult_monomial_monomial(left, right) z_elt = {} for (left_m, left_c) in left._monomial_coefficients.iteritems(): for (right_m, right_c) in right._monomial_coefficients.iteritems(): #Hack due to symmetrica crashing when both of the #partitions are the empty partition if left_m == [] and right_m == []: z_elt[ left_m ] = left_c*right_c continue d = symmetrica.mult_monomial_monomial({left_m:Integer(1)}, {right_m:Integer(1)}).monomial_coefficients() for m in d: if m in z_elt: z_elt[ m ] = z_elt[m] + left_c * right_c * d[m] else: z_elt[ m ] = left_c * right_c * d[m] return z_elt
def _multiply(self, left, right): """ Returns the product of ``left`` and ``right``. - ``self`` -- a monomial symmetric function basis - ``left``, ``right`` -- instances of the Schur basis ``self``. OUPUT: - an element of the Schur basis, the product of ``left`` and ``right`` EXAMPLES:: sage: m = SymmetricFunctions(QQ).m() sage: a = m([2,1]) sage: a^2 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] :: sage: QQx.<x> = QQ['x'] sage: m = SymmetricFunctions(QQx).m() sage: a = m([2,1])+x sage: 2*a # indirect doctest 2*x*m[] + 2*m[2, 1] sage: a^2 x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] """ # Use symmetrica to do the multiplication # A = left.parent() # Hack due to symmetrica crashing when both of the # partitions are the empty partition # if R is ZZ or R is QQ: # return symmetrica.mult_monomial_monomial(left, right) z_elt = {} for (left_m, left_c) in left._monomial_coefficients.iteritems(): for (right_m, right_c) in right._monomial_coefficients.iteritems(): # Hack due to symmetrica crashing when both of the # partitions are the empty partition if left_m == [] and right_m == []: z_elt[left_m] = left_c * right_c continue d = symmetrica.mult_monomial_monomial( {left_m: Integer(1)}, {right_m: Integer(1)} ).monomial_coefficients() for m in d: if m in z_elt: z_elt[m] = z_elt[m] + left_c * right_c * d[m] else: z_elt[m] = left_c * right_c * d[m] return z_elt
def _multiply(self, left, right): """ EXAMPLES:: sage: m = SFAMonomial(QQ) sage: a = m([2,1]) sage: a^2 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] :: sage: QQx.<x> = QQ['x'] sage: m = SFAMonomial(QQx) sage: a = m([2,1])+x sage: 2*a # indirect doctest 2*x*m[] + 2*m[2, 1] sage: a^2 x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] """ #Use symmetrica to do the multiplication A = left.parent() R = A.base_ring() #Hack due to symmetrica crashing when both of the #partitions are the empty partition #if R is ZZ or R is QQ: # return symmetrica.mult_monomial_monomial(left, right) z_elt = {} for (left_m, left_c) in left._monomial_coefficients.iteritems(): for (right_m, right_c) in right._monomial_coefficients.iteritems(): #Hack due to symmetrica crashing when both of the #partitions are the empty partition if left_m == [] and right_m == []: z_elt[left_m] = left_c * right_c continue d = symmetrica.mult_monomial_monomial({ left_m: Integer(1) }, { right_m: Integer(1) }).monomial_coefficients() for m in d: if m in z_elt: z_elt[m] = z_elt[m] + left_c * right_c * d[m] else: z_elt[m] = left_c * right_c * d[m] return z_elt
def _multiply(self, left, right): """ EXAMPLES:: sage: m = SFAMonomial(QQ) sage: a = m([2,1]) sage: a^2 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] :: sage: QQx.<x> = QQ['x'] sage: m = SFAMonomial(QQx) sage: a = m([2,1])+x sage: 2*a # indirect doctest 2*x*m[] + 2*m[2, 1] sage: a^2 x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] """ #Use symmetrica to do the multiplication A = left.parent() R = A.base_ring() #Hack due to symmetrica crashing when both of the #partitions are the empty partition #if R is ZZ or R is QQ: # return symmetrica.mult_monomial_monomial(left, right) z_elt = {} for (left_m, left_c) in left._monomial_coefficients.iteritems(): for (right_m, right_c) in right._monomial_coefficients.iteritems(): #Hack due to symmetrica crashing when both of the #partitions are the empty partition if left_m == [] and right_m == []: z_elt[ left_m ] = left_c*right_c continue d = symmetrica.mult_monomial_monomial({left_m:Integer(1)}, {right_m:Integer(1)}).monomial_coefficients() for m in d: if m in z_elt: z_elt[ m ] = z_elt[m] + left_c * right_c * d[m] else: z_elt[ m ] = left_c * right_c * d[m] return z_elt
def _multiply(self, left, right): """ Return the product of ``left`` and ``right``. - ``left``, ``right`` -- symmetric functions written in the monomial basis ``self``. OUTPUT: - the product of ``left`` and ``right``, expanded in the monomial basis, as a dictionary whose keys are partitions and whose values are the coefficients of these partitions (more precisely, their respective monomial symmetric functions) in the product. EXAMPLES:: sage: m = SymmetricFunctions(QQ).m() sage: a = m([2,1]) sage: a^2 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] :: sage: QQx.<x> = QQ['x'] sage: m = SymmetricFunctions(QQx).m() sage: a = m([2,1])+x sage: 2*a # indirect doctest 2*x*m[] + 2*m[2, 1] sage: a^2 x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2] """ # Use symmetrica to do the multiplication # A = left.parent() # Hack due to symmetrica crashing when both of the # partitions are the empty partition # if R is ZZ or R is QQ: # return symmetrica.mult_monomial_monomial(left, right) z_elt = {} for left_m, left_c in left._monomial_coefficients.items(): for right_m, right_c in right._monomial_coefficients.items(): # Hack due to symmetrica crashing when both of the # partitions are the empty partition if not left_m and not right_m: z_elt[left_m] = left_c * right_c continue d = symmetrica.mult_monomial_monomial({ left_m: Integer(1) }, { right_m: Integer(1) }).monomial_coefficients() for m in d: if m in z_elt: z_elt[m] += left_c * right_c * d[m] else: z_elt[m] = left_c * right_c * d[m] return z_elt