def _creation_by_determinant_helper(self, k, part): """ EXAMPLES:: sage: S = MacdonaldPolynomialsS(QQ) sage: a = S([2,1]) sage: a._creation_by_determinant_helper(2,[1]) (q^3*t-q^2*t-q+1)*McdS[2, 1] + (q^3-q^2*t-q+t)*McdS[3] """ S = self.parent() q,t = S.q, S.t part += [0]*(k-len(part)) if len(part) > k: raise ValueError, "the column to add is too small" #Create the matrix over the homogeneous symmetric #functions and take its determinant MS = MatrixSpace(sfa.SFAHomogeneous(S.base_ring()), k, k) h = MS.base_ring() m = [] for i in range(k): row = [0]*max(0, (i+1)-2-part[i]) for j in range(max(0, (i+1)-2-part[i]),k): value = part[i]+j-i+1 p = [value] if value > 0 else [] row.append( (1-q**(part[i]+j-i+1)*t**(k-(j+1)))*h(p) ) m.append(row) M = MS(m) res = M.det() #Convert to the Schurs res = S._s( res ) return S._from_element(res)
def matrix_clean_up(mat): r""" Apply get_cleaned_up_version to each object within each entry and return a cleaned up matrix """ dim = mat.nrows() L = list() mat_space = MatrixSpace(CombinatorialScalarRing(),dim) prnt = mat_space.base_ring() for i in range(dim): L.append(list()) for j in range(dim): L[i].append(CombinatorialScalarWrapper(mat[i,j].get_cleaned_up_version())) return mat_space(L)
def identity_matrix(dim): r""" Returns standard combinatorial identity matrix """ mat_space = MatrixSpace(CombinatorialScalarRing(),dim) prnt = mat_space.base_ring() L = list() for i in range(dim): L.append(list()) for j in range(dim): if i==j: L[i].append(prnt._one()) else: L[i].append(prnt._zero()) return mat_space(L)
def identity_matrix(dim): r""" Returns standard combinatorial identity matrix """ mat_space = MatrixSpace(CombinatorialScalarRing(), dim) prnt = mat_space.base_ring() L = list() for i in range(dim): L.append(list()) for j in range(dim): if i == j: L[i].append(prnt._one()) else: L[i].append(prnt._zero()) return mat_space(L)
def matrix_clean_up(mat): r""" Apply get_cleaned_up_version to each object within each entry and return a cleaned up matrix """ dim = mat.nrows() L = list() mat_space = MatrixSpace(CombinatorialScalarRing(), dim) prnt = mat_space.base_ring() for i in range(dim): L.append(list()) for j in range(dim): L[i].append( CombinatorialScalarWrapper(mat[i, j].get_cleaned_up_version())) return mat_space(L)
def matrix_combinatorial_adjoint(mat): r""" Return Combinatorial Adjoint. """ dim = mat.nrows() M = list() mat_space = MatrixSpace(CombinatorialScalarRing(), dim) prnt = mat_space.base_ring() #create list L of lists of sets, dimension is increased by one to mitigate index confusion L = list() for i in range(dim + 1): L.append(list()) for j in range(dim + 1): L[i].append(set()) P = Permutations(dim) for p in P: p_comb = CombinatorialScalarWrapper( [CombinatorialObject(p, p.signature())]) l = list() for i in range(1, dim + 1): l.append(mat[p(i) - 1, i - 1]) #This list will have empty sets, which will yield to an empty cartesian product #especially when the matrix input is triangular (except for the identity permutation). #We will now iterate through the selected entries in each column #and create a set of a singleton of an empty string that corresponds #to the "missing" element of the tuple described in definition 39. for i in range(1, dim + 1): copy_l = copy(l) copy_l[i - 1] = CombinatorialScalarWrapper( [CombinatorialObject('_', 1)]) cp = CartesianProduct(p_comb, *copy_l) for tupel in cp: tupel = tuple(tupel) tupel_weight = 1 tupel_sign = 1 for elm in tupel: tupel_sign = tupel_sign * elm.get_sign() tupel_weight = tupel_weight * elm.get_weight() L[i][p(i)].add( CombinatorialObject(tupel, tupel_sign, tupel_weight)) #turn these sets into CombinatorialScalars for i in range(1, dim + 1): l = list() for j in range(1, dim + 1): l.append(CombinatorialScalarWrapper(L[i][j])) M.append(l) return mat_space(M)
def matrix_combinatorial_adjoint(mat): r""" Return Combinatorial Adjoint. """ dim = mat.nrows() M = list() mat_space = MatrixSpace(CombinatorialScalarRing(),dim) prnt = mat_space.base_ring() #create list L of lists of sets, dimension is increased by one to mitigate index confusion L = list() for i in range(dim+1): L.append(list()) for j in range(dim+1): L[i].append(set()) P = Permutations(dim) for p in P: p_comb = CombinatorialScalarWrapper([CombinatorialObject(p,p.signature())]) l = list() for i in range(1,dim+1): l.append(mat[p(i)-1,i-1]) #This list will have empty sets, which will yield to an empty cartesian product #especially when the matrix input is triangular (except for the identity permutation). #We will now iterate through the selected entries in each column #and create a set of a singleton of an empty string that corresponds #to the "missing" element of the tuple described in definition 39. for i in range(1,dim+1): copy_l = copy(l) copy_l[i-1]=CombinatorialScalarWrapper([CombinatorialObject('_',1)]) cp = CartesianProduct(p_comb,*copy_l) for tupel in cp: tupel = tuple(tupel) tupel_weight = 1 tupel_sign = 1 for elm in tupel: tupel_sign = tupel_sign*elm.get_sign() tupel_weight = tupel_weight*elm.get_weight() L[i][p(i)].add(CombinatorialObject(tupel,tupel_sign,tupel_weight)) #turn these sets into CombinatorialScalars for i in range(1,dim+1): l = list() for j in range(1,dim+1): l.append(CombinatorialScalarWrapper(L[i][j])) M.append(l) return mat_space(M)
def _creation_by_determinant_helper(self, k, part): """ EXAMPLES:: sage: S = MacdonaldPolynomialsS(QQ) sage: a = S([2,1]) sage: a._creation_by_determinant_helper(2,[1]) (q^3*t-q^2*t-q+1)*McdS[2, 1] + (q^3-q^2*t-q+t)*McdS[3] """ S = self.parent() q, t = S.q, S.t part += [0] * (k - len(part)) if len(part) > k: raise ValueError, "the column to add is too small" #Create the matrix over the homogeneous symmetric #functions and take its determinant MS = MatrixSpace(sfa.SFAHomogeneous(S.base_ring()), k, k) h = MS.base_ring() m = [] for i in range(k): row = [0] * max(0, (i + 1) - 2 - part[i]) for j in range(max(0, (i + 1) - 2 - part[i]), k): value = part[i] + j - i + 1 p = [value] if value > 0 else [] row.append( (1 - q**(part[i] + j - i + 1) * t**(k - (j + 1))) * h(p)) m.append(row) M = MS(m) res = M.det() #Convert to the Schurs res = S._s(res) return S._from_element(res)