Example #1
0
    def direct_sum(self, other):
        """
        Return the direct sum.

        INPUT:

        - ``other`` -- a filtered vector space.

        OUTPUT:

        The direct sum as a filtered vector space.

        EXAMPLES::

            sage: V = FilteredVectorSpace(2, 0)
            sage: W = FilteredVectorSpace({0:[(1,-1),(2,1)], 1:[(1,1)]})
            sage: V.direct_sum(W)
            QQ^4 >= QQ^1 >= 0
            sage: V + W    # syntactic sugar
            QQ^4 >= QQ^1 >= 0
            sage: V + V == FilteredVectorSpace(4, 0)
            True

            sage: W = FilteredVectorSpace([(1,-1),(2,1)], {1:[0,1], 2:[1]})
            sage: V + W
            QQ^4 >= QQ^2 >= QQ^1 >= 0

        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^2 >= 0
        """
        from sage.structure.element import get_coercion_model
        base_ring = get_coercion_model().common_parent(self.base_ring(),
                                                       other.base_ring())
        # construct the generators
        self_gens, self_filt = self.presentation()
        other_gens, other_filt = other.presentation()
        generators = \
            [ list(v) + [base_ring.zero()]*other.dimension() for v in self_gens  ] + \
            [ [base_ring.zero()]*self.dimension() + list(v)  for v in other_gens ]

        # construct the filtration dictionary
        def join_indices(self_indices, other_indices):
            self_indices = tuple(self_indices)
            other_indices = tuple(i + len(self_gens) for i in other_indices)
            return self_indices + other_indices

        filtration = dict()
        self_indices = set()
        other_indices = set()
        for deg in reversed(uniq(self_filt.keys() + other_filt.keys())):
            self_indices.update(self_filt.get(deg, []))
            other_indices.update(other_filt.get(deg, []))
            gens = join_indices(self_indices, other_indices)
            filtration[deg] = gens
        return FilteredVectorSpace(generators, filtration, base_ring=base_ring)
Example #2
0
    def direct_sum(self, other):
        """
        Return the direct sum.

        INPUT:

        - ``other`` -- a filtered vector space.

        OUTPUT:

        The direct sum as a filtered vector space.

        EXAMPLES::

            sage: V = FilteredVectorSpace(2, 0)
            sage: W = FilteredVectorSpace({0:[(1,-1),(2,1)], 1:[(1,1)]})
            sage: V.direct_sum(W)
            QQ^4 >= QQ^1 >= 0
            sage: V + W    # syntactic sugar
            QQ^4 >= QQ^1 >= 0
            sage: V + V == FilteredVectorSpace(4, 0)
            True

            sage: W = FilteredVectorSpace([(1,-1),(2,1)], {1:[0,1], 2:[1]})
            sage: V + W
            QQ^4 >= QQ^2 >= QQ^1 >= 0

        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^2 >= 0
        """
        from sage.structure.element import get_coercion_model
        base_ring = get_coercion_model().common_parent(self.base_ring(), other.base_ring())
        # construct the generators
        self_gens, self_filt = self.presentation()
        other_gens, other_filt = other.presentation()
        generators = \
            [ list(v) + [base_ring.zero()]*other.dimension() for v in self_gens  ] + \
            [ [base_ring.zero()]*self.dimension() + list(v)  for v in other_gens ]
        # construct the filtration dictionary
        def join_indices(self_indices, other_indices):
            self_indices = tuple(self_indices)
            other_indices = tuple(i + len(self_gens) for i in other_indices)
            return self_indices + other_indices
        filtration = dict()
        self_indices = set()
        other_indices = set()
        for deg in reversed(uniq(self_filt.keys() + other_filt.keys())):
            self_indices.update(self_filt.get(deg, []))
            other_indices.update(other_filt.get(deg, []))
            gens = join_indices(self_indices, other_indices)
            filtration[deg] = gens
        return FilteredVectorSpace(generators, filtration, base_ring=base_ring)
