Home

Awesome

Abacus

A Combinatorics and Algebraic Number Theory Symbolic Computation library for Javascript, Python

version 1.0.9 in progress (~ 331kB minified)

abacus combinatorial numbers

Abacus.js, Abacus.min.js

Abacus is a flexible library containing methods and associated math utilities for (fast) combinatorial object computation and integer / number theoretic computation. It builds on (and extends) a deprecated previous project for PHP, Simulacra.

Abacus uses (for the most part) self-contained and standalone methods, so they can be easily copy-pasted in other projects, in case only a few methods are needed and not the whole library.

Abacus Live

see also:

Contents

Features

Supports: (see: test/test.bat)

Combinatorics

Algebraic Number Theory

Performance

Note that the lib can generate very large (and also randomised) combinatorial objects without ever using biginteger arithmetic due to design and implementation except if arbitrary random, ranking and unranking have to be used (see above)

Credits and References

See the comments in the code for algorithms and references used.

Example API

let o = Abacus.Permutation(4);
console.log(String(o.total()));
console.log('---');
for (let item of o)
{
    console.log(item.join(','));
}
24
---
0,1,2,3
0,1,3,2
0,2,1,3
0,2,3,1
0,3,1,2
0,3,2,1
1,0,2,3
1,0,3,2
1,2,0,3
1,2,3,0
1,3,0,2
1,3,2,0
2,0,1,3
2,0,3,1
2,1,0,3
2,1,3,0
2,3,0,1
2,3,1,0
3,0,1,2
3,0,2,1
3,1,0,2
3,1,2,0
3,2,0,1
3,2,1,0
let o = Abacus.Partition(6);
console.log(String(o.total()));
console.log('---');
for (let item of o)
{
    console.log(item.join('+'));
}
11
---
1+1+1+1+1+1
2+1+1+1+1
2+2+1+1
2+2+2
3+1+1+1
3+2+1
3+3
4+1+1
4+2
5+1
6
let field = Abacus.Ring.Q("x").associatedField();

let m = Abacus.Matrix(field, [
    [field.fromString("x-1"), field.fromString("x^2-1")],
    [field.fromString("x^2-1"), field.fromString("x-1")]
]);

console.log(m.toString());
console.log(m.inv().toString());
console.log(m.inv().mul(m).toString());
|  x-1 x^2-1|
|x^2-1   x-1|

|   -1/(x^3+x^2-2*x) (x+1)/(x^3+x^2-2*x)|
|(x+1)/(x^3+x^2-2*x)    -1/(x^3+x^2-2*x)|

|1 0|
|0 1|

Todo