Weighted Integer Vectors

sage.combinat.integer_vector_weighted.WeightedIntegerVectors(n, weight)

Returns the combinatorial class of integer vectors of n weighted by weight.

EXAMPLES:

sage: WeightedIntegerVectors(8, [1,1,2])
Integer vectors of 8 weighted by [1, 1, 2]
sage: WeightedIntegerVectors(8, [1,1,2]).first()
[0, 0, 4]
sage: WeightedIntegerVectors(8, [1,1,2]).last()
[8, 0, 0]
sage: WeightedIntegerVectors(8, [1,1,2]).cardinality()
25
sage: WeightedIntegerVectors(8, [1,1,2]).random_element()
[1, 1, 3]
class sage.combinat.integer_vector_weighted.WeightedIntegerVectors_nweight(n, weight)

Bases: sage.combinat.combinat.CombinatorialClass

list()

TESTS:

sage: WeightedIntegerVectors(7, [2,2]).list()
[]
sage: WeightedIntegerVectors(3, [2,1,1]).list()
[[1, 0, 1], [1, 1, 0], [0, 0, 3], [0, 1, 2], [0, 2, 1], [0, 3, 0]]
sage: ivw = [ WeightedIntegerVectors(k, [1,1,1]) for k in range(11) ]
sage: iv  = [ IntegerVectors(k, 3) for k in range(11) ]
sage: all( [ sorted(iv[k].list()) == sorted(ivw[k].list()) for k in range(11) ] )
True
sage: ivw = [ WeightedIntegerVectors(k, [2,3,7]) for k in range(11) ]
sage: all( [ i.cardinality() == len(i.list()) for i in ivw] )
True

Previous topic

Integer vectors

Next topic

Restricted growth arrays

This Page