MultiSeq - Maple Help

Iterator

 MultiSeq
 generate multiple sequences

 Calling Sequence MultiSeq(rngs, opts)

Parameters

 rngs - specifies the start and finish values of the counters opts - (optional) equation(s) of the form option = value; specify options for the MultiSeq command

Options

 • compile = truefalse
 True means compile the iterator. The default is true.
 • rank = nonnegint
 Specify the starting rank of the iterator. The default is one. Passing a value greater than one causes the iterator to skip the lower ranks; this can be useful when parallelizing iterators. The starting rank reverts to one when the iterator is reset, reused, or copied.

Description

 • The MultiSeq command returns an iterator that advances the elements of an Array as if they were the counters of nested loops.
 • The rngs parameter specifies the range of each counter. It can be
 – a range of lists of integers, e.g., [1,3] .. [4,1]
 – a range of one-dimensional rtables of integers, e.g., <1,3> .. <4,1>,
 – a list of ranges of integer, e.g., [1..4, 3..1],
 – a one-dimensional rtable of integers, e.g., <1..4, 3..1>.
 • At each iteration, the first counter is advanced. If the i-th counter is at its finish value when it is advanced, it is assigned its start value and the i+1 counter is advanced.
 • The iteration ends when all counters reach their finish values.
 • If the finish value of a counter is less than its start value, it is decremented rather than incremented when advanced.

Methods

In addition to the common iterator methods, this iterator object has the following methods. The self parameter is the iterator object.

 • Number(self): return the number of iterations required to step through the iterator, assuming it started at rank one.
 • Rank(self,L): return the rank of the current iteration. Optionally pass L, a list or one-dimensional rtable, and return its rank.
 • Unrank(self,rnk): return a one-dimensional Array corresponding to the iterator output with rank rnk.

Examples

 > $\mathrm{with}\left(\mathrm{Iterator}\right):$

Use a range of lists to specify the ranges for the counters.

 > $M≔\mathrm{MultiSeq}\left(\left[1,3\right]..\left[4,1\right]\right):$
 > $\mathrm{Print}\left(M,'\mathrm{showrank}'\right):$
 1: 1 3  2: 2 3  3: 3 3  4: 4 3  5: 1 2  6: 2 2  7: 3 2  8: 4 2  9: 1 1 10: 2 1 11: 3 1 12: 4 1

Compute the number of iterations.

 > $\mathrm{Number}\left(M\right)$
 ${12}$ (1)

Return the element with rank equal to 4.

 > $\mathrm{Unrank}\left(M,4\right)$
 $\left[\begin{array}{cc}{4}& {3}\end{array}\right]$ (2)

 > $N≔\mathrm{Object}\left(M,\mathrm{rank}=4\right):$
 > $\mathrm{Print}\left(N,'\mathrm{showrank}'\right)$
 4: 4 3  5: 1 2  6: 2 2  7: 3 2  8: 4 2  9: 1 1 10: 2 1 11: 3 1 12: 4 1

Use a list of ranges to specify the ranges.

 > $M≔\mathrm{MultiSeq}\left(\left[1..4,3..1\right]\right):$
 > $\mathrm{Print}\left(M,'\mathrm{showrank}'\right):$
 1: 1 3  2: 2 3  3: 3 3  4: 4 3  5: 1 2  6: 2 2  7: 3 2  8: 4 2  9: 1 1 10: 2 1 11: 3 1 12: 4 1

Compatibility

 • The Iterator[MultiSeq] command was introduced in Maple 2022.