• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cartesian_product.cartesian_product函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sage.categories.cartesian_product.cartesian_product函数的典型用法代码示例。如果您正苦于以下问题:Python cartesian_product函数的具体用法?Python cartesian_product怎么用?Python cartesian_product使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cartesian_product函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: symmetrized_coordinate_sums

def symmetrized_coordinate_sums(dim, n):
    """
    Return formal symmetrized sum of multi-indices

    INPUT:

    - ``dim`` -- integer. The dimension (range of each index).

    - ``n`` -- integer. The total number of indices.

    OUTPUT:

    A symmetrized formal sum of multi-indices (tuples of integers)

    EXAMPLES::

        sage: from sage.modules.tensor_operations import symmetrized_coordinate_sums
        sage: symmetrized_coordinate_sums(2, 2)
        ((0, 1) + (1, 0), (0, 0), (1, 1))
    """
    from sage.structure.formal_sum import FormalSum
    coordinates = [range(dim) for i in range(n)]
    table = dict()
    from sage.categories.cartesian_product import cartesian_product
    for i in cartesian_product(coordinates):
        sort_i = tuple(sorted(i))
        x = table.get(sort_i, [])
        x.append([+1, tuple(i)])
        table[sort_i] = x
    return tuple(FormalSum(x) for x in table.values())
开发者ID:ProgVal,项目名称:sage,代码行数:30,代码来源:tensor_operations.py


示例2: strongly_finer

    def strongly_finer(self):
        """
        Return the set of ordered set partitions which are strongly
        finer than ``self``.

        See :meth:`is_strongly_finer` for the definition of "strongly
        finer".

        EXAMPLES::

            sage: C = OrderedSetPartition([[1, 3], [2]]).strongly_finer()
            sage: C.cardinality()
            2
            sage: C.list()
            [[{1}, {3}, {2}], [{1, 3}, {2}]]

            sage: OrderedSetPartition([]).strongly_finer()
            {[]}

            sage: W = OrderedSetPartition([[4, 9], [-1, 2]])
            sage: W.strongly_finer().list()
            [[{4}, {9}, {-1}, {2}],
             [{4}, {9}, {-1, 2}],
             [{4, 9}, {-1}, {2}],
             [{4, 9}, {-1, 2}]]
        """
        par = parent(self)
        if not self:
            return FiniteEnumeratedSet([self])
        else:
            buo = OrderedSetPartition.bottom_up_osp
            return FiniteEnumeratedSet([par(sum((list(P) for P in C), []))
                    for C in cartesian_product([[buo(X, comp) for comp in Compositions(len(X))] for X in self])])
开发者ID:saraedum,项目名称:sage-renamed,代码行数:33,代码来源:set_partition_ordered.py


示例3: __init__

    def __init__(self, space, number_errors, number_erasures):
        r"""


        TESTS:

        If the sum of number of errors and number of erasures
        exceeds (or may exceed, in the case of tuples) the dimension of the input space,
        it will return an error::

            sage: n_err, n_era = 21, 21
            sage: Chan = channels.ErrorErasureChannel(GF(59)^40, n_err, n_era)
            Traceback (most recent call last):
            ...
            ValueError: The total number of errors and erasures can not exceed the dimension of the input space
        """
        if isinstance(number_errors, (Integer, int)):
            number_errors = (number_errors, number_errors)
        if not isinstance(number_errors, (tuple, list)):
            raise ValueError("number_errors must be a tuple, a list, an Integer or a Python int")

        if isinstance(number_erasures, (Integer, int)):
            number_erasures = (number_erasures, number_erasures)
        if not isinstance(number_erasures, (tuple, list)):
            raise ValueError("number_erasures must be a tuple, a list, an Integer or a Python int")

        output_space = cartesian_product([space, VectorSpace(GF(2), space.dimension())])
        super(ErrorErasureChannel, self).__init__(space, output_space)
        if number_errors[1] + number_erasures[1] > space.dimension():
            raise ValueError("The total number of errors and erasures can not exceed the dimension of the input space")
        self._number_errors = number_errors
        self._number_erasures = number_erasures
开发者ID:sensen1,项目名称:sage,代码行数:32,代码来源:channel_constructions.py


