https://github.com/jonghough/subspace
Math library, written in Java.
https://github.com/jonghough/subspace
biginteger combinatorics elliptic-curves factorization fft math mathematics maths numbers numerical-calculations permutation permutations pollard totient
Last synced: 11 months ago
JSON representation
Math library, written in Java.
- Host: GitHub
- URL: https://github.com/jonghough/subspace
- Owner: jonghough
- License: bsd-2-clause
- Created: 2016-06-01T06:42:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-26T07:37:22.000Z (over 8 years ago)
- Last Synced: 2025-01-10T02:25:44.669Z (about 1 year ago)
- Topics: biginteger, combinatorics, elliptic-curves, factorization, fft, math, mathematics, maths, numbers, numerical-calculations, permutation, permutations, pollard, totient
- Language: Java
- Homepage:
- Size: 691 KB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/jonghough/Subspace)
# Subspace
## Math library, written in Java, focusing on number theory and related fields.
### Implemented functions:
| Functions | Implemented |
|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| Factorization | Rho, P-1, P+1, Elliptic Curve examples |
| Arithmetic and Number theoretic functions | Prime decomposition, totient function, sigma functions, primality test, Meissel formula for counting primes, Jacobi Symbol |
| Analytic NT functions | Gamma function, approximation for large values, Riemann-Siegel formula for Z(t) |
| Sieves | Eratosthenes, Atkin sieves |
| Combinatorics | Integer Partitions, Partition counting, Permutation, lexicographically ordered permutations, permutation rank, parity. |
## License
BSD 2-clause “Simplified” License
### To build the library
`mvn clean install`
### To run unit tests
`mvn test`
### Examples
**Factoring a BigInteger**
The following uses the Pollard-rho method of factorization:
`ArrayList list = Factorizor.factor(new BigInteger("909077759200010102032010201"), Factorizor.FactorMethod.RHO);`
will return
`967, 9819889267, 95734388625509`
Pollard P-1 method is also implemented:
`ArrayList list2 = Factorizor.factor(new BigInteger("425624900000909000001111317911"), Factorizor.FactorMethod.PMO);`
returns
`571, 62818373, 11865997022428766417`
Factorizor also includes a P+1 factorization algorithm implementation.
**Euler Totient of a BigInteger**
Euler totient is defined [Totient](https://en.wikipedia.org/wiki/Euler%27s_totient_function)
`BigInteger tot = Totient.totient(new BigInteger("425624"));`
returns
`209920`
** Calculating number of primes less than a given float (or BigDecimal)**
`int q = PrimeCount.pi(1000000f);`
returns
`78498`
This uses the Meissel formula to calculate pi(x). It will probably choke on values much larger than 10 million though.
**Calculate Lexicographically ordered permutations of list of objects (which implement `Comparable`)**
`ArrayList permutations = PermutationsGeneric.getLexicographicPermutations(new Character[]{'a', 'b', 'c'});`
This returns six permutations:
```
{'a','b','c'}
{'a','c','b'}
{'b','a','c'}
{'b','c','a'}
{'c','a','b'}
{'c','b','a'}
```