Skip to content

Commit

Permalink
v.0.8.1 (redux)
Browse files Browse the repository at this point in the history
* fix wrong computation of conjugate composition
* fix typo in reverse partition successor
* partial support for partition/composition COLEX ordering
* optimise some routines, minor changes and update, live example update
  • Loading branch information
Nikos M committed Jan 29, 2017
1 parent 48ed35a commit e0be248
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 711 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ A combinatorics library for Node/XPCOM/JS, PHP, Python, C/C++, Java
* `UnorderedRepeatedCombination` (`test/combinations_repeats.js`)
* `OrderedRepeatedCombination` (`test/ordered_combinations_repeats.js`)
* `Subset` (`test/subsets.js`)
* `Partition` (`test/partitions.js`) **rank/unrank methods missing**
* `Composition` (`test/compositions.js`) **rank/unrank methods missing**
* `RestrictedPartition` (`test/restricted_partitions.js`) **exactly M max. part (or exactly K #parts in conjugate order)**
* `Partition` (`test/partitions.js`) **rank/unrank methods missing, partial support for COLEX**
* `Composition` (`test/compositions.js`) **rank/unrank methods missing, partial support for COLEX**
* `RestrictedPartition` (`test/restricted_partitions.js`) **exactly M max. part**
* `RestrictedComposition` (`test/restricted_compositions.js`) **exactly K #parts**
* **multiple (combined) iterator orderings & traversals**: `lex`, `colex`, `random`, `reversed`, `reflected`, `minimal` (not implemented yet). For example: `"revlex"` (equivalent to `"lex,reversed"`), `"refcolex"` (equivalent to `"colex,reflected"`), and so on..
* **arbitrary range** of combinatorial objects in a number of supported orderings (ie `lex`, `colex`, `random`,..). **Note** `rank`/`unrank` have to be implemented for this feature to work
Expand Down
312 changes: 81 additions & 231 deletions src/js/Abacus.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/js/Abacus.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/compositions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ o.order("colex,reflected")
o.order("colex,reversed")
[ 1, 1, 1, 1, 1, 1, 1 ]
o.random()
[ 3, 1, 1, 2 ]
[ 1, 1, 3, 1, 1 ]
o.dispose()
o = Abacus.Partition(8,{type:"composition"})
o.total()
Expand Down Expand Up @@ -808,7 +808,7 @@ o.order("lex,reversed")
[ 1, 1, 1, 1, 1, 1, 2 ]
[ 1, 1, 1, 1, 1, 1, 1, 1 ]
o.random()
[ 1, 1, 1, 2, 1, 1, 1 ]
[ 2, 1, 1, 2, 2 ]
o.dispose()
o = Abacus.Partition(10,{type:"composition"})
o.dimension()
Expand Down Expand Up @@ -2876,5 +2876,5 @@ o.order("lex,reversed")
[ 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
o.random()
[ 3, 3, 2, 1, 1 ]
[ 1, 1, 1, 2, 1, 1, 1, 2 ]
o.dispose()
4 changes: 2 additions & 2 deletions test/partitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ echo('---');

// Partitions

echo('o = Abacus.Partition(7)');
o = Abacus.Partition(7);
echo('o = Abacus.Partition(6)');
o = Abacus.Partition(6);

echo('o.total()');
echo(o.total());
Expand Down
126 changes: 55 additions & 71 deletions test/partitions.txt
Original file line number Diff line number Diff line change
@@ -1,88 +1,72 @@
Abacus.Partitions (VERSION = 0.8.1)
---
o = Abacus.Partition(7)
o = Abacus.Partition(6)
o.total()
15
11
o.next()
[ 1, 1, 1, 1, 1, 1, 1 ]
[ 1, 1, 1, 1, 1, 1 ]
o.hasNext()
true
o.next()
[ 2, 1, 1, 1, 1, 1 ]
[ 2, 1, 1, 1, 1 ]
default order is "lex", lexicographic-order
o.rewind()
[ 1, 1, 1, 1, 1, 1, 1 ]
[ 2, 1, 1, 1, 1, 1 ]
[ 2, 2, 1, 1, 1 ]
[ 2, 2, 2, 1 ]
[ 3, 1, 1, 1, 1 ]
[ 3, 2, 1, 1 ]
[ 3, 2, 2 ]
[ 3, 3, 1 ]
[ 4, 1, 1, 1 ]
[ 4, 2, 1 ]
[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]
[ 6 ]
o.order("lex,reversed")
[ 7 ]
[ 6, 1 ]
[ 5, 2 ]
[ 5, 1, 1 ]
[ 4, 3 ]
[ 4, 2, 1 ]
[ 4, 1, 1, 1 ]
[ 3, 3, 1 ]
[ 3, 2, 2 ]
[ 3, 2, 1, 1 ]
[ 3, 1, 1, 1, 1 ]
[ 2, 2, 2, 1 ]
[ 2, 2, 1, 1, 1 ]
[ 2, 1, 1, 1, 1, 1 ]
[ 1, 1, 1, 1, 1, 1, 1 ]
[ 6 ]
[ 5, 1 ]
[ 4, 2 ]
[ 4, 1, 1 ]
[ 3, 3 ]
[ 3, 2, 1 ]
[ 3, 1, 1, 1 ]
[ 2, 2, 2 ]
[ 2, 2, 1, 1 ]
[ 2, 1, 1, 1, 1 ]
[ 1, 1, 1, 1, 1, 1 ]
o.order("colex")
[ 7 ]
[ 6 ]
o.order("colex,reflected")
[ 7 ]
[ 6 ]
o.order("colex,reversed")
[ 1, 1, 1, 1, 1, 1, 1 ]
[ 1, 1, 1, 1, 1, 1 ]
o.random()
[ 3, 2, 1, 1 ]
[ 2, 2, 1, 1 ]
o.dispose()
o = Abacus.Partition(8)
o.total()
Expand Down Expand Up @@ -188,7 +172,7 @@ o.order("lex,reversed")
[ 2, 1, 1, 1, 1, 1, 1 ]
[ 1, 1, 1, 1, 1, 1, 1, 1 ]
o.random()
[ 4, 3, 1 ]
[ 3, 2, 2, 1 ]
o.dispose()
o = Abacus.Partition(12,{type:"packed"})
o.total()
Expand Down Expand Up @@ -514,7 +498,7 @@ o.order("lex,reversed")
[ [ 2, 1 ], [ 1, 10 ] ]
[ [ 1, 12 ] ]
o.random()
[ [ 7, 1 ], [ 5, 1 ] ]
[ [ 4, 1 ], [ 3, 1 ], [ 2, 1 ], [ 1, 3 ] ]
o.dispose()
o = Abacus.Partition(20,{type:"packed"})
o.total()
Expand Down Expand Up @@ -3040,5 +3024,5 @@ o.order("lex,reversed")
[ [ 2, 1 ], [ 1, 18 ] ]
[ [ 1, 20 ] ]
o.random()
[ [ 10, 1 ], [ 8, 1 ], [ 2, 1 ] ]
[ [ 4, 1 ], [ 3, 2 ], [ 2, 2 ], [ 1, 6 ] ]
o.dispose()
34 changes: 17 additions & 17 deletions test/restricted_compositions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@ o = Abacus.Partition(7,{type:"composition","max=":4})
o.total()
32
o.next()
[ 4, 2, 1 ]
[ 1, 1, 1, 4 ]
o.hasNext()
false
o.next()
null
default order is "lex", lexicographic-order
o.rewind()
[ 4, 2, 1 ]
[ 1, 1, 1, 4 ]
backwards
o.rewind(-1)
[ 1, 2, 4 ]
[ 4, 1, 1, 1 ]
o.order("lex,reflected")
[ 1, 2, 4 ]
[ 4, 1, 1, 1 ]
o.order("lex,reversed")
[ 1, 2, 4 ]
[ 4, 1, 1, 1 ]
o.order("colex")
[ 1, 2, 4 ]
[ 4, 1, 1, 1 ]
o.order("colex,reflected")
[ 4, 2, 1 ]
[ 1, 1, 1, 4 ]
o.order("colex,reversed")
[ 4, 2, 1 ]
[ 1, 1, 1, 4 ]
o.random()
[ 2, 4, 1 ]
[ 4, 1, 2 ]
o.dispose()
o = Abacus.Partition(8,{type:"composition","max=":4})
o.total()
64
o.next()
[ 4, 2, 2, 0 ]
[ 1, 1, 1, 1, 4 ]
o.hasNext()
false
o.next()
null
default order is "lex", lexicographic-order
o.rewind()
[ 4, 2, 2, 0 ]
[ 1, 1, 1, 1, 4 ]
backwards
o.rewind(-1)
[ 1, 2, 2, 3 ]
[ 4, 1, 1, 1, 1 ]
o.order("lex,reflected")
[ 0, 2, 2, 4 ]
[ 4, 1, 1, 1, 1 ]
o.order("lex,reversed")
[ 1, 2, 2, 3 ]
[ 4, 1, 1, 1, 1 ]
o.random()
[ 3, 1, 4 ]
[ 1, 3, 4 ]
o.dispose()
o = Abacus.Partition(7,{type:"composition","parts=":4})
o.total()
Expand Down Expand Up @@ -209,7 +209,7 @@ o.order("colex,reversed")
[ 3, 2, 1, 1 ]
[ 4, 1, 1, 1 ]
o.random()
[ 2, 2, 2, 1 ]
[ 3, 1, 1, 2 ]
o.dispose()
o = Abacus.Partition(8,{type:"composition","parts=":4})
o.total()
Expand Down Expand Up @@ -367,5 +367,5 @@ o.order("lex,reversed")
[ 1, 1, 2, 4 ]
[ 1, 1, 1, 5 ]
o.random()
[ 1, 1, 5, 1 ]
[ 2, 2, 2, 2 ]
o.dispose()
Loading

0 comments on commit e0be248

Please sign in to comment.