divisorsRcpp | R Documentation |
Function for generating the complete factorization for a vector of numbers.
divisorsRcpp(v, namedList = FALSE, nThreads = NULL)
v |
Vector of integers or numeric values. Non-integral values will be coerced to whole numbers. |
namedList |
Logical flag. If |
nThreads |
Specific number of threads to be used. The default is |
Efficient algorithm that builds on primeFactorize
to generate the complete factorization of many numbers.
Returns an unnamed vector if length(v) == 1
regardless of the value of namedList
. If v < 2^{31}
, the class of the returned vector will be integer, otherwise the class will be numeric.
If length(v) > 1
, a named/unnamed list of vectors will be returned. If max(bound1, bound2)
< 2^{31}
, the class of each vector will be integer, otherwise the class will be numeric.
The maximum value for each element in v
is 2^{53} - 1
.
Joseph Wood
primeFactorize
## Get the complete factorization of a single number
divisorsRcpp(10^8)
## Or get the complete factorization of many numbers
set.seed(29)
myVec <- sample(-1000000:1000000, 1000)
system.time(myFacs <- divisorsRcpp(myVec))
## Return named list
myFacsWithNames <- divisorsRcpp(myVec, namedList = TRUE)
## Using nThreads
system.time(divisorsRcpp(myVec, nThreads = 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.