예제 #1
0
    def __init__(self, *iters):
        """
        TESTS::

            sage: import sage.combinat.cartesian_product as cartesian_product
            sage: cp = cartesian_product.CartesianProduct_iters([1,2],[3,4]); cp
            Cartesian product of [1, 2], [3, 4]
            sage: loads(dumps(cp)) == cp
            True
        """
        self.iters = iters
        self._mrange = xmrange_iter(iters)
        CombinatorialClass.__init__(self)
예제 #2
0
    def __init__(self, *iters):
        """
        TESTS::

            sage: import sage.combinat.cartesian_product as cartesian_product
            sage: cp = cartesian_product.CartesianProduct_iters([1,2],[3,4]); cp
            Cartesian product of [1, 2], [3, 4]
            sage: loads(dumps(cp)) == cp
            True
        """
        self.iters = iters
        self._mrange = xmrange_iter(iters)
        CombinatorialClass.__init__(self)
예제 #3
0
    def __init__(self, s):
        """
        Constructs the combinatorial class of the sub multisets of s.

        EXAMPLES::

            sage: S = Subsets([1,2,2,3], submultiset=True)
            sage: Subsets([1,2,3,3], submultiset=True).cardinality()
            12
        """
        CombinatorialClass.__init__(self, category=FiniteEnumeratedSets())

        s = sorted(list(s))
        indices = list(sorted(Set([s.index(a) for a in s])))
        multiplicities = [len([a for a in s if a == s[i]]) for i in indices]

        self._s = s
        self._indices = indices
        self._multiplicities = multiplicities
예제 #4
0
    def __init__(self, s, k):
        """
        TESTS::

            sage: s = Subsets(Set([1]))
            sage: e = s.first()
            sage: isinstance(e, s.element_class)
            True

        In the following "_test_elements" is temporarily disabled
        until :class:`sage.sets.set.Set_object_enumerated` objects
        pass the category tests::

            sage: S = Subsets(3,2)
            sage: TestSuite(S).run(skip=["_test_elements"])
        """
        CombinatorialClass.__init__(self, category=FiniteEnumeratedSets())
        self.s = Set(s)
        self.k = k
예제 #5
0
    def __init__(self, s, k):
        """
        TESTS::

            sage: s = Subsets(Set([1]))
            sage: e = s.first()
            sage: isinstance(e, s.element_class)
            True

        In the following "_test_elements" is temporarily disabled
        until :class:`sage.sets.set.Set_object_enumerated` objects
        pass the category tests::

            sage: S = Subsets(3,2)
            sage: TestSuite(S).run(skip=["_test_elements"])
        """
        CombinatorialClass.__init__(self, category=FiniteEnumeratedSets())
        self.s = Set(s)
        self.k = k
예제 #6
0
    def __init__(self, s):
        """
        Constructs the combinatorial class of the sub multisets of s.

        EXAMPLES::

            sage: S = Subsets([1,2,2,3], submultiset=True)
            sage: Subsets([1,2,3,3], submultiset=True).cardinality()
            12
        """
        CombinatorialClass.__init__(self, category=FiniteEnumeratedSets())

        s = sorted(list(s))
        indices = list(sorted(Set([s.index(a) for a in s])))
        multiplicities = [len([a for a in s if a == s[i]])
                          for i in indices]

        self._s = s
        self._indices = indices
        self._multiplicities = multiplicities