示例4: __init__

    def __init__(self, crystals, **options):
        """
        TESTS::

            sage: from sage.combinat.crystals.tensor_product import FullTensorProductOfCrystals
            sage: C = crystals.Letters(['A',2])
            sage: T = crystals.TensorProduct(C,C)
            sage: isinstance(T, FullTensorProductOfCrystals)
            True
            sage: TestSuite(T).run()
        """
        category = Category.meet([crystal.category() for crystal in crystals])
        category = category.TensorProducts()
        if any(c in Sets().Infinite() for c in crystals):
            category = category.Infinite()
        Parent.__init__(self, category=category)
        self.crystals = crystals
        if 'cartan_type' in options:
            self._cartan_type = CartanType(options['cartan_type'])
        else:
            if not crystals:
                raise ValueError("you need to specify the Cartan type if the tensor product list is empty")
            else:
                self._cartan_type = crystals[0].cartan_type()
        self.cartesian_product = cartesian_product(self.crystals)
        self.module_generators = self
开发者ID:vbraun,项目名称:sage,代码行数:26,代码来源:tensor_product.py


示例5: basis

    def basis(self):
        r"""
        Return the basis of ``self``.

        EXAMPLES::

            sage: g = LieAlgebra(QQ, cartan_type=['D',4,1])
            sage: B = g.basis()
            sage: al = RootSystem(['D',4]).root_lattice().simple_roots()
            sage: B[al[1]+al[2]+al[4],4]
            (E[alpha[1] + alpha[2] + alpha[4]])#t^4
            sage: B[-al[1]-2*al[2]-al[3]-al[4],2]
            (E[-alpha[1] - 2*alpha[2] - alpha[3] - alpha[4]])#t^2
            sage: B[al[4],-2]
            (E[alpha[4]])#t^-2
            sage: B['c']
            c
            sage: B['d']
            d
        """
        K = cartesian_product([self._g.basis().keys(), ZZ])
        from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
        c = FiniteEnumeratedSet(['c'])
        if self._kac_moody:
            d = FiniteEnumeratedSet(['d'])
            keys = DisjointUnionEnumeratedSets([c, d, K])
        else:
            keys = DisjointUnionEnumeratedSets([c, K])
        return Family(keys, self.monomial)
开发者ID:sagemath,项目名称:sage,代码行数:29,代码来源:affine_lie_algebra.py


示例6: Possible

def Possible(n):
    r"""
    Possible stack of DyckWords inside a n x n cube.

    EXAMPLES::

        sage: from slabbe.dyck_3d import Possible
        sage: Possible(1)
        The Cartesian product of ({[1, 0]},)
        sage: Possible(2)
        The Cartesian product of ({[1, 1, 0, 0]}, {[1, 0, 1, 0], [1, 1, 0, 0]})
        sage: Possible(3).list()
        [([1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0], [1, 0, 1, 1, 0, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0], [1, 1, 0, 0, 1, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0], [1, 1, 0, 1, 0, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0], [1, 1, 1, 0, 0, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [1, 0, 1, 1, 0, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 0, 0]),
         ([1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0])]

    """
    from sage.combinat.dyck_word import DyckWords, DyckWord
    from sage.categories.cartesian_product import cartesian_product
    L = []
    for i in range(1, n+1):
        K = []
        for w in DyckWords(i):
            w = DyckWord([1]*(n-i) + list(w) + [0]*(n-i))
            K.append(w) 
        L.append(K)
    return cartesian_product(L)
开发者ID:seblabbe,项目名称:slabbe,代码行数:34,代码来源:dyck_3d.py


示例7: one

            def one(self):
                """
                EXAMPLES::

                    sage: cartesian_product([QQ, ZZ, RR]).one()
                    (1, 1, 1.00000000000000)
                """
                return cartesian_product([set.one() for set in self._sets])
开发者ID:bgxcpku,项目名称:sagelib,代码行数:8,代码来源:monoids.py