Example #3
0
    def add_horizontal_border_strip_star(self, h):
        r"""
        Return a list of super partitions that differ from ``self``
        by a horizontal strip.

        The notion of horizontal strip comes from the Pieri rule for the
        Schur-star basis of symmetric functions in super space (see
        Theorem 7 from [JL2016]_).

        INPUT:

        - ``h`` -- number of cells in the horizontal strip

        OUPUT:

        - a list of super partitions

        EXAMPLES::

            sage: SuperPartition([[4,1],[3]]).add_horizontal_border_strip_star(3)
            [[4, 1; 3, 3],
             [4, 1; 4, 2],
             [3, 1; 5, 2],
             [4, 1; 5, 1],
             [3, 1; 6, 1],
             [4, 0; 4, 3],
             [3, 0; 5, 3],
             [4, 0; 5, 2],
             [3, 0; 6, 2],
             [4, 1; 6],
             [3, 1; 7]]
            sage: SuperPartition([[2,1],[3]]).add_horizontal_border_strip_star(2)
            [[2, 1; 3, 2], [2, 1; 4, 1], [2, 0; 3, 3], [2, 0; 4, 2], [2, 1; 5]]
        """
        sp1, circ_list = self.to_circled_diagram()
        nsp = [list(la) + [0] for la in sp1.add_horizontal_border_strip(h)]
        sp1 = sp1 + [0]
        out = []
        for elt in nsp:
            row_changed = [row1 - row2 for row1, row2 in zip(elt, sp1)]
            new_sp = [
                elt,
                [(i[0] + 1, elt[i[0] + 1])
                 for i in circ_list if row_changed[i[0]] != 0]
                # TODO: Check that this is not suppose to be
                #   a tuple of size 1
                + [(i) for i in circ_list if row_changed[i[0]] == 0]
            ]
            if len(uniq([k for (j, k) in new_sp[1]])) == len(new_sp[1]):
                out += [SuperPartition.from_circled_diagram(*new_sp)]
        return out
Example #4
0
def all_attributes(compl_dct):
    varname = compl_dct["var-base-name"]
    try:
        regexp = re.compile("^[ a-zA-Z0-9._\\[\\]]+$")
        if regexp.match(varname) is None:
            return []
        if varname in interfaces:
            ls = ip.ev('dir(%s)' % (varname, ))
        else:
            ls = _completions_attributes(preparse(varname))
            ls.extend(ip.ev('dir(%s)' % (preparse(varname), )))
            ls = list(sorted(uniq(ls)))
        return ls
    except:
        return []
Example #5
0
def all_attributes(compl_dct):
    varname = compl_dct["var-base-name"]
    try:
        regexp = re.compile("^[ a-zA-Z0-9._\\[\\]]+$")
        if regexp.match(varname) is None:
            return []
        if varname in interfaces:
            ls = ip.ev('dir(%s)' % (varname,))
        else:
            ls = _completions_attributes(preparse(varname))
            ls.extend(ip.ev('dir(%s)' % (preparse(varname),)))
            ls = list(sorted(uniq(ls)))
        return ls
    except:
        return []
Example #6
0
    def add_horizontal_border_strip_star(self, h):
        r"""
        Return a list of super partitions that differ from ``self``
        by a horizontal strip.

        The notion of horizontal strip comes from the Pieri rule for the
        Schur-star basis of symmetric functions in super space (see
        Theorem 7 from [JL2016]_).

        INPUT:

        - ``h`` -- number of cells in the horizontal strip

        OUPUT:

        - a list of super partitions

        EXAMPLES::

            sage: SuperPartition([[4,1],[3]]).add_horizontal_border_strip_star(3)
            [[4, 1; 3, 3],
             [4, 1; 4, 2],
             [3, 1; 5, 2],
             [4, 1; 5, 1],
             [3, 1; 6, 1],
             [4, 0; 4, 3],
             [3, 0; 5, 3],
             [4, 0; 5, 2],
             [3, 0; 6, 2],
             [4, 1; 6],
             [3, 1; 7]]
            sage: SuperPartition([[2,1],[3]]).add_horizontal_border_strip_star(2)
            [[2, 1; 3, 2], [2, 1; 4, 1], [2, 0; 3, 3], [2, 0; 4, 2], [2, 1; 5]]
        """
        sp1, circ_list = self.to_circled_diagram()
        nsp = [list(la) + [0] for la in sp1.add_horizontal_border_strip(h)]
        sp1 = sp1 + [0]
        out = []
        for elt in nsp:
            row_changed = [row1-row2 for row1,row2 in zip(elt,sp1)]
            new_sp = [elt, [(i[0]+1, elt[i[0]+1]) for i in circ_list
                            if row_changed[i[0]] != 0]
                            # TODO: Check that this is not suppose to be
                            #   a tuple of size 1
                           + [(i) for i in circ_list if row_changed[i[0]] == 0]]
            if len(uniq([k for (j,k) in new_sp[1]])) == len(new_sp[1]):
                out += [SuperPartition.from_circled_diagram(*new_sp)]
        return out
