porepy.utils.permutations module
Utility function for permutation of numbers.
- multinary_permutations(base, length)[source]
Define a generator over all numbers of a certain length for a number system with a specified base.
- For details on the decomposition into an arbitrary base see
http://math.stackexchange.com/questions/111150/changing-a-number-between-arbitrary-bases
Note that the generator will loop over base**length combinations.
Examples
Construct the numbers [00] to [11] in binary numbers >>> multinary_permutations(2, 2) [array([ 0., 0.]), array([ 1., 0.]), array([ 0., 1.]), array([ 1., 1.])]
Construct the numbers from 0 to 99 (permuted) in the decimal number system. >>> it = multinary_permutation(10, 2)