├── .github
└── workflows
│ └── maven.yml
├── .gitignore
├── LICENSE
├── README.md
├── conf
└── log4j2-test.xml
├── doc
├── Lehman kN congruences.txt
└── PSIQS-performance.txt
├── lib
├── log4j-api-2.24.3.jar
└── log4j-core-2.24.3.jar
├── pom.xml
└── src
├── main
└── java
│ └── de
│ └── tilman_neumann
│ ├── jml
│ ├── BinarySearch.java
│ ├── ChebyshevPolynomials.java
│ ├── Divisors.java
│ ├── HarmonicNumbers.java
│ ├── MoebiusFunction.java
│ ├── base
│ │ ├── BigDecimalConstants.java
│ │ ├── BigDecimalMath.java
│ │ ├── BigIntCollectionUtil.java
│ │ ├── BigIntConstants.java
│ │ ├── BigIntConverter.java
│ │ ├── BigIntGrid.java
│ │ ├── BigIntPoly.java
│ │ ├── BigIntTriangle.java
│ │ ├── BigRational.java
│ │ ├── IntCollectionUtil.java
│ │ ├── NumberGrid.java
│ │ ├── Uint128.java
│ │ └── UnsignedBigInt.java
│ ├── combinatorics
│ │ ├── Binomial.java
│ │ ├── Factorial.java
│ │ ├── FallingFactorial.java
│ │ ├── HyperFactorial.java
│ │ ├── Multinomial.java
│ │ └── Stirling.java
│ ├── factor
│ │ ├── CombinedFactorAlgorithm.java
│ │ ├── CombinedFactorAlgorithmRunner.java
│ │ ├── FactorAlgorithm.java
│ │ ├── FactorException.java
│ │ ├── FactorSieve.java
│ │ ├── TestNumberNature.java
│ │ ├── TestsetGenerator.java
│ │ ├── base
│ │ │ ├── FactorArguments.java
│ │ │ ├── FactorResult.java
│ │ │ ├── GlobalFactoringOptions.java
│ │ │ ├── IntHolder.java
│ │ │ ├── PrimeBaseGenerator.java
│ │ │ ├── SortedIntegerArray.java
│ │ │ ├── SortedLongArray.java
│ │ │ ├── UnsafeUtil.java
│ │ │ ├── congruence
│ │ │ │ ├── AQPair.java
│ │ │ │ ├── AQPairFactory.java
│ │ │ │ ├── CongruenceCollector.java
│ │ │ │ ├── CongruenceCollector01.java
│ │ │ │ ├── CongruenceCollector02.java
│ │ │ │ ├── CongruenceCollector03.java
│ │ │ │ ├── CongruenceCollectorReport.java
│ │ │ │ ├── CongruenceCollectorSmall.java
│ │ │ │ ├── CycleCounter.java
│ │ │ │ ├── CycleCounter2LP.java
│ │ │ │ ├── CycleCounter3LP.java
│ │ │ │ ├── CycleFinder.java
│ │ │ │ ├── Partial.java
│ │ │ │ ├── Partial1Large.java
│ │ │ │ ├── Partial2Large.java
│ │ │ │ ├── PartialNLarge.java
│ │ │ │ ├── PartialSolver.java
│ │ │ │ ├── PartialSolver01.java
│ │ │ │ ├── PartialSolver02.java
│ │ │ │ ├── Smooth.java
│ │ │ │ ├── Smooth1LargeSquare.java
│ │ │ │ ├── SmoothComposite.java
│ │ │ │ ├── SmoothNLargeSquares.java
│ │ │ │ ├── SmoothPerfect.java
│ │ │ │ └── SmoothSimple.java
│ │ │ └── matrixSolver
│ │ │ │ ├── BlockLanczos.java
│ │ │ │ ├── FactorTest.java
│ │ │ │ ├── FactorTest01.java
│ │ │ │ ├── IndexSet.java
│ │ │ │ ├── MatrixRow.java
│ │ │ │ ├── MatrixSolver.java
│ │ │ │ ├── MatrixSolverBase01.java
│ │ │ │ ├── MatrixSolverBase02.java
│ │ │ │ ├── MatrixSolverBase03.java
│ │ │ │ ├── MatrixSolverBlockLanczos.java
│ │ │ │ ├── MatrixSolverGauss01.java
│ │ │ │ ├── MatrixSolverGauss02.java
│ │ │ │ ├── MatrixSolverGauss03.java
│ │ │ │ ├── MatrixSolverPGauss01.java
│ │ │ │ ├── RichMatrixFactory.java
│ │ │ │ └── util
│ │ │ │ ├── CompareCongruence.java
│ │ │ │ ├── CompareEntry.java
│ │ │ │ └── StackEntry.java
│ │ ├── cfrac
│ │ │ ├── CFrac.java
│ │ │ ├── CFrac63.java
│ │ │ ├── KnuthSchroeppelCFrac.java
│ │ │ └── tdiv
│ │ │ │ ├── TDiv_CF.java
│ │ │ │ ├── TDiv_CF01.java
│ │ │ │ ├── TDiv_CF02.java
│ │ │ │ ├── TDiv_CF03.java
│ │ │ │ ├── TDiv_CF63.java
│ │ │ │ ├── TDiv_CF63_01.java
│ │ │ │ └── TDiv_CF63_02.java
│ │ ├── ecm
│ │ │ ├── EllipticCurveMethod.java
│ │ │ ├── MontgomeryMult.java
│ │ │ ├── TinyEcm64.java
│ │ │ ├── TinyEcm64MH.java
│ │ │ └── TinyEcm64MHInlined.java
│ │ ├── hart
│ │ │ ├── HartFast.java
│ │ │ ├── HartFast2Mult.java
│ │ │ ├── HartFast2Mult2.java
│ │ │ ├── HartFast2MultFMA.java
│ │ │ ├── HartMultiplierChainSqrtN.java
│ │ │ ├── HartSimple.java
│ │ │ ├── HartSquarefree.java
│ │ │ ├── HartTDivRace.java
│ │ │ └── HartTDivRace2.java
│ │ ├── lehman
│ │ │ ├── LehmanCustomKOrder.java
│ │ │ ├── LehmanFast.java
│ │ │ ├── LehmanSimple.java
│ │ │ └── LehmanSmith.java
│ │ ├── pollardRho
│ │ │ ├── PollardRho.java
│ │ │ ├── PollardRho31.java
│ │ │ ├── PollardRhoBrent.java
│ │ │ ├── PollardRhoBrent31.java
│ │ │ ├── PollardRhoBrentModBlock.java
│ │ │ ├── PollardRhoBrentMontgomery32.java
│ │ │ ├── PollardRhoBrentMontgomery64.java
│ │ │ ├── PollardRhoBrentMontgomery64MH.java
│ │ │ ├── PollardRhoBrentMontgomery64MHInlined.java
│ │ │ ├── PollardRhoProductGcd.java
│ │ │ ├── PollardRhoTwoLoops.java
│ │ │ ├── PollardRhoTwoLoops31.java
│ │ │ └── PollardRhoTwoLoopsModBlock.java
│ │ ├── psiqs
│ │ │ ├── PSIQS.java
│ │ │ ├── PSIQSBase.java
│ │ │ ├── PSIQSThread.java
│ │ │ ├── PSIQSThreadBase.java
│ │ │ ├── PSIQSThread_SB.java
│ │ │ ├── PSIQSThread_SB_U.java
│ │ │ ├── PSIQSThread_U.java
│ │ │ ├── PSIQSThread_U_3LP.java
│ │ │ ├── PSIQSThread_U_nLP.java
│ │ │ ├── PSIQS_SB.java
│ │ │ ├── PSIQS_SB_U.java
│ │ │ ├── PSIQS_U.java
│ │ │ ├── PSIQS_U_3LP.java
│ │ │ └── PSIQS_U_nLP.java
│ │ ├── siqs
│ │ │ ├── KnuthSchroeppel.java
│ │ │ ├── ModularSqrtsEngine.java
│ │ │ ├── SIQS.java
│ │ │ ├── SIQSSmall.java
│ │ │ ├── data
│ │ │ │ ├── BaseArrays.java
│ │ │ │ └── SolutionArrays.java
│ │ │ ├── poly
│ │ │ │ ├── AParamGenerator.java
│ │ │ │ ├── AParamGenerator01.java
│ │ │ │ ├── AParamGenerator02.java
│ │ │ │ ├── PolyReport.java
│ │ │ │ ├── SIQSPolyGenerator.java
│ │ │ │ └── baseFilter
│ │ │ │ │ ├── BaseFilter.java
│ │ │ │ │ ├── BaseFilter_q1.java
│ │ │ │ │ ├── BaseFilter_q2.java
│ │ │ │ │ └── BaseFilter_qk.java
│ │ │ ├── powers
│ │ │ │ ├── AllPowerFinder.java
│ │ │ │ ├── NoPowerFinder.java
│ │ │ │ ├── PowerEntry.java
│ │ │ │ ├── PowerFinder.java
│ │ │ │ ├── PowerOfSmallPrimesFinder.java
│ │ │ │ └── SomePowerFinder.java
│ │ │ ├── sieve
│ │ │ │ ├── BlockSieveUtil.java
│ │ │ │ ├── Sieve.java
│ │ │ │ ├── Sieve03g.java
│ │ │ │ ├── Sieve03gU.java
│ │ │ │ ├── Sieve03h.java
│ │ │ │ ├── Sieve03hU.java
│ │ │ │ ├── SieveParams.java
│ │ │ │ ├── SieveParamsFactory01.java
│ │ │ │ ├── SieveParamsFactory02.java
│ │ │ │ ├── SieveReport.java
│ │ │ │ ├── SieveResult.java
│ │ │ │ ├── SieveResultDefaultImpl.java
│ │ │ │ ├── SimpleSieve.java
│ │ │ │ ├── SingleBlockSieve.java
│ │ │ │ ├── SingleBlockSieveU.java
│ │ │ │ └── SmoothCandidate.java
│ │ │ └── tdiv
│ │ │ │ ├── TDivReport.java
│ │ │ │ ├── TDiv_QS.java
│ │ │ │ ├── TDiv_QS_2LP.java
│ │ │ │ ├── TDiv_QS_2LP_Full.java
│ │ │ │ ├── TDiv_QS_3LP.java
│ │ │ │ ├── TDiv_QS_Small.java
│ │ │ │ ├── TDiv_QS_nLP.java
│ │ │ │ └── TDiv_QS_nLP_Full.java
│ │ ├── squfof
│ │ │ ├── SquFoF31.java
│ │ │ ├── SquFoF31Preload.java
│ │ │ └── SquFoF63.java
│ │ └── tdiv
│ │ │ ├── TDiv.java
│ │ │ ├── TDiv31.java
│ │ │ ├── TDiv31Barrett.java
│ │ │ ├── TDiv31Inverse.java
│ │ │ ├── TDiv63.java
│ │ │ └── TDiv63Inverse.java
│ ├── gaussianInteger
│ │ ├── GaussianInteger.java
│ │ └── GaussianIntegerConstants.java
│ ├── gcd
│ │ ├── EEA31.java
│ │ ├── EEA63.java
│ │ ├── Gcd.java
│ │ ├── Gcd31.java
│ │ └── Gcd63.java
│ ├── hyperbolic
│ │ ├── ArcCosH.java
│ │ ├── ArcCotH.java
│ │ ├── ArcSinH.java
│ │ └── ArcTanH.java
│ ├── modular
│ │ ├── JacobiSymbol.java
│ │ ├── LegendreSymbol.java
│ │ ├── ModularPower.java
│ │ ├── ModularSqrt.java
│ │ ├── ModularSqrt31.java
│ │ └── ModularSqrtBig.java
│ ├── partitions
│ │ ├── Generator.java
│ │ ├── IntegerPartition.java
│ │ ├── IntegerPartitionGenerator.java
│ │ ├── Mpi.java
│ │ ├── MpiPartition.java
│ │ ├── MpiPartitionGenerator.java
│ │ ├── MpiPowerMap.java
│ │ ├── Mpi_IntegerArrayImpl.java
│ │ ├── PrimePowers.java
│ │ └── PrimePowers_DefaultImpl.java
│ ├── powers
│ │ ├── Pow.java
│ │ ├── Pow2.java
│ │ └── PurePowerTest.java
│ ├── precision
│ │ ├── Magnitude.java
│ │ ├── Precision.java
│ │ └── Scale.java
│ ├── primes
│ │ ├── bounds
│ │ │ ├── NthPrimeUpperBounds.java
│ │ │ └── PrimeCountUpperBounds.java
│ │ ├── exact
│ │ │ ├── AutoExpandingPrimesArray.java
│ │ │ ├── CollectingCallback.java
│ │ │ ├── CountingCallback.java
│ │ │ ├── SSOZJ5.java
│ │ │ ├── SegmentedSieve.java
│ │ │ ├── SieveCallback.java
│ │ │ └── SimpleSieve.java
│ │ └── probable
│ │ │ ├── BPSWTest.java
│ │ │ ├── LucasTest.java
│ │ │ ├── MillerRabinTest.java
│ │ │ ├── PrPTest.java
│ │ │ └── TDivPrimeTest.java
│ ├── quadraticResidues
│ │ ├── QuadraticResidues.java
│ │ ├── QuadraticResiduesMod2PowN.java
│ │ ├── QuadraticResiduesMod3PowN.java
│ │ └── QuadraticResiduesModPPowN.java
│ ├── quaternion
│ │ ├── HurwitzQuaternion.java
│ │ ├── HurwitzQuaternionConstants.java
│ │ └── RationalQuaternion.java
│ ├── random
│ │ ├── LehmerRng64.java
│ │ ├── LehmerRng64MH.java
│ │ ├── Random64.java
│ │ ├── Rng.java
│ │ ├── SpRand32.java
│ │ ├── SplitMix64.java
│ │ ├── Xoroshiro128Plus.java
│ │ ├── Xoroshiro256StarStar.java
│ │ ├── Xorshf32.java
│ │ ├── Xorshift128Plus.java
│ │ └── Xorshift64Star.java
│ ├── roots
│ │ ├── Roots.java
│ │ ├── RootsReal.java
│ │ ├── SqrtExact.java
│ │ ├── SqrtInt.java
│ │ └── SqrtReal.java
│ ├── sequence
│ │ ├── NumberSequence.java
│ │ ├── SquarefreeSequence.java
│ │ └── SquarefreeSequence63.java
│ ├── smooth
│ │ ├── CANEntry.java
│ │ ├── CANIterator.java
│ │ ├── SHCNEntry.java
│ │ └── SHCNIterator.java
│ ├── squareSums
│ │ ├── FourSquaresFinder.java
│ │ └── SumOf4Squares.java
│ └── transcendental
│ │ ├── Agm.java
│ │ ├── EulerConstant.java
│ │ ├── Exp.java
│ │ ├── Ln.java
│ │ └── Pi.java
│ └── util
│ ├── ConfigUtil.java
│ ├── Ensure.java
│ ├── Multiset.java
│ ├── Multiset_HashMapImpl.java
│ ├── Pair.java
│ ├── ReflectionUtil.java
│ ├── SortOrder.java
│ ├── SortedList.java
│ ├── SortedMultiset.java
│ ├── SortedMultiset_BottomUp.java
│ ├── SortedMultiset_TopDown.java
│ ├── StringUtil.java
│ ├── TimeUtil.java
│ └── Timer.java
└── test
├── java
└── de
│ └── tilman_neumann
│ └── jml
│ ├── BinarySearchTest.java
│ ├── ChebyshevPolynomialsTest.java
│ ├── DivisorsPerformanceTest.java
│ ├── DivisorsTest.java
│ ├── EgyptianFractionsTriangleDemo.java
│ ├── FermatCatalanConjectureTestRunner.java
│ ├── HarmonicNumbersTest.java
│ ├── MoebiusFunctionTest.java
│ ├── base
│ ├── BigIntConverterTest.java
│ ├── BigRationalTest.java
│ ├── Uint128PerformanceTest.java
│ ├── Uint128Test.java
│ ├── UnsignedBigIntPerformanceTest.java
│ └── UnsignedBigIntTest.java
│ ├── collatz
│ ├── CollatzDroppingSequenceTestRunner.java
│ └── CollatzRepeatSequenceTestRunner.java
│ ├── combinatorics
│ ├── BinomialTest.java
│ ├── FactorialPerformanceTest.java
│ ├── FactorialTest.java
│ ├── FallingFactorialPerformanceTest.java
│ ├── FallingFactorialTest.java
│ ├── StirlingPerformanceTest.java
│ └── StirlingTest.java
│ ├── factor
│ ├── BatchFactorizer.java
│ ├── CombinedFactorAlgorithm1ThreadTest.java
│ ├── CombinedFactorAlgorithm2ThreadsTest.java
│ ├── FactorSieveDemo.java
│ ├── FactorTestBase.java
│ ├── FactorizerTest.java
│ ├── HardSemiprimeGenerator.java
│ ├── TestsetGeneratorTest.java
│ ├── cfrac
│ │ ├── CFrac63Test.java
│ │ ├── CFracRunner.java
│ │ └── CFracTest.java
│ ├── ecm
│ │ ├── BigNbrTest.java
│ │ ├── EllipticCurveMethodTest.java
│ │ ├── TinyEcm64MHInlinedTest.java
│ │ ├── TinyEcm64MHTest.java
│ │ └── TinyEcm64Test.java
│ ├── hart
│ │ ├── HartCongruencesAnalyzer.java
│ │ ├── HartFast2Mult2Test.java
│ │ ├── HartFast2MultFMATest.java
│ │ ├── HartFast2MultTest.java
│ │ ├── HartFastTest.java
│ │ ├── HartMultiplierChainGenerator.java
│ │ ├── HartSimpleTest.java
│ │ ├── HartSquareCongruencesAnalyzer.java
│ │ ├── HartSquarefreeTest.java
│ │ ├── HartTDivRace2Test.java
│ │ └── HartTDivRaceTest.java
│ ├── lehman
│ │ ├── GuardedVsUnguardedSqrtPerformanceTest.java
│ │ ├── LehmanCongruencesAnalyzer.java
│ │ ├── LehmanCongruencesAnalyzer2.java
│ │ ├── LehmanCustomKOrderTest.java
│ │ ├── LehmanFastTest.java
│ │ ├── LehmanKFactoringMostNAnalyzer.java
│ │ ├── LehmanKFactoringSameNAnalyzer.java
│ │ ├── LehmanKModsAnalyzer.java
│ │ ├── LehmanKProgressionsAnalyzer.java
│ │ ├── LehmanKProgressionsAnalyzer2.java
│ │ ├── LehmanKStructureAnalyzer.java
│ │ ├── LehmanModPowersOf2Analyzer.java
│ │ ├── LehmanSimpleTest.java
│ │ ├── LehmanSmithTest.java
│ │ └── LehmanSpecialArgumentsAnalyzer.java
│ ├── pollardRho
│ │ ├── PollardRho31Test.java
│ │ ├── PollardRhoBrent31Runner.java
│ │ ├── PollardRhoBrent31Test.java
│ │ ├── PollardRhoBrentModBlockTest.java
│ │ ├── PollardRhoBrentMontgomery32Test.java
│ │ ├── PollardRhoBrentMontgomery64MHInlinedRunner.java
│ │ ├── PollardRhoBrentMontgomery64MHInlinedTest.java
│ │ ├── PollardRhoBrentMontgomery64MHRunner.java
│ │ ├── PollardRhoBrentMontgomery64MHTest.java
│ │ ├── PollardRhoBrentMontgomery64Runner.java
│ │ ├── PollardRhoBrentMontgomery64Test.java
│ │ ├── PollardRhoBrentRunner.java
│ │ ├── PollardRhoBrentTest.java
│ │ ├── PollardRhoTest.java
│ │ ├── PollardRhoTwoLoopsModBlockTest.java
│ │ └── PollardRhoTwoLoopsTest.java
│ ├── psiqs
│ │ ├── PSIQS_Runner.java
│ │ ├── PSIQS_SB_Runner.java
│ │ ├── PSIQS_SB_U_Runner.java
│ │ ├── PSIQS_U_3LP_Runner.java
│ │ ├── PSIQS_U_Runner.java
│ │ └── PSIQS_U_nLP_Runner.java
│ ├── siqs
│ │ ├── SIQSRunner.java
│ │ ├── SIQSSmallRunner.java
│ │ ├── SIQSSmallTest.java
│ │ ├── SIQSTest.java
│ │ └── poly
│ │ │ └── BParamTest.java
│ ├── squfof
│ │ ├── SquFoF31PreloadTest.java
│ │ ├── SquFoF31Test.java
│ │ └── SquFoF63Test.java
│ └── tdiv
│ │ ├── TDiv31BarrettTest.java
│ │ ├── TDiv31InverseTest.java
│ │ ├── TDiv31Test.java
│ │ ├── TDiv63InverseTest.java
│ │ ├── TDiv63Test.java
│ │ └── TDivTest.java
│ ├── gaussianInteger
│ └── GaussianIntegerTest.java
│ ├── modular
│ ├── JacobiSymbolPerformanceTest.java
│ ├── JacobiSymbolTest.java
│ ├── ModularSqrtPerformanceTest.java
│ └── ModularSqrtTest.java
│ ├── partitions
│ ├── IntegerPartitionGeneratorRunner.java
│ ├── MpiPartitionCountCoverageAnalyzer.java
│ ├── MpiPartitionGeneratorRunner.java
│ ├── MpiPartitionGeneratorTest.java
│ └── MpiPowerMapHypothesisTest.java
│ ├── powers
│ ├── PurePowerTestPerformanceTest.java
│ ├── PurePowerTestRunner.java
│ └── PurePowerTestTest.java
│ ├── precision
│ ├── MagnitudeTest.java
│ └── PrecisionTest.java
│ ├── primes
│ ├── PrimeCountsBetweenSquaresAnalyzer.java
│ ├── PrimeGapAnalyzer.java
│ ├── RiemannLagariasHypothesisAnalyzer.java
│ ├── RiemannRobinHypothesisAnalyzer.java
│ ├── bounds
│ │ ├── NthPrimeUpperBoundsTest.java
│ │ └── PrimeCountUpperBoundsTest.java
│ ├── exact
│ │ ├── AutoExpandingPrimesArrayPerformanceTest.java
│ │ ├── SSOZJ5Runner.java
│ │ ├── SegmentedSievePerformanceTest.java
│ │ ├── SieveTest.java
│ │ └── SimpleSievePerformanceTest.java
│ └── probable
│ │ ├── NextProbablePrimePerformanceTest.java
│ │ └── NextProbablePrimeTest.java
│ ├── quadraticResidues
│ ├── QuadraticResiduesMod2PowNPerformanceTest.java
│ ├── QuadraticResiduesMod2PowNTest.java
│ ├── QuadraticResiduesMod3PowNPerformanceTest.java
│ ├── QuadraticResiduesMod3PowNTest.java
│ ├── QuadraticResiduesModPPowNPerformanceTest.java
│ ├── QuadraticResiduesModPPowNTest.java
│ └── QuadraticResiduesTest.java
│ ├── quaternion
│ ├── HurwitzQuaternionTest.java
│ └── RationalQuaternionTest.java
│ ├── random
│ ├── LehmerRng64MHTest.java
│ ├── LehmerRng64Test.java
│ ├── RngPerformanceTest.java
│ ├── RngTest.java
│ ├── SecureRandomTest.java
│ ├── SpRand32Test.java
│ ├── SplitMix64Test.java
│ ├── Xoroshiro128PlusTest.java
│ ├── Xoroshiro256StarStarTest.java
│ ├── Xorshf32Test.java
│ ├── Xorshift128PlusTest.java
│ └── Xorshift64StarTest.java
│ ├── roots
│ ├── RootsPerformanceTest.java
│ ├── RootsRealRunner.java
│ ├── RootsTest.java
│ ├── SqrtExactPerformanceTest.java
│ ├── SqrtExactTest.java
│ ├── SqrtIntPerformanceTest.java
│ ├── SqrtIntTest.java
│ ├── SqrtRealRunner.java
│ ├── SqrtRealTest.java
│ └── SquareRestAnalyzer.java
│ ├── sequence
│ └── SquarefreeSequencePerformanceTest.java
│ ├── smooth
│ ├── CANTest.java
│ └── SHCNTest.java
│ ├── squareSums
│ ├── FourSquaresFinderRunner.java
│ ├── FourSquaresFinderTest.java
│ ├── SumOf4SquaresPerformanceTest.java
│ └── SumOf4SquaresTest.java
│ └── transcendental
│ ├── AgmRunner.java
│ ├── EulerConstantPerformanceTest.java
│ ├── ExpRunner.java
│ ├── ExpTest.java
│ ├── LnRunner.java
│ └── PiPerformanceTest.java
└── resources
└── factor
└── qaTests.txt
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Java CI with Maven
10 |
11 | on:
12 | push:
13 | branches: [ "master" ]
14 | pull_request:
15 | branches: [ "master" ]
16 |
17 | jobs:
18 | build:
19 |
20 | runs-on: ubuntu-latest
21 | timeout-minutes: 30
22 |
23 | steps:
24 | - uses: actions/checkout@v4
25 | - name: Set up JDK 11
26 | uses: actions/setup-java@v4
27 | with:
28 | java-version: '11'
29 | distribution: 'temurin'
30 | cache: maven
31 | - name: Build with Maven
32 | run: mvn -B package --file pom.xml
33 |
34 | - name: Report
35 | uses: dorny/test-reporter@v1
36 | if: always()
37 | with:
38 | name: Maven Tests
39 | path: target/surefire-reports/*.xml
40 | reporter: java-junit
41 | fail-on-error: true
42 |
43 | # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
44 | - name: Update dependency graph
45 | uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
46 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 | /target/
3 | /.settings/
4 | .classpath
5 | .project
6 | log.txt
7 |
--------------------------------------------------------------------------------
/conf/log4j2-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/lib/log4j-api-2.24.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TilmanNeumann/java-math-library/79dbb1c74886fe299bb218b32e85ec890d339950/lib/log4j-api-2.24.3.jar
--------------------------------------------------------------------------------
/lib/log4j-core-2.24.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TilmanNeumann/java-math-library/79dbb1c74886fe299bb218b32e85ec890d339950/lib/log4j-core-2.24.3.jar
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/base/BigDecimalConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018-2024 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.base;
15 |
16 | import java.math.BigDecimal;
17 |
18 | public class BigDecimalConstants {
19 |
20 | public static final BigDecimal F_0 = BigDecimal.ZERO;
21 | public static final BigDecimal F_0_5 = new BigDecimal("0.5");
22 | public static final BigDecimal F_1 = BigDecimal.ONE;
23 | public static final BigDecimal F_2 = BigDecimal.valueOf(2);
24 | public static final BigDecimal F_2_5 = new BigDecimal("2.5");
25 | public static final BigDecimal F_3 = BigDecimal.valueOf(3);
26 | public static final BigDecimal F_4 = BigDecimal.valueOf(4);
27 | public static final BigDecimal F_5 = BigDecimal.valueOf(5);
28 | public static final BigDecimal F_8 = BigDecimal.valueOf(8);
29 | public static final BigDecimal F_10 = BigDecimal.TEN;
30 | public static final BigDecimal F_12 = BigDecimal.valueOf(12);
31 | public static final BigDecimal F_16 = BigDecimal.valueOf(16);
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/base/BigIntGrid.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.base;
15 |
16 | import java.math.BigInteger;
17 |
18 | /**
19 | * A two-dimensional grid of big integers.
20 | *
21 | * @author Tilman Neumann
22 | */
23 | public class BigIntGrid extends NumberGrid {
24 |
25 | private static final long serialVersionUID = 9189914650661627444L;
26 |
27 | /**
28 | * Simplified constructor with offsets 1.
29 | *
30 | * @param xLabel The letter to use for the x-axis
31 | * @param xStart The start value for the x-axis-values
32 | * @param yLabel The letter to use for the y-axis
33 | * @param yStart The start value for the y-axis-values
34 | */
35 | public BigIntGrid(String xLabel, int xStart, String yLabel, int yStart) {
36 | super(xLabel, xStart, yLabel, yStart);
37 | }
38 |
39 | /**
40 | * Full constructor with all options.
41 | *
42 | * @param xLabel The letter to use for the x-axis
43 | * @param xStart The start value for the x-axis-values
44 | * @param xIncrement The increment for the x-axis-values
45 | * @param yLabel The letter to use for the y-axis
46 | * @param yStart The start value for the y-axis-values
47 | * @param yIncrement The increment for the y-axis-values
48 | */
49 | public BigIntGrid(String xLabel, int xStart, int xIncrement, String yLabel, int yStart, int yIncrement) {
50 | super(xLabel, xStart, xIncrement, yLabel, yStart, yIncrement);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/base/IntCollectionUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.base;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Collection;
18 | import java.util.StringTokenizer;
19 |
20 | /**
21 | * Utility methods for collections of Integers.
22 | *
23 | * @author Tilman Neumann
24 | */
25 | public class IntCollectionUtil {
26 |
27 | /**
28 | * Converts the given comma-separated string into a list of Integers.
29 | * @param str
30 | * @return list of sequence elements
31 | */
32 | public static ArrayList stringToList(String str) {
33 | ArrayList list = new ArrayList<>();
34 | if (str!=null) {
35 | StringTokenizer tokenizer = new StringTokenizer(str.trim(), ",");
36 | while (tokenizer.hasMoreTokens()) {
37 | String token = tokenizer.nextToken().trim();
38 | try {
39 | list.add(Integer.decode(token));
40 | } catch (NumberFormatException nfe) {
41 | throw new IllegalArgumentException("str contains illegal value '" + token + "'");
42 | }
43 | }
44 | }
45 | return list;
46 | }
47 |
48 | /**
49 | * Returns the maximum value of the given non-negative integer collection.
50 | * @param c the collection (not null)
51 | * @return the biggest element, or 0 if the collection is empty
52 | */
53 | public static int max(Collection c) {
54 | int result = 0;
55 | for (int elem : c) {
56 | if (elem>result) result = elem;
57 | }
58 | return result;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/combinatorics/HyperFactorial.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.combinatorics;
15 |
16 | import java.math.BigInteger;
17 |
18 | import static de.tilman_neumann.jml.base.BigIntConstants.*;
19 |
20 | /**
21 | * Hyperfactorials.
22 | *
23 | * @author Tilman Neumann
24 | */
25 | public class HyperFactorial {
26 | /**
27 | * A002109 or the standard "hyperfactorial" is the product {1^1*2^2*..n^n}.
28 | * @param n
29 | * @return hyperfactorial(n)
30 | */
31 | public static BigInteger standard(int n) {
32 | BigInteger result = I_1;
33 | for (int k=2; k<=n; k++) {
34 | result = result.multiply(BigInteger.valueOf(k).pow(k));
35 | }
36 | return result;
37 | }
38 |
39 | /**
40 | * A000197 or what I call the "inverse hyperfactorial" is the product
41 | * 1^n*2^(n-1)*..*(n-1)^2*n^1 = 1!*2!*3!*...(n-1)!*n!.
42 | * @param n
43 | * @return the "inverse hyperfactorial" of n aka 1!*2!*3!*...(n-1)!*n!
44 | */
45 | public static BigInteger inverse(int n) {
46 | BigInteger result = I_1;
47 | BigInteger kFactorial = I_1;
48 | for (int k=2; k<=n; k++) {
49 | kFactorial = kFactorial.multiply(BigInteger.valueOf(k));
50 | result = result.multiply(kFactorial);
51 | }
52 | return result;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/combinatorics/Multinomial.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.combinatorics;
15 |
16 | import java.math.BigInteger;
17 |
18 | /**
19 | * Multinomial coefficient implementations.
20 | *
21 | * @author Tilman Neumann
22 | */
23 | public class Multinomial {
24 |
25 | /**
26 | * Multinomial coefficient.
27 | *
28 | * @param N Category counts.
29 | * @return (N1+...+Nk) choose (N1, ..., Nk)
30 | */
31 | public static BigInteger multinomial(int N[]) {
32 | // get dimension
33 | int k = N.length;
34 |
35 | // get total count
36 | int Nall = 0;
37 | for (int i = 0; i.
13 | */
14 | package de.tilman_neumann.jml.factor;
15 |
16 | import java.math.BigInteger;
17 |
18 | /**
19 | * An exception indicating that a factor was found.
20 | *
21 | * @author Tilman Neumann
22 | */
23 | public class FactorException extends Exception {
24 | private static final long serialVersionUID = -6623862851940555652L;
25 |
26 | private BigInteger factor = null;
27 |
28 | /**
29 | * Complete constructor.
30 | * @param factor
31 | */
32 | public FactorException(BigInteger factor) {
33 | this.factor = factor;
34 | }
35 |
36 | /**
37 | * @return factor
38 | */
39 | public BigInteger getFactor() {
40 | return this.factor;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/TestNumberNature.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor;
15 |
16 | /**
17 | * Definition of the "nature" of test numbers.
18 | * @author Tilman Neumann
19 | */
20 | public enum TestNumberNature {
21 | /**
22 | * Arbitrary random composite numbers N chosen from a certain bit length.
23 | * Note that there are no such numbers with less than 3 bits.
24 | */
25 | RANDOM_COMPOSITES,
26 |
27 | /**
28 | * Random odd composite numbers N chosen from a certain bit length.
29 | * Note that there are no such numbers with less than 4 bits.
30 | */
31 | RANDOM_ODD_COMPOSITES,
32 |
33 | /**
34 | * Odd semiprimes N=a*b with min(a,b) >= cbrt(N).
35 | * Note that there are no such numbers with less than 4 bits.
36 | */
37 | MODERATE_SEMIPRIMES,
38 |
39 | /**
40 | * Odd semiprimes N=a*b with bitLength(min(a,b)) == bitLength(N)/2 - 1 bits.
41 | */
42 | QUITE_HARD_SEMIPRIMES
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/FactorArguments.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2020 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base;
15 |
16 | import java.math.BigInteger;
17 |
18 | public class FactorArguments {
19 | /** The number to factor */
20 | public BigInteger N;
21 |
22 | /** The number of bits of N */
23 | public int NBits;
24 |
25 | /** The exponent of N */
26 | public int exp;
27 |
28 | /**
29 | * Full constructor.
30 | * @param N the number to factor
31 | * @param exp the exponent of N
32 | */
33 | public FactorArguments(BigInteger N, int exp) {
34 | this.N = N;
35 | this.NBits = N.bitLength();
36 | this.exp = exp;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/GlobalFactoringOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base;
15 |
16 | /**
17 | * Global factoring settings.
18 | *
19 | * Code "guarded" with a static final boolean = false will be removed by the compiler.
20 | * Thus if turned off, such code does not decrement performance at all.
21 | *
22 | * @author Tilman Neumann
23 | */
24 | public interface GlobalFactoringOptions {
25 | /**
26 | * Basic analysis of timings and operations. This option is used by most or all factoring algorithms that collect relations.
27 | * In SIQS, the analysis includes number of polynomials, number of smooth and partial relations (also by large factor counts),
28 | * trials division results, solver runs and tested null-vectors, and sub-phase timings.
29 | */
30 | static final boolean ANALYZE = false;
31 |
32 | /**
33 | * Monitor the congruence collecting progress on-the-fly.
34 | * This option needs ANALYZE as well.
35 | */
36 | static final boolean ANALYZE_PROGRESS = false;
37 |
38 | /**
39 | * A switch to additionally turn on analysis of the size of large factors that yield smooth relations.
40 | * This option needs ANALYZE as well.
41 | */
42 | static final boolean ANALYZE_LARGE_FACTOR_SIZES = false;
43 |
44 | /**
45 | * A switch to additionally turn on analysis of the number of Q-values with positive and negative sign.
46 | * This option needs ANALYZE as well.
47 | */
48 | static final boolean ANALYZE_Q_SIGNS = false;
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/IntHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base;
15 |
16 | /**
17 | * Class for holding counts. A holder class is better performance-wise than mapping counts as integers
18 | * since increments/decrements don't need to be remapped.
19 | *
20 | * @author David McGuigan
21 | */
22 | public class IntHolder {
23 | public int value;
24 |
25 | public IntHolder(int v) {
26 | value = v;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/CycleCounter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2021 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.util.HashSet;
17 |
18 | /**
19 | * Interface for cycle counting algorithms.
20 | * @author Till
21 | *
22 | * @see [LLDMW02] Leyland, Lenstra, Dodson, Muffett, Wagstaff 2002: "MPQS with three large primes", Lecture Notes in Computer Science, 2369.
23 | * @see [LM94] Lenstra, Manasse 1994: "Factoring With Two Large Primes", Mathematics of Computation, volume 63, number 208, page 789.
24 | */
25 | public interface CycleCounter {
26 |
27 | /** Initialize this cycle counter for a new factor argument. */
28 | void initializeForN();
29 |
30 | /**
31 | * Counts the number of independent cycles in the partial relations.
32 | *
33 | * @param partial the newest partial relation to add
34 | * @param correctSmoothCount the correct number of smooths from partials (only for debugging)
35 | * @return the updated number of smooths from partials
36 | */
37 | int addPartial(Partial partial, int correctSmoothCount);
38 |
39 | /**
40 | * @return the partial relations found so far
41 | */
42 | HashSet getPartialRelations();
43 |
44 | /**
45 | * @return number of partial relations found so far.
46 | */
47 | int getPartialRelationsCount();
48 |
49 | /**
50 | * @return the number of cycles counted by this algorithm
51 | */
52 | int getCycleCount();
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/Partial.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.math.BigInteger;
17 |
18 | import de.tilman_neumann.jml.factor.base.SortedIntegerArray;
19 |
20 | /**
21 | * Base class for partial congruences.
22 | * The matrix elements of a partial congruence are the large factors appearing with odd exponent.
23 | *
24 | * @author Tilman Neumann
25 | */
26 | abstract public class Partial extends AQPair {
27 |
28 | /**
29 | * Full constructor.
30 | * @param A
31 | * @param smallFactors small factors of Q
32 | */
33 | public Partial(BigInteger A, SortedIntegerArray smallFactors) {
34 | super(A, smallFactors);
35 | }
36 |
37 | /**
38 | * @return the large factors appearing with odd exponent.
39 | */
40 | abstract public Long[] getLargeFactorsWithOddExponent();
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/Partial1Large.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.math.BigInteger;
17 |
18 | import de.tilman_neumann.jml.factor.base.SortedIntegerArray;
19 | import de.tilman_neumann.util.SortedMultiset;
20 |
21 | /**
22 | * A partial congruence having 1 large factor.
23 | *
24 | * @author Tilman Neumann
25 | */
26 | public class Partial1Large extends Partial {
27 |
28 | private long bigFactor; // needs 8 byte instead of 56 byte for a Long[1]
29 |
30 | /**
31 | * Full constructor.
32 | * @param A
33 | * @param smallFactors small factors of Q
34 | * @param bigFactor the single large factor of Q
35 | */
36 | public Partial1Large(BigInteger A, SortedIntegerArray smallFactors, long bigFactor) {
37 | super(A, smallFactors);
38 | // only 1 large factor
39 | this.bigFactor = bigFactor;
40 | }
41 |
42 | @Override
43 | public SortedMultiset getAllQFactors() {
44 | // get small factors of Q
45 | SortedMultiset allFactors = super.getSmallQFactors();
46 | // add single large factor
47 | allFactors.add(bigFactor);
48 | return allFactors;
49 | }
50 |
51 | @Override
52 | public Long[] getLargeFactorsWithOddExponent() {
53 | return new Long[] {bigFactor};
54 | }
55 |
56 | @Override
57 | public int getNumberOfLargeQFactors() {
58 | return 1;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/PartialSolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018-2024 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.util.Collection;
17 |
18 | /**
19 | * Interface for solvers used to find smooth from partial relations.
20 | *
21 | * @author Tilman Neumann
22 | */
23 | public interface PartialSolver {
24 |
25 | /**
26 | * @return the name of the algorithm
27 | */
28 | String getName();
29 |
30 | /** Initialize this partial solver for a new factor argument. */
31 | void initializeForN();
32 |
33 | /**
34 | * Solve a partial congruence equation system.
35 | * @param congruences the partial congruence equation system
36 | * @return list of smooth congruences found
37 | */
38 | Smooth solve(Collection extends Partial> congruences);
39 |
40 | /**
41 | * @return the size of the biggest partial matrix found for some N
42 | */
43 | int getMaxMatrixSize();
44 |
45 | /**
46 | * Release memory after a factorization.
47 | */
48 | void cleanUp();
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/Smooth.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.util.Set;
17 |
18 | /**
19 | * A smooth congruence.
20 | * The matrix elements of a smooth congruence are the small factors appearing with odd exponent.
21 | *
22 | * @author Tilman Neumann
23 | */
24 | public interface Smooth {
25 |
26 | /**
27 | * Test if the Q of this smooth congruence is an exact square.
28 | * Since smooth congruences can not have non-square large Q-factors, only the small Q-factors need to be checked.
29 | *
30 | * @return true if Q is square
31 | */
32 | boolean isExactSquare();
33 |
34 | /**
35 | * @return set matrix elements. For a smooth relation these are the small factors appearing with odd exponent.
36 | */
37 | Integer[] getMatrixElements();
38 |
39 | /**
40 | * @return the set of AQPairs this smooth relation consists of
41 | */
42 | Set getAQPairs();
43 |
44 | /**
45 | * Add this's AQPairs to the target set via xor.
46 | * This operation permits to get around without creating new array objects
47 | * for all those congruence sub-classes that represent just a single AQPair.
48 | *
49 | * @param targetSet
50 | */
51 | void addMyAQPairsViaXor(Set targetSet);
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/Smooth1LargeSquare.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.math.BigInteger;
17 |
18 | import de.tilman_neumann.jml.factor.base.SortedIntegerArray;
19 | import de.tilman_neumann.util.SortedMultiset;
20 |
21 | /**
22 | * A smooth congruence with 1 large factor contained as a square.
23 | *
24 | * @author Tilman Neumann
25 | */
26 | public class Smooth1LargeSquare extends SmoothSimple {
27 |
28 | /** the large factor contained as a square */
29 | private long bigFactor;
30 |
31 | /**
32 | * Full constructor.
33 | * @param A
34 | * @param smallFactors small factors of Q
35 | * @param bigFactor the single large factor of Q contained as square
36 | */
37 | public Smooth1LargeSquare(BigInteger A, SortedIntegerArray smallFactors, long bigFactor) {
38 | super(A, smallFactors);
39 | // the large factor contained as a square
40 | this.bigFactor = bigFactor;
41 | }
42 |
43 | @Override
44 | public SortedMultiset getAllQFactors() {
45 | // get small factors of Q
46 | SortedMultiset allFactors = super.getSmallQFactors();
47 | // add single large factor square
48 | allFactors.add(bigFactor, 2);
49 | return allFactors;
50 | }
51 |
52 | @Override
53 | public int getNumberOfLargeQFactors() {
54 | return 2;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/SmoothNLargeSquares.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.math.BigInteger;
17 |
18 | import de.tilman_neumann.jml.factor.base.SortedIntegerArray;
19 | import de.tilman_neumann.jml.factor.base.SortedLongArray;
20 | import de.tilman_neumann.util.SortedMultiset;
21 |
22 | /**
23 | * A smooth congruence having an arbitrary number of large factors.
24 | *
25 | * @author Tilman Neumann
26 | */
27 | public class SmoothNLargeSquares extends SmoothSimple {
28 |
29 | private long[] bigFactors;
30 | private byte[] bigFactorExponents;
31 |
32 | /**
33 | * Full constructor.
34 | * @param A
35 | * @param smallFactors small factors of Q
36 | * @param bigFactors large factors of Q
37 | */
38 | public SmoothNLargeSquares(BigInteger A, SortedIntegerArray smallFactors, SortedLongArray bigFactors) {
39 | super(A, smallFactors);
40 | // copy big factors of Q
41 | this.bigFactors = bigFactors.copyFactors();
42 | this.bigFactorExponents = bigFactors.copyExponents();
43 | }
44 |
45 | @Override
46 | public SortedMultiset getAllQFactors() {
47 | // get small factors of Q
48 | SortedMultiset allFactors = super.getSmallQFactors();
49 | // add large factors
50 | for (int i=0; i.
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.math.BigInteger;
17 |
18 | import de.tilman_neumann.jml.factor.base.SortedIntegerArray;
19 | import de.tilman_neumann.util.SortedMultiset;
20 |
21 | /**
22 | * A perfect smooth congruence.
23 | * @author Tilman Neumann
24 | */
25 | public class SmoothPerfect extends SmoothSimple {
26 |
27 | /**
28 | * Full constructor.
29 | * @param A
30 | * @param smallFactors small factors of Q
31 | */
32 | public SmoothPerfect(BigInteger A, SortedIntegerArray smallFactors) {
33 | super(A, smallFactors);
34 | }
35 |
36 | @Override
37 | public SortedMultiset getAllQFactors() {
38 | // a perfect smooth congruence has no large factors
39 | return super.getSmallQFactors();
40 | }
41 |
42 | @Override
43 | public int getNumberOfLargeQFactors() {
44 | return 0;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/congruence/SmoothSimple.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.congruence;
15 |
16 | import java.math.BigInteger;
17 | import java.util.HashSet;
18 | import java.util.Set;
19 |
20 | import de.tilman_neumann.jml.factor.base.SortedIntegerArray;
21 |
22 | /**
23 | * A smooth congruence from a single AQ-pair.
24 | * @author Tilman Neumann
25 | */
26 | abstract public class SmoothSimple extends AQPair implements Smooth {
27 |
28 | private Integer[] oddExpElements;
29 |
30 | public SmoothSimple(BigInteger A, SortedIntegerArray smallFactors) {
31 | super(A, smallFactors);
32 | // determine small factors with odd exponents: first we need a set to eliminate duplicates.
33 | Set result = new HashSet();
34 | for (int i=0; i getAQPairs() {
43 | Set set = new HashSet<>();
44 | set.add(this);
45 | return set;
46 | }
47 |
48 | @Override
49 | public void addMyAQPairsViaXor(Set targetSet) {
50 | if (!targetSet.remove(this)) targetSet.add(this);
51 | }
52 |
53 | @Override
54 | public Integer[] getMatrixElements() {
55 | return oddExpElements;
56 | }
57 |
58 | @Override
59 | public boolean isExactSquare() {
60 | return oddExpElements.length==0;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/matrixSolver/FactorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.matrixSolver;
15 |
16 | import java.util.Set;
17 |
18 | import de.tilman_neumann.jml.factor.FactorException;
19 | import de.tilman_neumann.jml.factor.base.congruence.AQPair;
20 |
21 | /**
22 | * Interface for final factor tests when a square congruence A^2 == Q (mod kN) has been found.
23 | * The congruence may be improper though...
24 | *
25 | * @author Tilman Neumann
26 | */
27 | public interface FactorTest {
28 |
29 | /**
30 | * @return the algorithm name
31 | */
32 | String getName();
33 |
34 | /**
35 | * Test if a square congruence A^2 == Q (mod kN) gives a factor of N.
36 | *
37 | * @param aqPairs
38 | * @throws FactorException
39 | */
40 | void testForFactor(Set aqPairs) throws FactorException;
41 | }
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/matrixSolver/MatrixSolverBase03.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.matrixSolver;
15 |
16 | import java.util.Arrays;
17 | import java.util.List;
18 |
19 | import de.tilman_neumann.jml.factor.base.congruence.Smooth;
20 | import de.tilman_neumann.jml.factor.base.matrixSolver.util.CompareCongruence;
21 |
22 | /**
23 | * Base implementation for a congruence equation system (the "LinAlg phase matrix") solver.
24 | * Much faster than the first version due to great improvements by Dave McGuigan.
25 | *
26 | * @author Tilman Neumann, Dave McGuigan
27 | */
28 | abstract public class MatrixSolverBase03 extends MatrixSolverBase02 {
29 |
30 | /**
31 | * Sort smooths be smallest number of column bits set
32 | */
33 | @Override
34 | protected void sortSmooths(List list) {
35 | Object[] ns = list.toArray();
36 | Arrays.sort(ns, new CompareCongruence());
37 | list.clear();
38 | for (Object o : ns) {
39 | Smooth s = (Smooth)o;
40 | list.add(s);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/de/tilman_neumann/jml/factor/base/matrixSolver/util/CompareCongruence.java:
--------------------------------------------------------------------------------
1 | /*
2 | * java-math-library is a Java library focused on number theory, but not necessarily limited to it. It is based on the PSIQS 4.0 factoring project.
3 | * Copyright (C) 2018 Tilman Neumann - tilman.neumann@web.de
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10 | *
11 | * You should have received a copy of the GNU General Public License along with this program;
12 | * if not, see .
13 | */
14 | package de.tilman_neumann.jml.factor.base.matrixSolver.util;
15 |
16 | import java.util.Comparator;
17 |
18 | import de.tilman_neumann.jml.factor.base.congruence.Smooth;
19 |
20 | /**
21 | * @author David McGuigan
22 | */
23 | public class CompareCongruence implements Comparator