示例8: _init_product_vectors

    def _init_product_vectors(self, i):
        r"""
        Helper to build up ``self._vectors`` incrementally during the
        constructor.

        INPUT:

        - `i` -- list/tuple of integers. Multi-index of length equal
          to the number of constituent vector collections. The $j$-th
          entry $i[j]$ indexes a ray in the $j$-th vector
          collection. Hence, $i$ specifies one element in each vector
          collection.

        OUTPUT:

        This method mutates the :class:`TensorOperation` instance. In
        particular, the tensor product of the vectors of the vector
        collection is computed, and added to the elements of the
        tensor operation if it has not been encountered before. 

        The index of this tensor product vector is returned as an
        integer.

        .. NOTE::

            In a convenient choice of coordinates the tensor product
            of, say, two vectors $(a,b)$ and $(c,d)$, is $(ac, ad, bc,
            bd)$.

        EXAMPLES::

            sage: from sage.modules.tensor_operations import \
            ....:      VectorCollection, TensorOperation
            sage: R = VectorCollection([(1,0), (1,2), (-1,-2)], QQ, 2)
            sage: S = VectorCollection([(1,), (-1,)], QQ, 1)
            sage: R_tensor_S = TensorOperation([R,S])
            sage: R_tensor_S.index_map(1, 1)
            3
            sage: R_tensor_S.index_map(2, 0)
            3
            sage: R_tensor_S.vectors()   # indirect doctest
            ((1, 0), (-1, 0), (1, 2), (-1, -2))
        """
        # Pick out the i[j]-th vector
        rays = [list(self._V[j].vectors()[k]) for j, k in enumerate(i)]
        v = []
        # Note: convert to list, as cartesian_product of vectors is unrelated
        from sage.categories.cartesian_product import cartesian_product
        for r in cartesian_product(map(list, rays)):
            v.append(prod(r))   # build up the tensor product
        v = tuple(v)
        # Use index of pre-existing tensor product vector if there is one
        try:
            result = self._vectors.index(v)
        except ValueError:
            self._vectors.append(v)
            result = len(self._vectors) - 1
        return result
开发者ID:ProgVal,项目名称:sage,代码行数:58,代码来源:tensor_operations.py


示例9: twin_prime_powers_difference_set

def twin_prime_powers_difference_set(p, check=True):
    r"""
    Return a difference set on `GF(p) \times GF(p+2)`.

    The difference set is built from the following element of the cartesian
    product of finite fields `GF(p) \times GF(p+2)`:

    - `(x,0)` with any `x`
    - `(x,y)` with `x` and `y` squares
    - `(x,y)` with `x` and `y` non-squares

    For more information see :wikipedia:`Difference_set`.

    INPUT:

    - ``check`` -- boolean (default: ``True``). If ``True`` then the result of
      the computation is checked before being returned. This should not be
      needed but ensures that the output is correct.

    EXAMPLES::

        sage: from sage.combinat.designs.difference_family import twin_prime_powers_difference_set
        sage: G,D = twin_prime_powers_difference_set(3)
        sage: G
        The cartesian product of (Finite Field of size 3, Finite Field of size 5)
        sage: D
        [[(1, 1), (1, 4), (2, 2), (2, 3), (0, 0), (1, 0), (2, 0)]]
    """
    from sage.rings.finite_rings.constructor import FiniteField
    from sage.categories.cartesian_product import cartesian_product
    from itertools import product
    Fp = FiniteField(p,'x')
    Fq = FiniteField(p+2,'x')
    Fpset = set(Fp)
    Fqset = set(Fq)
    Fp_squares = set(x**2 for x in Fpset)
    Fq_squares = set(x**2 for x in Fqset)

    # Pairs of squares, pairs of non-squares
    d = []
    d.extend(product(Fp_squares.difference([0]),Fq_squares.difference([0])))
    d.extend(product(Fpset.difference(Fp_squares),Fqset.difference(Fq_squares)))

    # All (x,0)
    d.extend((x,0) for x in Fpset)

    G = cartesian_product([Fp,Fq])

    if check and not is_difference_family(G, [d]):
        raise RuntimeError("twin_prime_powers_difference_set produced a wrong "
                           "difference set with p={}. Please contact "
                           "[email protected]".format(p))

    return G, [d]
开发者ID:bukzor,项目名称:sage,代码行数:54,代码来源:difference_family.py


