Skip to content

Commit c00cae3

Browse files
committed
readme updated. product APIs refactored
1 parent f6e65b0 commit c00cae3

File tree

19 files changed

+862
-918
lines changed

19 files changed

+862
-918
lines changed

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,3 @@ Add the following section to your `pom.xml` file.
3131
4. [Cartesian Product: 4 different types of products](docs/products/README.md)
3232
5. [Ranking of permutations & combinations: 7 different types of rankings](docs/ranking/README.md)
3333
6. [Number system algorithms: 3 different types for combinatorics](docs/numbersystem/README.md)
34-
35-
[Home](../../README.md)
36-
    |    
37-
[Permutation Generators](../permutations/README.md)
38-
    |    
39-
[Combination Generators](../combinations/README.md)
40-
    |    
41-
[Set/Subset Generators](../sets/sets.md)
42-
    |    
43-
[Cartesian Product Generators](../products/README.md)
44-
    |    
45-
[Math Functions](../calculator/README.md)
46-
    |    
47-
[Ranking Algorithms](../ranking/README.md)
48-
    |    
49-
[Number System Algorithms](../numbersystem/README.md)

docs/calculator/README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
[Home](../../README.md)
2-
    |    
3-
[Permutation Generators](../permutations/README.md)
4-
    |    
5-
[Combination Generators](../combinations/README.md)
6-
    |    
7-
[Set/Subset Generators](../sets/sets.md)
8-
    |    
9-
[Cartesian Product Generators](../products/README.md)
10-
    |    
11-
[Math Functions](../calculator/README.md)
12-
    |    
13-
[Ranking Algorithms](../ranking/README.md)
1+
[Home](../../README.md)
2+
</br>[Permutation Generators](../permutations/README.md)
3+
</br>[Combination Generators](../combinations/README.md)
4+
</br>[Set/Subset Generators](../sets/sets.md)
5+
</br>[Cartesian Product Generators](../products/README.md)
6+
</br>[Math Functions](../calculator/README.md)
7+
</br>[Ranking Algorithms](../ranking/README.md)
8+
</br>[Number System Algorithms](../numbersystem/README.md)
149

1510
# Math Functions in Calculator
1611

@@ -213,17 +208,11 @@ Calculator calc = new Calculator();
213208
BigInteger result = calc.rencontresNumber(4, 1);
214209
System.out.println(result); // Output: 8
215210
```
216-
217-
[Home](../../README.md)
218-
    |    
219-
[Permutation Generators](../permutations/README.md)
220-
    |    
221-
[Combination Generators](../combinations/README.md)
222-
    |    
223-
[Set/Subset Generators](../sets/sets.md)
224-
    |    
225-
[Cartesian Product Generators](../products/README.md)
226-
    |    
227-
[Math Functions](../calculator/README.md)
228-
    |    
229-
[Ranking Algorithms](../ranking/README.md)
211+
[Home](../../README.md)
212+
</br>[Permutation Generators](../permutations/README.md)
213+
</br>[Combination Generators](../combinations/README.md)
214+
</br>[Set/Subset Generators](../sets/sets.md)
215+
</br>[Cartesian Product Generators](../products/README.md)
216+
</br>[Math Functions](../calculator/README.md)
217+
</br>[Ranking Algorithms](../ranking/README.md)
218+
</br>[Number System Algorithms](../numbersystem/README.md)

docs/combinations/README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
[Home](../../README.md)
2-
    |    
3-
[Permutation Generators](../permutations/README.md)
4-
    |    
5-
[Combination Generators](../combinations/README.md)
6-
    |    
7-
[Set/Subset Generators](../sets/sets.md)
8-
    |    
9-
[Cartesian Product Generators](../products/README.md)
10-
    |    
11-
[Math Functions](../calculator/README.md)
12-
    |    
13-
[Ranking Algorithms](../ranking/README.md)
1+
[Home](../../README.md)
2+
</br>[Permutation Generators](../permutations/README.md)
3+
</br>[Combination Generators](../combinations/README.md)
4+
</br>[Set/Subset Generators](../sets/sets.md)
5+
</br>[Cartesian Product Generators](../products/README.md)
6+
</br>[Math Functions](../calculator/README.md)
7+
</br>[Ranking Algorithms](../ranking/README.md)
8+
</br>[Number System Algorithms](../numbersystem/README.md)
149

1510
# Combination Generators
1611

@@ -255,17 +250,11 @@ JNumberTools.combinations()
255250
.fromSequence(iterable)
256251
.stream().toList();
257252
```
258-
259-
[Home](../../README.md)
260-
    |    