Example #7
0
    def base_rays(self, fiber, points):
        """
        Return the primitive lattice vectors that generate the
        direction given by the base projection of points.

        INPUT:

        - ``fiber`` -- a sub-lattice polytope defining the
          :meth:`base_projection`.

        - ``points`` -- the points to project to the base.

        OUTPUT:

        A tuple of primitive `\ZZ`-vectors.

        EXAMPLES::

            sage: from sage.geometry.polyhedron.ppl_lattice_polytope import LatticePolytope_PPL
            sage: poly = LatticePolytope_PPL((-9,-6,-1,-1),(0,0,0,1),(0,0,1,0),(0,1,0,0),(1,0,0,0))
            sage: fiber = poly.fibration_generator(2).next()
            sage: poly.base_rays(fiber, poly.integral_points_not_interior_to_facets())
            ((-1, -1), (0, 1), (1, 0))

            sage: p = LatticePolytope_PPL((1,0),(1,2),(-1,0))
            sage: f = LatticePolytope_PPL((1,0),(-1,0))
            sage: p.base_rays(f, p.integral_points())
            ((1),)
        """
        quo = self.base_projection(fiber)
        vertices = []
        for p in points:
            v = vector(ZZ,quo(p))
            if v.is_zero():
                continue
            d =  GCD_list(v.list())
            if d>1:
                for i in range(0,v.degree()):
                    v[i] /= d
            v.set_immutable()
            vertices.append(v)
        return tuple(uniq(vertices))
Example #8
0
def construct_from_generators(filtration, base_ring, check):
    """
    Construct a filtered vector space.

    INPUT:

    - ``filtration`` -- a dictionary of filtration steps. Each
      filtration step is a pair consisting of an integer degree and a
      list/tuple/iterable of vector space generators. The integer
      ``degree`` stipulates that all filtration steps of degree higher
      or equal than ``degree`` (up to the next filtration step) are
      said subspace.

    EXAMPLES::

        sage: from sage.modules.filtered_vector_space import construct_from_generators
        sage: r = [1, 2]
        sage: construct_from_generators({1:[r]}, QQ, True)
        QQ^1 >= 0 in QQ^2
    """
    def normalize_gen(v):
        return tuple(map(base_ring, v))

    # convert generator notation to generator+indices
    if len(filtration) == 0:
        raise ValueError(
            'you need to specify at least one ray to deduce the dimension')
    generators = []
    for gens in filtration.values():
        generators += map(normalize_gen, gens)
    generators = tuple(uniq(generators))

    # normalize filtration data
    normalized = dict()
    for deg, gens_deg in filtration.iteritems():
        indices = [generators.index(normalize_gen(v)) for v in gens_deg]
        normalized[deg] = tuple(indices)
    return construct_from_generators_indices(generators, normalized, base_ring,
                                             check)
Example #9
0
def construct_from_generators(filtration, base_ring, check):
    """
    Construct a filtered vector space.

    INPUT:

    - ``filtration`` -- a dictionary of filtration steps. Each
      filtration step is a pair consisting of an integer degree and a
      list/tuple/iterable of vector space generators. The integer
      ``degree`` stipulates that all filtration steps of degree higher
      or equal than ``degree`` (up to the next filtration step) are
      said subspace.

    EXAMPLES::

        sage: from sage.modules.filtered_vector_space import construct_from_generators
        sage: r = [1, 2]
        sage: construct_from_generators({1:[r]}, QQ, True)
        QQ^1 >= 0 in QQ^2
    """
    def normalize_gen(v):
        return tuple(map(base_ring, v))

    # convert generator notation to generator+indices
    if len(filtration) == 0:
        raise ValueError('you need to specify at least one ray to deduce the dimension')
    generators = []
    for gens in filtration.values():
        generators += map(normalize_gen, gens)
    generators = tuple(uniq(generators))

    # normalize filtration data
    normalized = dict()
    for deg, gens_deg in iteritems(filtration):
        indices = [generators.index(normalize_gen(v)) for v in gens_deg]
        normalized[deg] = tuple(indices)
    return construct_from_generators_indices(generators, normalized, base_ring, check)