示例10: strongly_fatter

    def strongly_fatter(self):
        """
        Return the set of ordered set partitions which are strongly fatter
        than ``self``.

        See :meth:`strongly_finer` for the definition of "strongly fatter".

        EXAMPLES::

            sage: C = OrderedSetPartition([[2, 5], [1], [3, 4]]).strongly_fatter()
            sage: C.cardinality()
            2
            sage: sorted(C)
            [[{2, 5}, {1, 3, 4}],
             [{2, 5}, {1}, {3, 4}]]

            sage: OrderedSetPartition([[4, 9], [-1, 2]]).strongly_fatter().list()
            [[{4, 9}, {-1, 2}]]

        Some extreme cases::

            sage: list(OrderedSetPartition([[5]]).strongly_fatter())
            [[{5}]]
            sage: list(OrderedSetPartition([]).strongly_fatter())
            [[]]
            sage: sorted(OrderedSetPartition([[1], [2], [3], [4]]).strongly_fatter())
            [[{1, 2, 3, 4}],
             [{1, 2, 3}, {4}],
             [{1, 2}, {3, 4}],
             [{1, 2}, {3}, {4}],
             [{1}, {2, 3, 4}],
             [{1}, {2, 3}, {4}],
             [{1}, {2}, {3, 4}],
             [{1}, {2}, {3}, {4}]]
            sage: sorted(OrderedSetPartition([[1], [3], [2], [4]]).strongly_fatter())
            [[{1, 3}, {2, 4}],
             [{1, 3}, {2}, {4}],
             [{1}, {3}, {2, 4}],
             [{1}, {3}, {2}, {4}]]
            sage: sorted(OrderedSetPartition([[4], [1], [5], [3]]).strongly_fatter())
            [[{4}, {1, 5}, {3}], [{4}, {1}, {5}, {3}]]
        """
        c = [sorted(X) for X in self]
        l = len(c)
        g = [-1] + [i for i in range(l-1) if c[i][-1] > c[i+1][0]] + [l-1]
        # g lists the positions of the blocks that cannot be merged
        # with their right neighbors.
        subcomps = [OrderedSetPartition(c[g[i] + 1 : g[i+1] + 1]) for i in range(len(g)-1)]
        # Now, self is the concatenation of the entries of subcomps.
        # We can fatten each of the ordered set partitions setcomps
        # arbitrarily, and then concatenate the results.
        fattenings = [list(subcomp.fatter()) for subcomp in subcomps]
        return FiniteEnumeratedSet([OrderedSetPartition(sum([list(g) for g in fattening], []))
            for fattening in cartesian_product(fattenings)])
开发者ID:saraedum,项目名称:sage-renamed,代码行数:54,代码来源:set_partition_ordered.py


示例11: group_generators

            def group_generators(self):
                """
                Return the group generators of ``self``.

                EXAMPLES::

                    sage: C5 = CyclicPermutationGroup(5)
                    sage: C4 = CyclicPermutationGroup(4)
                    sage: S4 = SymmetricGroup(3)
                    sage: C = cartesian_product([C5, C4, S4])
                    sage: C.group_generators()
                    Family (((1,2,3,4,5), (), ()),
                            ((), (1,2,3,4), ()),
                            ((), (), (1,2)),
                            ((), (), (2,3)))

                We check the other portion of :trac:`16718` is fixed::

                    sage: len(C.j_classes())
                    1

                An example with an infinitely generated group (a better output
                is needed)::

                    sage: G = Groups.free([1,2])
                    sage: H = Groups.free(ZZ)
                    sage: C = cartesian_product([G, H])
                    sage: C.monoid_generators()
                    Lazy family (gen(i))_{i in The Cartesian product of (...)}
                """
                F = self.cartesian_factors()
                ids = tuple(G.one() for G in F)
                def lift(i, gen):
                    cur = list(ids)
                    cur[i] = gen
                    return self._cartesian_product_of_elements(cur)
                from sage.sets.family import Family

                # Finitely generated
                cat = FiniteEnumeratedSets()
                if all(G.group_generators() in cat
                       or isinstance(G.group_generators(), (tuple, list)) for G in F):
                    ret = [lift(i, gen) for i,G in enumerate(F) for gen in G.group_generators()]
                    return Family(ret)

                # Infinitely generated
                # This does not return a good output, but it is "correct"
                # TODO: Figure out a better way to do things
                from sage.categories.cartesian_product import cartesian_product
                gens_prod = cartesian_product([Family(G.group_generators(),
                                                      lambda g: (i, g))
                                               for i,G in enumerate(F)])
                return Family(gens_prod, lift, name="gen")
开发者ID:Babyll,项目名称:sage,代码行数:53,代码来源:groups.py


示例12: difference_matrix_product

