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

 OrdinaryToReflectedGray
 convert ordinary mixed-radix tuple to reflected Gray code

 Calling Sequence OrdinaryToReflectedGray(b,m)

Parameters

 b - {list,rtable}; tuple m - {list,rtable}; radices

Description

 • OrdinaryToReflectedGray converts an ordinary mixed-radix tuple to the mixed-radix reflected Gray code tuple of the same rank.
 • The b parameter is the ordinary mixed-radix tuple. It is a list or one-dimensional rtable of nonnegative integers. The first element is the low-order element.
 • The m parameter is the radices. It is a list or one-dimensional rtable of positive integers.

Examples

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

Compare, by rank, the ordinary mixed-radix tuples with the mixed-radix Gray codes.

 > $\mathrm{radices}≔\left[4,3,2\right]:$
 > $M≔\mathrm{Iterator}:-\mathrm{MixedRadixTuples}\left(\mathrm{radices}\right):$
 > $G≔\mathrm{Iterator}:-\mathrm{MixedRadixGrayCode}\left(\mathrm{radices}\right):$
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}M\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}g≔\mathrm{OrdinaryToReflectedGray}\left(b,\mathrm{radices}\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{printf}\left("%2d : %d : %d : %2d\n",\mathrm{Rank}\left(M\right),b,g,\mathrm{Rank}\left(G,g\right)\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$
 1 : 0 0 0 : 0 0 0 :  1  2 : 1 0 0 : 1 0 0 :  2  3 : 2 0 0 : 2 0 0 :  3  4 : 3 0 0 : 3 0 0 :  4  5 : 0 1 0 : 3 1 0 :  5  6 : 1 1 0 : 2 1 0 :  6  7 : 2 1 0 : 1 1 0 :  7  8 : 3 1 0 : 0 1 0 :  8  9 : 0 2 0 : 0 2 0 :  9 10 : 1 2 0 : 1 2 0 : 10 11 : 2 2 0 : 2 2 0 : 11 12 : 3 2 0 : 3 2 0 : 12 13 : 0 0 1 : 3 2 1 : 13 14 : 1 0 1 : 2 2 1 : 14 15 : 2 0 1 : 1 2 1 : 15 16 : 3 0 1 : 0 2 1 : 16 17 : 0 1 1 : 0 1 1 : 17 18 : 1 1 1 : 1 1 1 : 18 19 : 2 1 1 : 2 1 1 : 19 20 : 3 1 1 : 3 1 1 : 20 21 : 0 2 1 : 3 0 1 : 21 22 : 1 2 1 : 2 0 1 : 22 23 : 2 2 1 : 1 0 1 : 23 24 : 3 2 1 : 0 0 1 : 24

References

 Knuth, Donald Ervin. The Art of Computer Programming, volume 4, fascicle 2; generating all tuples and permutations, sec. 7.2.1.1, generating all n-tuples, p. 19, eq. 50.

Compatibility

 • The Iterator[MixedRadix][OrdinaryToReflectedGray] command was introduced in Maple 2016.
 • For more information on Maple 2016 changes, see Updates in Maple 2016.