Skip to content

enhanced sets and cartesian products #18290

@videlec

Description

@videlec

We implement several missing features of sets, enumerated sets and their cartesian products.

We add methods is_empty and is_finite to all sets.

We implement most of the methods for cartesian products of sets and enumerated sets (cardinality, rank/unrank, iteration).

For example, all commands below were hanging

sage: C = cartesian_product([Permutations(7), Permutations(9)])
sage: C.cardinality()
1828915200
sage: C.unrank(143872745)
([1, 5, 3, 6, 2, 4, 7], [5, 3, 2, 4, 7, 8, 9, 6, 1])
sage: C.rank(_)
143872745
sage: C.random_element()   # random
([4, 2, 6, 7, 1, 3, 5], [4, 7, 2, 8, 6, 3, 9, 5, 1])

CC: @nathanncohen @nthiery

Component: categories

Keywords: cartesian_product

Author: Vincent Delecroix

Branch: 707bf1e

Reviewer: Nicolas M. Thiéry

Issue created by migration from https://trac.sagemath.org/ticket/18290

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions