View source: R/IntegerFactorization.R
primeFactorizeBig | R Documentation |
Quickly generates the prime factorization for many (possibly large) numbers, using trial division, Pollard's rho algorithm, Lenstra's Elliptic Curve method, and finally the Quadratic Sieve.
primeFactorizeBig(v, namedList = FALSE, showStats = FALSE,
skipPolRho = FALSE, skipECM = FALSE, nThreads = NULL)
v |
Vector of integers, numerics, string values, or elements of class bigz. |
namedList |
Logical flag. If |
showStats |
Logical flag for showing summary statistics. The default is |
skipPolRho |
Logical flag for skipping the extended pollard rho algorithm. The default is |
skipECM |
Logical flag for skipping the extended elliptic curve algorithm. The default is |
nThreads |
Number of threads to be used for the elliptic curve method and the quadratic sieve.s The default is |
This function should be preferred in most situations and is identical to quadraticSieve
when both skipECM
and skipPolRho
are set to TRUE
.
It is optimized for factoring big and small numbers by dynamically using different algorithms based off of the input. It takes cares to not spend too much time in any of the methods and avoids wastefully switching to the quadratic sieve when the number is very large.
See quadraticSieve
for information regarding showStats
.
Returns an unnamed vector of class bigz if length(v) == 1
regardless of the value of namedList
.
If length(v) > 1
, a named/unnamed list of vectors of class bigz will be returned.
Note, the function primeFactorizeBig(n, skipECM = T, skipPolRho = T)
is the same as quadraticSieve(n)
Joseph Wood
primeFactorize
, primeFactors
, factorize
, quadraticSieve
## Get the prime factorization of a single number
primeFactorizeBig(100)
## Or get the prime factorization of many numbers
set.seed(29)
myVec <- sample(-1000000:1000000, 1000)
system.time(myFacs <- primeFactorizeBig(myVec))
## Return named list
myFacsWithNames <- primeFactorizeBig(myVec, namedList = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.