Vector Partitions¶
AUTHORS:
- Amritanshu Prasad (2013): Initial version 
- Shriya M (2022): Added new parameters such as - distinct,- partsand- is_repeatable
- sage.combinat.vector_partition.IntegerVectorsIterator(vect, min=None)[source]¶
- Return an iterator over the list of integer vectors which are componentwise less than or equal to - vect, and lexicographically greater than or equal to- min.- INPUT: - vect– list of nonnegative integers
- min– list of nonnegative integers dominated elementwise by- vect
 - OUTPUT: - A list in lexicographic order of all integer vectors (as lists) which are dominated elementwise by - vectand are greater than or equal to- minin lexicographic order.- EXAMPLES: - sage: from sage.combinat.vector_partition import IntegerVectorsIterator sage: list(IntegerVectorsIterator([1, 1])) [[0, 0], [0, 1], [1, 0], [1, 1]] sage: list(IntegerVectorsIterator([1, 1], min = [1, 0])) [[1, 0], [1, 1]] - >>> from sage.all import * >>> from sage.combinat.vector_partition import IntegerVectorsIterator >>> list(IntegerVectorsIterator([Integer(1), Integer(1)])) [[0, 0], [0, 1], [1, 0], [1, 1]] >>> list(IntegerVectorsIterator([Integer(1), Integer(1)], min = [Integer(1), Integer(0)])) [[1, 0], [1, 1]] 
- class sage.combinat.vector_partition.VectorPartition(parent, vecpar)[source]¶
- Bases: - CombinatorialElement- A vector partition is a multiset of integer vectors. - partition_at_vertex(i)[source]¶
- Return the partition obtained by sorting the - i-th elements of the vectors in the vector partition.- EXAMPLES: - sage: V = VectorPartition([[1, 2, 1], [2, 4, 1]]) sage: V.partition_at_vertex(1) [4, 2] - >>> from sage.all import * >>> V = VectorPartition([[Integer(1), Integer(2), Integer(1)], [Integer(2), Integer(4), Integer(1)]]) >>> V.partition_at_vertex(Integer(1)) [4, 2] 
 
