def __init__(self, *iters): """ TESTS:: sage: from sage.combinat.cartesian_product import CartesianProduct_iters sage: cp = CartesianProduct_iters([1,2],[3,4]); cp Cartesian product of [1, 2], [3, 4] sage: loads(dumps(cp)) == cp True sage: TestSuite(cp).run(skip='_test_an_element') Check that :trac:`24558` is fixed:: sage: from sage.combinat.cartesian_product import CartesianProduct_iters sage: from sage.sets.set_from_iterator import EnumeratedSetFromIterator sage: I = EnumeratedSetFromIterator(Integers) sage: CartesianProduct_iters(I, I) Cartesian product of {0, 1, -1, 2, -2, ...}, {0, 1, -1, 2, -2, ...} """ self.iters = iters self._mrange = xmrange_iter(iters) category = EnumeratedSets() try: category = category.Finite() if self.is_finite() else category.Infinite() except ValueError: # Unable to determine if it is finite or not pass def iterfunc(): # we can not use self.__iterate__ directly because # that leads to an infinite recursion in __eq__ return self.__iterate__() name = "Cartesian product of " + ", ".join(map(str, self.iters)) EnumeratedSetFromIterator.__init__(self, iterfunc, name=name, category=category, cache=False)
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)
def residues(self): """ Returns a iterator through a complete list of residues modulo this integral ideal. An error is raised if this fractional ideal is not integral. EXAMPLES:: sage: K.<a, w> = NumberFieldTower([x^2 - 3, x^2 + x + 1]) sage: I = K.ideal(6, -w*a - w + 4) sage: list(I.residues())[:5] [(25/3*w - 1/3)*a + 22*w + 1, (16/3*w - 1/3)*a + 13*w, (7/3*w - 1/3)*a + 4*w - 1, (-2/3*w - 1/3)*a - 5*w - 2, (-11/3*w - 1/3)*a - 14*w - 3] """ abs_ideal = self.absolute_ideal() from_abs = abs_ideal.number_field().structure()[0] from sage.misc.mrange import xmrange_iter abs_residues = abs_ideal.residues() return xmrange_iter(abs_residues.iter_list, lambda c: from_abs(abs_residues.typ(c)))