def tensor_product(self, other): r""" Return the graded tensor product. INPUT: - ``other`` -- a filtered vector space. OUTPUT: The graded tensor product, that is, the tensor product of a generator of degree `d_1` with a generator in degree `d_2` has degree `d_1 + d_2`. EXAMPLES:: sage: F1 = FilteredVectorSpace(1, 1) sage: F2 = FilteredVectorSpace(1, 2) sage: F1.tensor_product(F2) QQ^1 >= 0 sage: F1 * F2 QQ^1 >= 0 sage: F1.min_degree() 1 sage: F2.min_degree() 2 sage: (F1*F2).min_degree() 3 A suitable base ring is chosen if they do not match:: sage: v = [(1,0), (0,1)] sage: F1 = FilteredVectorSpace(v, {0:[0], 1:[1]}, base_ring=QQ) sage: F2 = FilteredVectorSpace(v, {0:[0], 1:[1]}, base_ring=RDF) sage: F1 * F2 RDF^4 >= RDF^3 >= RDF^1 >= 0 """ V = self W = other from sage.structure.element import get_coercion_model base_ring = get_coercion_model().common_parent(V.base_ring(), W.base_ring()) from sage.modules.tensor_operations import VectorCollection, TensorOperation V_generators, V_indices = V.presentation() W_generators, W_indices = W.presentation() V_coll = VectorCollection(V_generators, base_ring, V.dimension()) W_coll = VectorCollection(W_generators, base_ring, W.dimension()) T = TensorOperation([V_coll, W_coll], 'product') filtration = dict() for V_deg in V.support(): for W_deg in W.support(): deg = V_deg + W_deg indices = filtration.get(deg, set()) for i in V_indices[V_deg]: for j in W_indices[W_deg]: i_tensor_j = T.index_map(i, j) indices.add(i_tensor_j) filtration[deg] = indices return FilteredVectorSpace(T.vectors(), filtration, base_ring=base_ring)
def _power_operation(self, n, operation): """ Return tensor power operation. INPUT: - ``n`` -- integer. the number of factors of ``self``. - ``operation`` -- string. See :class:`~sage.modules.tensor_operations.TensorOperation` for details. EXAMPLES:: sage: F = FilteredVectorSpace(1, 1) + FilteredVectorSpace(1, 2); F QQ^2 >= QQ^1 >= 0 sage: F._power_operation(2, 'symmetric') QQ^3 >= QQ^2 >= QQ^1 >= 0 sage: F._power_operation(2, 'antisymmetric') QQ^1 >= 0 """ from sage.modules.tensor_operations import VectorCollection, TensorOperation generators, indices = self.presentation() V = VectorCollection(generators, self.base_ring(), self.dimension()) T = TensorOperation([V] * n, operation) iters = [self.support()] * n filtration = dict() from sage.categories.cartesian_product import cartesian_product for degrees in cartesian_product(iters): deg = sum(degrees) filt_deg = filtration.get(deg, set()) for i in cartesian_product([indices.get(d) for d in degrees]): pow_i = T.index_map(*i) if pow_i is not None: filt_deg.add(pow_i) filtration[deg] = filt_deg return FilteredVectorSpace(T.vectors(), filtration, base_ring=self.base_ring())