Motr
M0
|
Functions | |
M0_INTERNAL uint64_t | m0_fact (uint64_t n) |
M0_INTERNAL uint32_t | m0_ncr (uint64_t n, uint64_t r) |
M0_INTERNAL int | m0_combination_index (int N, int K, int *x) |
M0_INTERNAL void | m0_combination_inverse (int cid, int N, int K, int *x) |
For a given alphabet 'A', having length 'N' containing sorted and no duplicate elements, combinations are build in lexoicographical order using Lehmer code. Then given a combination 'X' it's index can be returned. Also given a index and length of combination, combination can be returned.
For more information on this issue visit here
M0_INTERNAL int m0_combination_index | ( | int | N, |
int | K, | ||
int * | x | ||
) |
Returns combination index of 'x' in combinations of alphabet 'A'.
'N' | length of alphabet 'A' ordered elements. |
'K' | lenght of combination. |
Definition at line 52 of file combinations.c.
M0_INTERNAL void m0_combination_inverse | ( | int | cid, |
int | N, | ||
int | K, | ||
int * | x | ||
) |
Returns the combination array 'x' for a given combination index.
cid | Combination index. | |
N | Length of alphabet (total number of elements). | |
K | Length of combination (# of elements in the combination). | |
[out] | x | Indices of elements, represented by the combination. |
Definition at line 79 of file combinations.c.
M0_INTERNAL uint64_t m0_fact | ( | uint64_t | n | ) |
Factorial of n.
Definition at line 31 of file combinations.c.
M0_INTERNAL uint32_t m0_ncr | ( | uint64_t | n, |
uint64_t | r | ||
) |
The number of possible combinations that can be obtained by taking a sub-set of ‘r’ items from a larger set of ‘n’ elements.
Definition at line 38 of file combinations.c.