261-
[Permutation Generators](../permutations/README.md)
262-
    |    
263-
[Combination Generators](../combinations/README.md)
264-
    |    
265-
[Set/Subset Generators](../sets/sets.md)
266-
    |    
267-
[Cartesian Product Generators](../products/README.md)
268-
    |    
269-
[Math Functions](../calculator/README.md)
270-
    |    
271-
[Ranking Algorithms](../ranking/README.md)
253+
[Home](../../README.md)
254+
</br>[Permutation Generators](../permutations/README.md)
255+
</br>[Combination Generators](../combinations/README.md)
256+
</br>[Set/Subset Generators](../sets/sets.md)
257+
</br>[Cartesian Product Generators](../products/README.md)
258+
</br>[Math Functions](../calculator/README.md)
259+
</br>[Ranking Algorithms](../ranking/README.md)
260+
</br>[Number System Algorithms](../numbersystem/README.md)

docs/numbersystem/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[Home](../../README.md)
2+
</br>[Permutation Generators](../permutations/README.md)
3+
</br>[Combination Generators](../combinations/README.md)
4+
</br>[Set/Subset Generators](../sets/sets.md)
5+
</br>[Cartesian Product Generators](../products/README.md)
6+
</br>[Math Functions](../calculator/README.md)
7+
</br>[Ranking Algorithms](../ranking/README.md)
8+
</br>[Number System Algorithms](../numbersystem/README.md)
9+
10+
# Number System Algorithms
11+
12+
JNumberTools provides three number system algorithms related to combinatorics, enabling efficient encoding and decoding of permutations and combinations. These APIs support `BigInteger` for large indices, making them suitable for applications in combinatorial generation, ranking, and data compression.
13+
14+
**Currently Available Algorithms**
15+
16+
1. [Factorial Number System (Factoradic)](#1-factorial-number-system-factoradic)
17+
2. [Permutation Number System (Permutadic)](#2-permutation-number-system-permutadic)
18+
3. [Combinatorial Number System (Combinadic)](#3-combinatorial-number-system-combinadic)
19+
20+
---
21+
22+
### 1. Factorial Number System (Factoradic)
23+
The Factorial Number System, also known as Factoradic, represents numbers as sums of factorials, where each digit is constrained by its position. It is used to encode and decode unique permutations efficiently.
24+
25+
```java
26+
// Convert a number to its factoradic representation
27+
BigInteger number = BigInteger.valueOf(859);
28+
int[] factoradic = JNumberTools.numberSystem().factoradic(number);
29+
System.out.println(Arrays.toString(factoradic)); // Output: [7, 1, 2, 0, 1]
30+
31+
// Convert a factoradic representation back to a number
32+
BigInteger result = JNumberTools.numberSystem().fromFactoradic(new int[]{7, 1, 2, 0, 1});
33+
System.out.println(result); // Output: 859
34+
```
35+
36+
### 2. Permutation Number System (Permutadic)
37+
The Permutation Number System, or Permutadic, is a generalization of the factoradic system for k-permutations. It encodes k-permutations using a mixed-radix system, enabling efficient generation of permutations at specific indices.
38+
39+
```java
40+
// Convert a number to its permutadic representation for n=5, k=3
41+
BigInteger number = BigInteger.valueOf(100);
42+
int[] permutadic = JNumberTools.numberSystem().permutadic(5, 3, number);
43+
System.out.println(Arrays.toString(permutadic)); // Output: [4, 2, 0]
44+
45+
// Convert a permutadic representation back to a number
46+
BigInteger result = JNumberTools.numberSystem().fromPermutadic(5, new int[]{4, 2, 0});
47+
System.out.println(result); // Output: 100
48+
```
49+
50+
### 3. Combinatorial Number System (Combinadic)
51+
The Combinatorial Number System, or Combinadic, encodes combinations by representing their indices as sums of binomial coefficients. It is used to efficiently generate and rank combinations.
52+
53+
```java
54+
// Convert a number to its combinadic representation for n=5, k=3
55+
BigInteger number = BigInteger.valueOf(35);
56+
int[] combinadic = JNumberTools.numberSystem().combinadic(5, 3, number);
57+
System.out.println(Arrays.toString(combinadic)); // Output: [4, 3, 1]
58+
59+
// Convert a combinadic representation back to a number
60+
BigInteger result = JNumberTools.numberSystem().fromCombinadic(new int[]{4, 3, 1});
61+
System.out.println(result); // Output: 35
62+
```
63+
[Home](../../README.md)
64+
</br>[Permutation Generators](../permutations/README.md)
65+
</br>[Combination Generators](../combinations/README.md)
66+
</br>[Set/Subset Generators](../sets/sets.md)
67+
</br>[Cartesian Product Generators](../products/README.md)
68+
</br>[Math Functions](../calculator/README.md)
69+
</br>[Ranking Algorithms](../ranking/README.md)
70+
</br>[Number System Algorithms](../numbersystem/README.md)

docs/permutations/README.md

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
[Home](../../README.md)
2-
    |    
3-
[Permutation Generators](../permutations/README.md)
4-
    |    
5-
[Combination Generators](../combinations/README.md)
6-
    |    
7-
[Set/Subset Generators](../sets/sets.md)
8-
    |    
9-
[Cartesian Product Generators](../products/README.md)
10-
    |    
11-
[Math Functions](../calculator/README.md)
12-
    |    
13-
[Ranking Algorithms](../ranking/README.md)
1+
[Home](../../README.md)
2+
</br>[Permutation Generators](../permutations/README.md)
3+
</br>[Combination Generators](../combinations/README.md)
4+
</br>[Set/Subset Generators](../sets/sets.md)
5+
</br>[Cartesian Product Generators](../products/README.md)
6+
</br>[Math Functions](../calculator/README.md)
7+
</br>[Ranking Algorithms](../ranking/README.md)
8+
</br>[Number System Algorithms](../numbersystem/README.md)
149

1510
# Permutation Generators
1611

@@ -397,16 +392,11 @@ JNumberTools.permutations()
397392
.stream().toList();
398393
```
399394

400-
[Home](../../README.md)
401-
    |    
402-
[Permutation Generators](../permutations/README.md)
403-
    |    
404-
[Combination Generators](../combinations/README.md)
405-
    |    
406-
[Set/Subset Generators](../sets/sets.md)
407-
    |    
408-
[Cartesian Product Generators](../products/README.md)
409-
    |    
410-
[Math Functions](../calculator/README.md)
411-
    |    
412-
[Ranking Algorithms](../ranking/README.md)
395+
[Home](../../README.md)
396+
</br>[Permutation Generators](../permutations/README.md)
397+
</br>[Combination Generators](../combinations/README.md)
398+
</br>[Set/Subset Generators](../sets/sets.md)
399+
</br>[Cartesian Product Generators](../products/README.md)
400+
</br>[Math Functions](../calculator/README.md)
401+
</br>[Ranking Algorithms](../ranking/README.md)
402+
</br>[Number System Algorithms](../numbersystem/README.md)

docs/products/README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
[Home](../../README.md)    |    [Permutation Generators](../permutations/README.md)    |    
2-
[Combination Generators](../combinations/README.md)    |    [Set/subset Generators](../sets/sets.md)    |    [Cartesian Product Generators](../products/README.md)
1+
[Home](../../README.md)
2+
</br>[Permutation Generators](../permutations/README.md)
3+
</br>[Combination Generators](../combinations/README.md)
4+
</br>[Set/Subset Generators](../sets/sets.md)
5+
</br>[Cartesian Product Generators](../products/README.md)
6+
</br>[Math Functions](../calculator/README.md)
7+
</br>[Ranking Algorithms](../ranking/README.md)
8+
</br>[Number System Algorithms](../numbersystem/README.md)
39

410
# Cartesian Product Generators
511

@@ -107,13 +113,11 @@ JNumberTools.cartesianProduct()
107113
.lexOrderMth(1_000_000_000_000_000_000L, 0)
108114
.stream().toList();
109115
```
110-
111-
[Home](../../README.md)
112-
    |    
113-
[Permutation Generators](../permutations/README.md)
114-
    |    
115-
[Combination Generators](../combinations/README.md)
116-
    |    
117-
[Set/subset Generators](../sets/sets.md)
118-
    |    
119-
[Cartesian Product Generators](../products/README.md)
116+
[Home](../../README.md)
117+
</br>[Permutation Generators](../permutations/README.md)
118+
</br>[Combination Generators](../combinations/README.md)
119+
</br>[Set/Subset Generators](../sets/sets.md)
120+
</br>[Cartesian Product Generators](../products/README.md)
121+
</br>[Math Functions](../calculator/README.md)
122+
</br>[Ranking Algorithms](../ranking/README.md)
123+
</br>[Number System Algorithms](../numbersystem/README.md)

docs/ranking/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[Home](../../README.md)
2+
</br>[Permutation Generators](../permutations/README.md)
3+
</br>[Combination Generators](../combinations/README.md)
4+
</br>[Set/Subset Generators](../sets/sets.md)
5+
</br>[Cartesian Product Generators](../products/README.md)
6+
</br>[Math Functions](../calculator/README.md)
7+
</br>[Ranking Algorithms](../ranking/README.md)
8+
</br>[Number System Algorithms](../numbersystem/README.md)
9+
10+
# Ranking Algorithms
11+
12+
JNumberTools provides the following 7 ranking algorithms for permutations and combinations. These APIs calculate the lexicographical rank of a given permutation or combination, supporting `BigInteger` for large indices, enabling efficient ranking even in massive combinatorial spaces.
13+
14+
**Currently Available Algorithms**
15+
16+
1. [Ranking of Unique Permutation](#1-ranking-of-unique-permutation)
17+
2. [Ranking of k-Permutation](#2-ranking-of-k-permutation)
18+
3. [Ranking of Repetitive Permutation](#3-ranking-of-repetitive-permutation)
19+
4. [Ranking of Unique Combination](#4-ranking-of-unique-combination)
20+
5. [Ranking of Repetitive Combination](#5-ranking-of-repetitive-combination)
21+
6. [Ranking of Multiset Permutation](#6-ranking-of-multiset-permutation)
22+
7. [Ranking of Multiset Combination](#7-ranking-of-multiset-combination)
23+
24+
---
25+
26+
### 1. Ranking of Unique Permutation
27+
Calculates the rank of a unique permutation starting from 0th. For example, there are a total of 4!=24 permutations of [0,1,2,3], where the first permutation [0,1,2,3] has rank 0 and the last permutation [3,2,1,0] has the rank of 23.
28+
29+
```java
30+
BigInteger rank = JNumberTools.rankOf().uniquePermutation(3, 2, 1, 0);
31+
```
32+
33+
### 2. Ranking of k-Permutation
34+
Calculates the rank of a k-permutation. For example, if we select 5 elements out of 8 [0,1,2,3,4,5,6,7], there are a total of <sup>8</sup>P<sub>5</sub> permutations, out of which the 1000<sup>th</sup> permutation is [8,4,6,2,0].
35+
36+
```java
37+
// Will return 1000
38+
BigInteger rank = JNumberTools.rankOf().kPermutation(8, 4, 6, 2, 0);
39+
```
40+
41+
### 3. Ranking of Repetitive Permutation
42+
Calculates the rank of a repetitive permutation.
43+
44+
```java
45+
// 1,0,0,1 is the 9th repeated permutation of two digits 0 and 1
46+
int elementCount = 2;
47+
BigInteger result = JNumberTools.rankOf()
48+
.repeatedPermutation(elementCount, new Integer[]{1, 0, 0, 1});
49+
```
50+
51+
### 4. Ranking of Unique Combination
52+
Calculates the rank of a given combination. For example, if we generate combinations of 4 elements out of 8 in lex order, the 35th combination will be [1,2,3,4]. Given the input 8 and [1,2,3,4], the API returns 35, the rank of the combination.
53+
54+
```java
55+
BigInteger rank = JNumberTools.rankOf().uniqueCombination(8, 1, 2, 3, 4);
56+
```
57+
58+
### 5. Ranking of Repetitive Combination
59+
This feature is currently in development and will be available in a future release.
60+
61+
### 6. Ranking of Multiset Permutation
62+
This feature is currently in development and will be available in a future release.
63+
64+
### 7. Ranking of Multiset Combination
65+
This feature is currently in development and will be available in a future release.
66+
67+
[Home](../../README.md)
68+
</br>[Permutation Generators](../permutations/README.md)
69+
</br>[Combination Generators](../combinations/README.md)
70+
</br>[Set/Subset Generators](../sets/sets.md)
71+
</br>[Cartesian Product Generators](../products/README.md)
72+
</br>[Math Functions](../calculator/README.md)
73+
</br>[Ranking Algorithms](../ranking/README.md)
74+
</br>[Number System Algorithms](../numbersystem/README.md)

0 commit comments

Comments
 (0)