def difference_matrix_product(k, M1, G1, lmbda1, M2, G2, lmbda2, check=True):
    r"""
    Return the product of the ``(G1,k,lmbda1)`` and ``(G2,k,lmbda2)`` difference
    matrices ``M1`` and ``M2``.

    The result is a `(G1 \times G2, k, \lambda_1 \lambda_2)`-difference matrix.

    INPUT:

    - ``k,lmbda1,lmbda2`` -- positive integer

    - ``G1, G2`` -- groups

    - ``M1, M2`` -- ``(G1,k,lmbda1)`` and ``(G,k,lmbda2)`` difference
      matrices

    - ``check`` (boolean) -- if ``True`` (default), the output is checked before
      being returned.

    EXAMPLES::

        sage: from sage.combinat.designs.difference_matrices import (
        ....:     difference_matrix_product,
        ....:     is_difference_matrix)
        sage: G1,M1 = designs.difference_matrix(11,6)
        sage: G2,M2 = designs.difference_matrix(7,6)
        sage: G,M = difference_matrix_product(6,M1,G1,1,M2,G2,1)
        sage: G1
        Finite Field of size 11
        sage: G2
        Finite Field of size 7
        sage: G
        The Cartesian product of (Finite Field of size 11, Finite Field of size 7)
        sage: is_difference_matrix(M,G,6,1)
        True
    """
    g1 = G1.cardinality()
    g2 = G2.cardinality()
    g = g1 * g2
    lmbda = lmbda1 * lmbda2
    from sage.categories.cartesian_product import cartesian_product

    G = cartesian_product([G1, G2])

    M = [[G((M1[j1][i], M2[j2][i])) for i in range(k)] for j1 in range(lmbda1 * g1) for j2 in range(lmbda2 * g2)]

    if check and not is_difference_matrix(M, G, k, lmbda, True):
        raise RuntimeError(
            "In the product construction, Sage built something which is not a ({},{},{})-DM!".format(g, k, lmbda)
        )

    return G, M
开发者ID:akoutsianas,项目名称:sage,代码行数:52,代码来源:difference_matrices.py


示例13: _power_operation

    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())
开发者ID:mcognetta,项目名称:sage,代码行数:38,代码来源:filtered_vector_space.py


示例14: example

        def example(self):
            """
            EXAMPLES::

                sage: Sets().CartesianProducts().example()
                The cartesian product of (Set of prime numbers (basic implementation), An example of an infinite enumerated set: the non negative integers, An example of a finite enumerated set: {1,2,3})
            """
            from finite_enumerated_sets import FiniteEnumeratedSets
            from infinite_enumerated_sets import InfiniteEnumeratedSets
            from cartesian_product import cartesian_product
            S1 = Sets().example()
            S2 = InfiniteEnumeratedSets().example()
            S3 = FiniteEnumeratedSets().example()
            return cartesian_product([S1, S2, S3])
开发者ID:jwbober,项目名称:sagelib,代码行数:14,代码来源:sets_cat.py


示例15: monoid_generators

            def monoid_generators(self):
                """
                Return the generators of ``self``.

                EXAMPLES::

                    sage: M = Monoids.free([1,2,3])
                    sage: N = Monoids.free(['a','b'])
                    sage: C = cartesian_product([M, N])
                    sage: C.monoid_generators()
                    Family ((F[1], 1), (F[2], 1), (F[3], 1),
                            (1, F['a']), (1, F['b']))

                An example with an infinitely generated group (a better output
                is needed)::

                    sage: N = Monoids.free(ZZ)
                    sage: C = cartesian_product([M, N])
                    sage: C.monoid_generators()
                    Lazy family (gen(i))_{i in The Cartesian product of (...)}
                """
                F = self.cartesian_factors()
                ids = tuple(M.one() for M in F)

                def lift(i, gen):
                    cur = list(ids)
                    cur[i] = gen
                    return self._cartesian_product_of_elements(cur)

                from sage.sets.family import Family

                # Finitely generated
                cat = FiniteEnumeratedSets()
                if all(M.monoid_generators() in cat or isinstance(M.monoid_generators(), (tuple, list)) for M in F):
                    ret = [lift(i, gen) for i, M in enumerate(F) for gen in M.monoid_generators()]
                    return Family(ret)

                # Infinitely generated
                # This does not return a good output, but it is "correct"
                # TODO: Figure out a better way to do things
                from sage.categories.cartesian_product import cartesian_product

                gens_prod = cartesian_product(
                    [Family(M.monoid_generators(), lambda g: (i, g)) for i, M in enumerate(F)]
                )
                return Family(gens_prod, lift, name="gen")
开发者ID:novoselt,项目名称:sage,代码行数:46,代码来源:monoids.py


