Package sage :: Package combinat :: Module integer_vector
[hide private]
[frames] | no frames]

Module integer_vector

source code


Integer vectors



Classes [hide private]
  IntegerVectors_all
  IntegerVectors_nk
  IntegerVectors_nkconstraints
  IntegerVectors_nconstraints
  IntegerVectors_nnondescents
The combinatorial class of integer vectors v graded by two parameters: - n: the sum of the parts of v - comp: the non descents composition of v In other words: the length of v equals c[1]+...+c[k], and v is descreasing in the consecutive blocs of length c[1], ..., c[k] Those are the integer vectors of sum n which are lexicographically maximal (for the natural left->right reading) in their orbit by the young subgroup S_{c_1} x \dots x S_{c_k}.
Functions [hide private]
 
_default_function(l, default, i)
EXAMPLES:...
source code
 
list2func(l, default=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)
Given a list l, return a function that takes in a value i and return l[i-1].
source code
 
constant_func(i)
Returns the constant function i.
source code
 
IntegerVectors(n=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a..., k=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a..., **kwargs)
Returns the combinatorial class of integer vectors.
source code
Variables [hide private]
  infinity = +Infinity
Function Details [hide private]

_default_function(l, default, i)

source code 

EXAMPLES:
    sage: from sage.combinat.integer_vector import _default_function
    sage: import functools
    sage: f = functools.partial(_default_function, [1,2,3], 99)
    sage: f(0)
    99
    sage: f(1)
    1
    sage: f(2)
    2
    sage: f(3)
    3
    sage: f(4)
    99

list2func(l, default=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)

source code 

Given a list l, return a function that takes in a value
i and return l[i-1].  If default is not None, then the function
will return the default value for out of range i's.

EXAMPLES:
    sage: f = sage.combinat.integer_vector.list2func([1,2,3])
    sage: f(1)
    1
    sage: f(2)
    2
    sage: f(3)
    3
    sage: f(4)
    Traceback (most recent call last):
    ...
    IndexError: list index out of range

    sage: f = sage.combinat.integer_vector.list2func([1,2,3], 0)
    sage: f(3)
    3
    sage: f(4)
    0

constant_func(i)

source code 

Returns the constant function i.

EXAMPLES:
    sage: f = sage.combinat.integer_vector.constant_func(3)
    sage: f(-1)
    3
    sage: f('asf')
    3

IntegerVectors(n=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a..., k=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a..., **kwargs)

source code 

Returns the combinatorial class of integer vectors.

EXAMPLES:
  If n is not specified, it returns the class of all
  integer vectors.
  
    sage: IntegerVectors()
    Integer vectors
    sage: [] in IntegerVectors()
    True
    sage: [1,2,1] in IntegerVectors()
    True
    sage: [1, 0, 0] in IntegerVectors()
    True

  If n is specified, then it returns the class of all
  integer vectors which sum to n.
  
    sage: IV3 = IntegerVectors(3); IV3
    Integer vectors that sum to 3

  Note that trailing zeros are ignored so that [3, 0]
  does not show up in the following list (since [3] does)
  
    sage: IntegerVectors(3, max_length=2).list()
    [[3], [2, 1], [1, 2], [0, 3]]

  If n and k are both specified, then it returns the class
  of integer vectors that sum to n and are of length k.

    sage: IV53 = IntegerVectors(5,3); IV53
    Integer vectors of length 3 that sum to 5
    sage: IV53.count()
    21
    sage: IV53.first()
    [5, 0, 0]
    sage: IV53.last()
    [0, 0, 5]
    sage: IV53.random_element()
    [4, 0, 1]