Giter Club home page Giter Club logo

subspace's Introduction

Build Status

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<BigInteger> list = Factorizor.factor(new BigInteger("909077759200010102032010201"), Factorizor.FactorMethod.RHO);

will return

967, 9819889267, 95734388625509

Pollard P-1 method is also implemented:

ArrayList<BigInteger> 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

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<Character[]> 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'}
	```

subspace's People

Contributors

jonghough avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

mickhogs

subspace's Issues

Improve ContinuedFractions#realToCF() method

The limit is 1 to high:

diff --git a/src/main/java/arithmetic/ContinuedFractions.java b/src/main/java/arithmetic/ContinuedFractions.java
index 07d67bf..77c65b8 100644
--- a/src/main/java/arithmetic/ContinuedFractions.java
+++ b/src/main/java/arithmetic/ContinuedFractions.java
@@ -70,10 +70,13 @@
         double tNext;
         int aNext;
         as.add(aNow);
-        for(int i = 0; i < limit; i++){
+        for(int i = 0; i < limit-1; i++){
             double rec = 1.0 / tNow;
             aNext = (int)rec;
             tNext = rec - aNext;
+            if (aNext==Integer.MAX_VALUE)  {
+				break;
+			}
             as.add(aNext);
             tNow = tNext;
         }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.