Skip to content

Commit

Permalink
v.0.5.1
Browse files Browse the repository at this point in the history
* add some restricted partitions support (eg into exactly K parts, OR with M maximum value)
* method signature and name changes, ie .rewind(-1) instead of .forward(), .next(-1) instead of .prev(), .hasNext(-1) instead of .hasPrev()
* extended options on object instantiation, eg type, parameters, oredring, etc..
* some optimisations, minor fixes
* included: permutations, combinations (with repeats), subsets, partitions (with K parts OR M max value), tensors, tuples
* orderings: lex, colex, revlex, revcolex, reflex, refcolex, random
  • Loading branch information
Nikos M committed Dec 29, 2016
1 parent bc3334f commit 7d24dab
Show file tree
Hide file tree
Showing 18 changed files with 1,082 additions and 615 deletions.
138 changes: 93 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A combinatorics library for Node/XPCOM/JS, PHP, Python
(php/python implementations in progress)


**version 0.5.0**
**version 0.5.1** (~ 28kB minified, ~ 9kB zipped)

![abacus combinatorial numbers](/abacus.jpg)

Expand Down Expand Up @@ -51,7 +51,7 @@ A combinatorics library for Node/XPCOM/JS, PHP, Python
**permutations** (see `test/permutations.js`)

```text
Abacus.Permutations (VERSION = 0.5.0)
Abacus.Permutations (VERSION = 0.5.1)
---
o = Abacus.Permutation(4)
o.total()
Expand All @@ -67,173 +67,221 @@ o.rewind()
[ [ 0, 1, 2, 3 ],
'index : 0',
'rank : 0',
'unrank : 0,1,2,3',
'is_permutation : yes',
'is_identity : yes',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 0, 1, 3, 2 ],
'index : 1',
'rank : 1',
'unrank : 0,1,3,2',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 0, 2, 1, 3 ],
'index : 2',
'rank : 2',
'unrank : 0,2,1,3',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 0, 2, 3, 1 ],
'index : 3',
'rank : 3',
'unrank : 0,2,3,1',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : no' ]
[ [ 0, 3, 1, 2 ],
'index : 4',
'rank : 4',
'unrank : 0,3,1,2',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : no' ]
[ [ 0, 3, 2, 1 ],
'index : 5',
'rank : 5',
'unrank : 0,3,2,1',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 1, 0, 2, 3 ],
'index : 6',
'rank : 6',
'unrank : 1,0,2,3',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 1, 0, 3, 2 ],
'index : 7',
'rank : 7',
'unrank : 1,0,3,2',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 1, 2, 0, 3 ],
'index : 8',
'rank : 8',
'unrank : 1,2,0,3',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : no' ]
[ [ 1, 2, 3, 0 ],
'index : 9',
'rank : 9',
'unrank : 1,2,3,0',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 1, 3, 0, 2 ],
'index : 10',
'rank : 10',
'unrank : 1,3,0,2',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 1, 3, 2, 0 ],
'index : 11',
'rank : 11',
'unrank : 1,3,2,0',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 2, 0, 1, 3 ],
'index : 12',
'rank : 12',
'unrank : 2,0,1,3',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : no' ]
[ [ 2, 0, 3, 1 ],
'index : 13',
'rank : 13',
'unrank : 2,0,3,1',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 2, 1, 0, 3 ],
'index : 14',
'rank : 14',
'unrank : 2,1,0,3',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 2, 1, 3, 0 ],
'index : 15',
'rank : 15',
'unrank : 2,1,3,0',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 2, 3, 0, 1 ],
'index : 16',
'rank : 16',
'unrank : 2,3,0,1',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 2, 3, 1, 0 ],
'index : 17',
'rank : 17',
'unrank : 2,3,1,0',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : no' ]
'is_involution : no',
'is_connected : no' ]
[ [ 3, 0, 1, 2 ],
'index : 18',
'rank : 18',
'unrank : 3,0,1,2',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 3, 0, 2, 1 ],
'index : 19',
'rank : 19',
'unrank : 3,0,2,1',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 3, 1, 0, 2 ],
'index : 20',
'rank : 20',
'unrank : 3,1,0,2',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : no' ]
'is_involution : no',
'is_connected : yes' ]
[ [ 3, 1, 2, 0 ],
'index : 21',
'rank : 21',
'unrank : 3,1,2,0',
'is_permutation : yes',
'is_identity : no',
'is_derangement : no',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
[ [ 3, 2, 0, 1 ],
'index : 22',
'rank : 22',
'unrank : 3,2,0,1',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : no' ]
'is_involution : no',
'is_connected : no' ]
[ [ 3, 2, 1, 0 ],
'index : 23',
'rank : 23',
'unrank : 3,2,1,0',
'is_permutation : yes',
'is_identity : no',
'is_derangement : yes',
'is_involution : yes' ]
'is_involution : yes',
'is_connected : no' ]
backwards
o.forward()
o.rewind(-1)
[ 3, 2, 1, 0 ]
[ 3, 2, 0, 1 ]
[ 3, 1, 2, 0 ]
Expand Down Expand Up @@ -384,32 +432,32 @@ o.order("colex,reversed")
[ 2, 3, 1, 0 ]
[ 3, 2, 1, 0 ]
o.order("random")
[ 1, 2, 0, 3 ]
[ 3, 1, 2, 0 ]
[ 0, 3, 2, 1 ]
[ 1, 3, 0, 2 ]
[ 1, 3, 2, 0 ]
[ 2, 1, 3, 0 ]
[ 1, 0, 3, 2 ]
[ 2, 3, 1, 0 ]
[ 3, 0, 2, 1 ]
[ 2, 1, 0, 3 ]
[ 3, 2, 0, 1 ]
[ 3, 0, 1, 2 ]
[ 0, 3, 1, 2 ]
[ 0, 2, 3, 1 ]
[ 1, 0, 2, 3 ]
[ 1, 2, 3, 0 ]
[ 2, 3, 0, 1 ]
[ 2, 3, 1, 0 ]
[ 0, 2, 1, 3 ]
[ 0, 1, 3, 2 ]
[ 1, 2, 0, 3 ]
[ 0, 3, 2, 1 ]
[ 2, 3, 0, 1 ]
[ 0, 1, 2, 3 ]
[ 1, 0, 2, 3 ]
[ 3, 2, 1, 0 ]
[ 1, 0, 3, 2 ]
[ 3, 1, 0, 2 ]
[ 2, 0, 1, 3 ]
[ 1, 2, 3, 0 ]
[ 1, 3, 2, 0 ]
[ 3, 0, 2, 1 ]
[ 2, 0, 3, 1 ]
[ 3, 1, 0, 2 ]
[ 3, 2, 1, 0 ]
o.random()
[ 3, 1, 2, 0 ]
[ 2, 1, 3, 0 ]
[ 0, 3, 1, 2 ]
[ 3, 2, 0, 1 ]
[ 3, 0, 1, 2 ]
[ 2, 1, 0, 3 ]
o.random()
[ 0, 1, 3, 2 ]
o.order("colex").range(-5, -1)
[ 1, 2, 0, 3 ]
[ 2, 0, 1, 3 ]
Expand Down
Loading

0 comments on commit 7d24dab

Please sign in to comment.