divisorsRcpp {RcppAlgos} | R Documentation |
Vectorized Factorization (Complete)
Description
Function for generating the complete factorization for a vector of numbers.
Usage
divisorsRcpp(v, namedList = FALSE, nThreads = NULL)
Arguments
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 |
Details
Efficient algorithm that builds on primeFactorize
to generate the complete factorization of many numbers.
Value
Returns an unnamed vector if
length(v) == 1
regardless of the value ofnamedList
. Ifv < 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. Ifmax(bound1, bound2)
< 2^{31}
, the class of each vector will be integer, otherwise the class will be numeric.
Note
The maximum value for each element in v
is 2^{53} - 1
.
Author(s)
Joseph Wood
References
See Also
Examples
## 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))