Product - Maple Help

Iterator

 Product
 create the product of iterators

 Calling Sequence Product(objects, opts)

Parameters

 objects - sequence of iterators opts - (optional) equation(s) of the form option = value; specify options for the Product 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. The starting rank reverts to one when the iterator is reset, reused, or copied.

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.

Description

 • The Product command returns an iterator that is the direct product of a sequence of iterators. The output of the created iterator is a one-dimensional Array that concatenates the output of each component iterator. Each component iterator advances when the preceding iterator resets. The first iterator advances with each iteration.

Examples

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

Create an iterator that combines the permutations of the integers from 1 to 3 with three bit binary Gray code.

 > $P≔\mathrm{Product}\left(\mathrm{Permute}\left(3\right),\mathrm{BinaryGrayCode}\left(3\right)\right):$

Print the first 10 iterations, along with the rank.

 > $\mathrm{Print}\left(P,10,'\mathrm{showrank}'\right):$
 1: 1 2 3 0 0 0  2: 1 3 2 0 0 0  3: 2 1 3 0 0 0  4: 2 3 1 0 0 0  5: 3 1 2 0 0 0  6: 3 2 1 0 0 0  7: 1 2 3 1 0 0  8: 1 3 2 1 0 0  9: 2 1 3 1 0 0 10: 2 3 1 1 0 0

Compute the number of iterations.

 > $\mathrm{Number}\left(P\right)$
 ${48}$ (1)

Compute the output with rank equal to 8.

 > $\mathrm{Unrank}\left(P,8\right)$
 $\left[\begin{array}{cccccc}{1}& {3}& {2}& {1}& {0}& {0}\end{array}\right]$ (2)

Compatibility

 • The Iterator[Product] command was introduced in Maple 2016.