示例16: __init__

    def __init__(self, R):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: L = lie_algebras.Heisenberg(QQ, oo)
            sage: TestSuite(L).run()
            sage: L.p(1).bracket(L.q(1)) == L.z()
            True
            sage: L.q(1).bracket(L.p(1)) == -L.z()
            True
        """
        S = cartesian_product([PositiveIntegers(), ['p','q']])
        cat = LieAlgebras(R).Nilpotent().WithBasis()
        LieAlgebraWithGenerators.__init__(self, R, index_set=S, category=cat)
        HeisenbergAlgebra_abstract.__init__(self, S)
开发者ID:sagemath,项目名称:sage,代码行数:17,代码来源:heisenberg.py


示例17: __init__

    def __init__(self, R, q):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: AW = algebras.AskeyWilson(QQ)
            sage: TestSuite(AW).run()  # long time
        """
        self._q = q
        cat = Algebras(Rings().Commutative()).WithBasis()
        indices = cartesian_product([NonNegativeIntegers()]*6)
        CombinatorialFreeModule.__init__(self, R, indices, prefix='AW',
                                         sorting_key=_basis_key,
                                         sorting_reverse=True,
                                         category=cat)
        self._assign_names('A,B,C,a,b,g')
开发者ID:sagemath,项目名称:sage,代码行数:17,代码来源:askey_wilson.py


示例18: cartesian_product

        def cartesian_product(*elements):
            """
            Returns the cartesian product of its arguments, as an element of
            the cartesian product of the parents of those elements.

            EXAMPLES::

                sage: C = AlgebrasWithBasis(QQ)
                sage: A = C.example()
                sage: (a,b,c) = A.algebra_generators()
                sage: a.cartesian_product(b, c)
                B[(0, word: a)] + B[(1, word: b)] + B[(2, word: c)]

            FIXME: is this a policy that we want to enforce on all parents?
            """
            from sage.structure.element import parent, Element
            assert(all(isinstance(element, Element) for element in elements))
            parents = [parent(element) for element in elements]
            return cartesian_product(parents)._cartesian_product_of_elements(elements) # good name???
开发者ID:jwbober,项目名称:sagelib,代码行数:19,代码来源:sets_cat.py


示例19: _init_product

    def _init_product(self):
        """
        Initialization for the tensor product

        EXAMPLES::

            sage: from sage.modules.tensor_operations import \
            ....:      VectorCollection, TensorOperation
            sage: R = VectorCollection([(1,0), (1,2), (-1,-2)], QQ, 2)
            sage: S = VectorCollection([(1,), (-1,)], QQ, 1)
            sage: R_tensor_S = TensorOperation([R,S], operation='product')
            sage: sorted(R_tensor_S._index_map.iteritems())   # indirect doctest
            [((0, 0), 0), ((0, 1), 1), ((1, 0), 2), ((1, 1), 3), ((2, 0), 3), ((2, 1), 2)]
        """
        V_list_indices = [range(V.n_vectors()) for V in self._V]
        from sage.categories.cartesian_product import cartesian_product
        for i in cartesian_product(V_list_indices):
            self._index_map[tuple(i)] = self._init_product_vectors(i)
        self._symmetrize_indices = False
开发者ID:ProgVal,项目名称:sage,代码行数:19,代码来源:tensor_operations.py


示例20: basis

    def basis(self):
        """
        Return the basis of ``self``.

        EXAMPLES::

            sage: L = lie_algebras.Heisenberg(QQ, oo)
            sage: L.basis()
            Lazy family (basis map(i))_{i in Disjoint union of Family ({'z'},
             The Cartesian product of (Positive integers, {'p', 'q'}))}
            sage: L.basis()['z']
            z
            sage: L.basis()[(12, 'p')]
            p12
        """
        S = cartesian_product([PositiveIntegers(), ['p','q']])
        I = DisjointUnionEnumeratedSets([Set(['z']), S])
        def basis_elt(x):
            if isinstance(x, str):
                return self.monomial(x)
            return self.monomial(x[1] + str(x[0]))
        return Family(I, basis_elt, name="basis map")
开发者ID:sagemath,项目名称:sage,代码行数:22,代码来源:heisenberg.py



注:本文中的sage.categories.cartesian_product.cartesian_product函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python category.Category类代码示例发布时间:2022-05-27
下一篇:
Python maxima.eval函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap