Iterator
Product
create the product of iterators
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Product(objects, opts)
objects
-
sequence of iterators
opts
(optional) equation(s) of the form option = value; specify options for the Product command
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.
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.
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.
with⁡Iterator:
Create an iterator that combines the permutations of the integers from 1 to 3 with three bit binary Gray code.
P≔Product⁡Permute⁡3,BinaryGrayCode⁡3:
Print the first 10 iterations, along with the rank.
Print⁡P,10,showrank:
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.
Number⁡P
48
Compute the output with rank equal to 8.
Unrank⁡P,8
132100
The Iterator[Product] command was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
Download Help Document