- class sage.combinat.vector_partition.VectorPartitions(vec, min=None, parts=None, distinct=False, is_repeatable=None)[source]¶
- Bases: - UniqueRepresentation,- Parent- Class of all vector partitions of - vecwith all parts greater than or equal to- minin lexicographic order, with parts from- parts.- A vector partition of - vecis a list of vectors with nonnegative integer entries whose sum is- vec.- INPUT: - vec– integer vector
- min– integer vector dominated elementwise by- vec
- parts– finite list of possible parts
- distinct– boolean, set to- Trueif only vector partitions with distinct parts are enumerated
- is_repeatable– boolean function on- partswhich gives- Truein parts that can be repeated
 - EXAMPLES: - If - minis not specified, then the class of all vector partitions of- vecis created:- sage: VP = VectorPartitions([2, 2]) sage: for vecpar in VP: ....: print(vecpar) [[0, 1], [0, 1], [1, 0], [1, 0]] [[0, 1], [0, 1], [2, 0]] [[0, 1], [1, 0], [1, 1]] [[0, 1], [2, 1]] [[0, 2], [1, 0], [1, 0]] [[0, 2], [2, 0]] [[1, 0], [1, 2]] [[1, 1], [1, 1]] [[2, 2]] - >>> from sage.all import * >>> VP = VectorPartitions([Integer(2), Integer(2)]) >>> for vecpar in VP: ... print(vecpar) [[0, 1], [0, 1], [1, 0], [1, 0]] [[0, 1], [0, 1], [2, 0]] [[0, 1], [1, 0], [1, 1]] [[0, 1], [2, 1]] [[0, 2], [1, 0], [1, 0]] [[0, 2], [2, 0]] [[1, 0], [1, 2]] [[1, 1], [1, 1]] [[2, 2]] - If - distinctis set to be True, then distinct part partitions are created:- sage: VP = VectorPartitions([2,2], distinct = True) sage: list(VP) [[[0, 1], [1, 0], [1, 1]], [[0, 1], [2, 1]], [[0, 2], [2, 0]], [[1, 0], [1, 2]], [[2, 2]]] - >>> from sage.all import * >>> VP = VectorPartitions([Integer(2),Integer(2)], distinct = True) >>> list(VP) [[[0, 1], [1, 0], [1, 1]], [[0, 1], [2, 1]], [[0, 2], [2, 0]], [[1, 0], [1, 2]], [[2, 2]]] - If - minis specified, then the class consists of only those vector partitions whose parts are all greater than or equal to- minin lexicographic order:- sage: VP = VectorPartitions([2, 2], min = [1, 0]) sage: for vecpar in VP: ....: print(vecpar) [[1, 0], [1, 2]] [[1, 1], [1, 1]] [[2, 2]] sage: VP = VectorPartitions([2, 2], min = [1, 0], distinct = True) sage: for vecpar in VP: ....: print(vecpar) [[1, 0], [1, 2]] [[2, 2]] - >>> from sage.all import * >>> VP = VectorPartitions([Integer(2), Integer(2)], min = [Integer(1), Integer(0)]) >>> for vecpar in VP: ... print(vecpar) [[1, 0], [1, 2]] [[1, 1], [1, 1]] [[2, 2]] >>> VP = VectorPartitions([Integer(2), Integer(2)], min = [Integer(1), Integer(0)], distinct = True) >>> for vecpar in VP: ... print(vecpar) [[1, 0], [1, 2]] [[2, 2]] - If - partsis specified, then the class consists only of those vector partitions whose parts are from- parts:- sage: Vec_Par = VectorPartitions([2,2], parts=[[0,1],[1,0],[1,1]]) sage: list(Vec_Par) [[[0, 1], [0, 1], [1, 0], [1, 0]], [[0, 1], [1, 0], [1, 1]], [[1, 1], [1, 1]]] - >>> from sage.all import * >>> Vec_Par = VectorPartitions([Integer(2),Integer(2)], parts=[[Integer(0),Integer(1)],[Integer(1),Integer(0)],[Integer(1),Integer(1)]]) >>> list(Vec_Par) [[[0, 1], [0, 1], [1, 0], [1, 0]], [[0, 1], [1, 0], [1, 1]], [[1, 1], [1, 1]]] - If - is_repeatableis specified, then the parts which satisfy the boolean function- is_repeatableare allowed to be repeated:- sage: Vector_Partitions = VectorPartitions([2,2], parts=[[0,1],[1,0],[1,1]], is_repeatable=lambda vec: sum(vec)%2!=0) sage: list(Vector_Partitions) [[[0, 1], [0, 1], [1, 0], [1, 0]], [[0, 1], [1, 0], [1, 1]]] - >>> from sage.all import * >>> Vector_Partitions = VectorPartitions([Integer(2),Integer(2)], parts=[[Integer(0),Integer(1)],[Integer(1),Integer(0)],[Integer(1),Integer(1)]], is_repeatable=lambda vec: sum(vec)%Integer(2)!=Integer(0)) >>> list(Vector_Partitions) [[[0, 1], [0, 1], [1, 0], [1, 0]], [[0, 1], [1, 0], [1, 1]]] - Element[source]¶
- alias of - VectorPartition
 
- sage.combinat.vector_partition.find_min(vect)[source]¶
- Return a string of - 0’s with one- 1at the location where the list- vecthas its last entry which is not equal to- 0.- INPUT: - vec– list of integers
 - OUTPUT: - A list of the same length with - 0’s everywhere, except for a- 1at the last position where- vechas an entry not equal to- 0.- EXAMPLES: - sage: from sage.combinat.vector_partition import find_min sage: find_min([2, 1]) [0, 1] sage: find_min([2, 1, 0]) [0, 1, 0] - >>> from sage.all import * >>> from sage.combinat.vector_partition import find_min >>> find_min([Integer(2), Integer(1)]) [0, 1] >>> find_min([Integer(2), Integer(1), Integer(0)]) [0, 1, 0]