Iterator/WeightedComposition - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Iterator/WeightedComposition

Iterator

  

WeightedComposition

  

generate weighted compositions that sum to a constant

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

WeightedComposition(W, T, opts)

Parameters

W

-

{list,Vector,1-dimensional Array}(posint); weights of components of each composition, in nondecreasing order

T

-

nonnegint; weighted sum of each composition

opts

-

(optional) equation(s) of the form option = value; specify options for the WeightedComposition command

Options

• 

compile = truefalse

  

True means compile the iterator. The default is true.

Description

• 

The WeightedComposition command returns an iterator that generates all weighted compositions of T with weights W. The order in which the weighted compositions are generated is co-lexicographic. (That is, lexicographic in the reverse of the weighted compositions.)

• 

A weighted composition is a sequence of nonnegative integers, r1,,rn, such that T=k=1nWkrk with n=numelemsW. Unlike regular compositions, but like bounded compositions, a weighted composition is understood to be ordered: rk corresponds to Wk.

Examples

withIterator:

BWeightedComposition1,2,4,8:

PrintB,showrank:

             1: 8 0 0
             2: 6 1 0
             3: 4 2 0
             4: 2 3 0
             5: 0 4 0
             6: 4 0 1
             7: 2 1 1
             8: 0 2 1
             9: 0 0 2

Compatibility

• 

The Iterator[WeightedComposition] command was introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

Iterator

Iterator[BoundedComposition]

Iterator[Composition]