Product - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Iterator

  

Product

  

create the product of iterators

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

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. 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.

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

withIterator:

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

PProductPermute3,BinaryGrayCode3:

Print the first 10 iterations, along with the rank.

PrintP,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.

NumberP

48

(1)

Compute the output with rank equal to 8.

UnrankP,8

132100

(2)

Compatibility

• 

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

• 

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