All rights reserved.
Tilman Neumann 2007-2017

Introduction

PSIQS is an open source Java package for integer factorization. I named it after the most powerful algorithm it contains, a Parallel SIQS implementation. Other factor algorithms included in the package are SquFoF, CFrac and PollardRho. In the background it features many state-of-the-art algorithms like Tonelli-Shanks or Knuth-Schroeppel multiplier determination. Besides it brings some classes that simplify the development and testing of factor algorithms, like a test data generator and a performance test capable of comparing several algorithms.

The main development goals have been stability and to make the algorithms easy to understand. Because of the supposed educational value I consider the source distribution as the important one. However, to demonstrate quickly that it works, there is also an executable jar file having a simple command-line interface.

Since release 2.0, tuning the performance of SIQS and PSIQS has become another major goal. Indeed it has become the fastest Java program for integer factorization that I am aware of. See below how it compares to other programs.

Get it

Running the jar

You need Java 1.8. The executable jar file can be run in two forms:

  1. Without parameters you will be asked to insert factor arguments on standard input:
    java -jar psiqs3.0.jar
  2. Passing command-line parameters:
    java -jar psiqs3.0.jar [-t <numberOfThreads>] <numberToFactor>

It may be favorable to specify a few JVM options: First it is necessary to give it enough memory to be able to factor big numbers; and second one should configure the garbage collector appropriately. 4 GB of RAM are more than necessary to factor 340 bit numbers, but typically I am using something like

java -Xmx12G -XX:NewSize=128M -XX:MaxNewSize=128M -XX:+UseConcMarkSweepGC -jar psiqs3.0.jar

The sources

To build the project from the sources, just create a plain Java project, extract the contents of psiqs3.0-src.zip to the root folder of the project, make sure that 'src' is the source folder of your project, and add the log4j- and junit-jars from the lib-folder to your classpath.

The sources are stuffed with comments. The best starting points to explore it and in particular the quadratic sieve implementations are the classes

de.tilman_neumann.math.factor.FactorizerTest
de.tilman_neumann.math.factor.CombinedFactorAlgorithm
de.tilman_neumann.math.factor.siqs.SIQS
de.tilman_neumann.math.factor.psiqs.PSIQS

The larger algorithms have a plug-in structure for their most important components. This allows us for example to create a new implementation of the sieve stage only, plug it into the SIQS class, and compare the performance of the new vs. old sieve stage implementation using class FactorizerTest. Many components come already with several implementations, but typically only one of them - the fastest - is really required. I did not bother creating a class hierarchy in such cases; a diff shows us as quickly where the changes are. Slower implementations are maintained because they are typically simpler, hence better apt to explain what a component should actually be doing.

Speed

PSIQS 2.1 was the big step concerning performance, being about 3 times faster than release 1.2. Release 3.0 is another bit faster, but not that much, maybe just something like 5%. It seems as if in Java I cannot achieve much more.

PSIQS is also about twice as fast as Dario Alpern's Java Siqs implementation. On the other hand, the C-written Yafu program is more than three times faster than PSIQS.

Look here for a performance comparison with PSIQS 2.1; for 3.0 it didn't bother to make another time-consuming investigation...

Credits

My dearest thanks go to Dario Alpern for the permission to use his Block-Lanczos solver, and to Graeme Willoughby for his great comments on the BigInteger algorithms in the SqrtInt, SqrtExact, Root and PurePowerTest classes.

Contact

I would be happy about any comments or suggestions sent to
Tilman.Neumann(at)web.de