All Projects → danog → PrimeModule

danog / PrimeModule

Licence: AGPL-3.0 License
PHP Prime module capable of doing prime factorization of huge numbers very quickly.

Programming Languages

PHP
23972 projects - #3 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to PrimeModule

RcppAlgos
Tool for Solving Problems in Combinatorics and Computational Mathematics
Stars: ✭ 31 (+138.46%)
Mutual labels:  factorization
LimitedLDLFactorizations.jl
Limited-Memory Factorization of Symmetric Matrices
Stars: ✭ 15 (+15.38%)
Mutual labels:  factorization
NMFADMM
A sparsity aware implementation of "Alternating Direction Method of Multipliers for Non-Negative Matrix Factorization with the Beta-Divergence" (ICASSP 2014).
Stars: ✭ 39 (+200%)
Mutual labels:  factorization
Prime95
Prime95 source code from GIMPS to find Mersenne Prime.
Stars: ✭ 25 (+92.31%)
Mutual labels:  prime
anomalous-tor-keys
Analysis of archived Tor relay RSA public keys
Stars: ✭ 22 (+69.23%)
Mutual labels:  factorization
RolX
An alternative implementation of Recursive Feature and Role Extraction (KDD11 & KDD12)
Stars: ✭ 52 (+300%)
Mutual labels:  factorization
factordb
RSA primes numbers /RSA/CTFs
Stars: ✭ 42 (+223.08%)
Mutual labels:  factorization
prime-grid
A prime grid for your projects!
Stars: ✭ 24 (+84.62%)
Mutual labels:  prime
M-NMF
An implementation of "Community Preserving Network Embedding" (AAAI 2017)
Stars: ✭ 119 (+815.38%)
Mutual labels:  factorization
fedora-prime
Simple program to switch between intel and nvidia gpu
Stars: ✭ 24 (+84.62%)
Mutual labels:  prime
Abacus
Advanced Combinatorics and Algebraic Number Theory Symbolic Computation library for JavaScript, Python
Stars: ✭ 16 (+23.08%)
Mutual labels:  factorization
easy reader
⏮ ⏯ ⏭ A Rust library for easily navigating forward, backward or randomly through the lines of huge files.
Stars: ✭ 83 (+538.46%)
Mutual labels:  huge
Prime
✨Open Source GraphQL CMS
Stars: ✭ 1,675 (+12784.62%)
Mutual labels:  prime
heroku
Deploy Prime CMS to Heroku in a single click
Stars: ✭ 16 (+23.08%)
Mutual labels:  prime
PrimeG2Pkg
Running Windows on smartphone is not new. How about a calculator?
Stars: ✭ 68 (+423.08%)
Mutual labels:  prime
Awesome Community Detection
A curated list of community detection research papers with implementations.
Stars: ✭ 1,874 (+14315.38%)
Mutual labels:  factorization
Surprise
A Python scikit for building and analyzing recommender systems
Stars: ✭ 5,151 (+39523.08%)
Mutual labels:  factorization
Librec
LibRec: A Leading Java Library for Recommender Systems, see
Stars: ✭ 3,045 (+23323.08%)
Mutual labels:  factorization

PrimeModule

Build Status

Prime module capable of doing prime factorization of huge numbers very quickly.

It can factorize huge numbers (even bigger than PHP_INT_MAX thanks to the wolfram alpha/python modules) very quickly.

Installation:

Install with composer.

composer require danog/primemodule

Install python to enable the python module and the PHP curl extension to enable the wolfram alpha module.

Usage:

This library has 4 prime factorization modules (ordered by speed, huge semiprime is usually a 20 digit semiprime generated by telegram, see the travis ci tests for more stats):

  • native_cpp - A native c++ factorization module (it's the fastest), medium time 0.03943687915802 tested with 100 huge semiprime

  • python - A quadratic sieve python module (usually it's faster than the pollard brent module, other times it just gets stuck (and then killed after 10 seconds by the lib), medium time 0.35134809732437 seconds calculated using 100 huge semiprimes, some of which caused the module to freeze and be killed. Usually it's 10 times faster than the pollard brent module)

  • python_alt - A pollard brent module also written in python (medium time 0.1801231908798 seconds calculated using 100 huge semiprimes)

  • wolfram - A wolfram alpha module (usually takes around 2.1294961380959 seconds calculated using 100 huge semiprimes)

  • native - A native PHP lopatin module (usually takes around 2.5698633241653 seconds calculated using 100 huge semiprimes, may sometimes be faster than the wolfram module: for example on HHVM native factorization usually takes 0.1 seconds)

These modules can be used either in the single variant, which returns only one factor (useful for semiprime factorization), or the full methods, that return an array with all of the factors.

This module was created to do semiprime factorization, so it might not perform very well with composite numbers.

The python/wolframalpha modules accept numeric strings bigger than PHP_INT_MAX, and if the factors are bigger than PHP_INT_MAX they will also returned as a string.

An automatic function can also be used, which chooses automatically the module in the following order: python_alt, python, native, wolfram.

require 'vendor/autoload.php';

// quadratic sieve factorization
$factor = \danog\PrimeModule::python_single(2768594593405030913); // returns 1455582581 or 1902052573
// pollard brent sieve factorization
$factor = \danog\PrimeModule::python_single_alt(2768594593405030913); // returns 1455582581 or 1902052573
// native PHP single factorization
$factor = \danog\PrimeModule::native_single(2768594593405030913); // returns 1455582581 or 1902052573
// wolfram factorization
$factor = \danog\PrimeModule::wolfram_single(2768594593405030913); // returns 1455582581 or 1902052573
// automatic factorization
$factor = \danog\PrimeModule::auto_single(2768594593405030913); // returns 1455582581 or 1902052573


// quadratic sieve factorization
$factor = \danog\PrimeModule::python(15); // returns an array with 3 and 5
// pollard brent sieve factorization
$factor = \danog\PrimeModule::python_alt(15); // returns an array with 3 and 5
// native PHP factorization
$factor = \danog\PrimeModule::native(15); // returns an array with 3 and 5
// wolfram factorization
$factor = \danog\PrimeModule::wolfram(15); // returns an array with 3 and 5
// automatic factorization
$factor = \danog\PrimeModule::auto(15); // returns an array with 3 and 5


See tests/testing.php for more detailed examples.

Library created by Daniil Gentili (https://daniil.it)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].