jwood000 / RcppAlgos

@@ -91,3 +91,40 @@
Loading
91 91
    ComboGroupsCountCpp(v, numGroups)
92 92
}
93 93
94 +
comboGrid <- function(..., repetition = TRUE) {
95 +
    ## This is from expand.grid
96 +
    nargs <- length(args <- list(...))
97 +
    if (!nargs) 
98 +
        return(as.data.frame(list()))
99 +
    if (nargs == 1L && is.list(a1 <- args[[1L]])) 
100 +
        nargs <- length(args <- a1)
101 +
    if (nargs == 0L) 
102 +
        return(as.data.frame(list()))
103 +
    
104 +
    iArgs <- seq_len(nargs)
105 +
    nmc <- paste0("Var", iArgs)
106 +
    nm <- names(args)
107 +
    if (is.null(nm)) 
108 +
        nm <- nmc
109 +
    else if (any(ng0 <- nzchar(nm))) 
110 +
        nmc[ng0] <- nm[ng0]
111 +
    
112 +
    pools <- args
113 +
    names(pools) <- nmc
114 +
    
115 +
    numChars <- sum(sapply(pools, class) == "character")
116 +
    convertCharToFac <- numChars < length(pools) && length(pools) > 1
117 +
    
118 +
    pools <- lapply(pools, function(x) {
119 +
            t <- sort(unique(x))
120 +
121 +
            if (convertCharToFac && class(t) == "character") {
122 +
                return(factor(t, levels = t))
123 +
            } else {
124 +
                return(t)
125 +
            }
126 +
        })
127 +
    
128 +
    comboGridRcpp(pools, sapply(pools, is.factor), repetition, sum(lengths(pools)))
129 +
}
130 +

@@ -0,0 +1,335 @@
Loading
1 +
#include "CleanConvert.h"
2 +
#include "ComboCartesian.h"
3 +
#include "Eratosthenes.h"
4 +
5 +
enum rcppType {
6 +
    tInt = 0,
7 +
    tDbl = 1,
8 +
    tStr = 2,
9 +
    tLog = 3,
10 +
    tFac = 4
11 +
};
12 +
13 +
void convertToString(std::vector<std::string> &tempVec,
14 +
                     SEXP ListElement, rcppType &typePass, bool bFac) {
15 +
    
16 +
    switch(TYPEOF(ListElement)) {
17 +
        case INTSXP: {
18 +
            if (bFac) {
19 +
                Rcpp::IntegerVector facVec = Rcpp::as<Rcpp::IntegerVector>(ListElement);
20 +
                std::vector<std::string> strVec = Rcpp::as<std::vector<std::string>>(facVec.attr("levels"));
21 +
                typePass = tFac;
22 +
                
23 +
                for (auto v: strVec) {
24 +
                    bool isNum = (!v.empty() && v.find_first_not_of("0123456789.") == std::string::npos);
25 +
                    
26 +
                    if (isNum) {
27 +
                        double n = std::atof(v.c_str());
28 +
                        if (std::floor(n) != n) v += "dbl";
29 +
                    } else {
30 +
                        v += "str";
31 +
                    }
32 +
                    
33 +
                    tempVec.push_back(v);
34 +
                }
35 +
            } else {
36 +
                std::vector<int> intVec = Rcpp::as<std::vector<int>>(ListElement);
37 +
                typePass = tInt;
38 +
                
39 +
                for (auto v: intVec)
40 +
                    tempVec.push_back(std::to_string(v));
41 +
            }
42 +
            
43 +
            break;
44 +
        }
45 +
        case LGLSXP: {
46 +
            std::vector<int> intVec = Rcpp::as<std::vector<int>>(ListElement);
47 +
            typePass = tLog;
48 +
            
49 +
            for (auto v: intVec) {
50 +
                std::string r = std::to_string(v);
51 +
                tempVec.push_back(r + "log");
52 +
            }
53 +
            
54 +
            break;
55 +
        }
56 +
        case REALSXP: {
57 +
            std::vector<double> dblVec = Rcpp::as<std::vector<double>>(ListElement);
58 +
            typePass = tDbl;
59 +
            
60 +
            for (auto v: dblVec) {
61 +
                std::string r = std::to_string(v);
62 +
                
63 +
                while (r.back() == '0')
64 +
                    r.pop_back();
65 +
                
66 +
                if (std::floor(v) != v) r += "dbl";
67 +
                tempVec.push_back(r);
68 +
            }
69 +
            
70 +
            break;
71 +
        }
72 +
        case STRSXP: {
73 +
            std::vector<std::string> strVec = Rcpp::as<std::vector<std::string>>(ListElement);
74 +
            typePass = tStr;
75 +
            
76 +
            for (auto v: strVec) {
77 +
                bool isNum = (!v.empty() && v.find_first_not_of("0123456789.") == std::string::npos);
78 +
                
79 +
                if (isNum) {
80 +
                    double n = std::atof(v.c_str());
81 +
                    if (std::floor(n) != n) v += "dbl";
82 +
                } else {
83 +
                    v += "str";
84 +
                }
85 +
                
86 +
                tempVec.push_back(v);
87 +
            }
88 +
            
89 +
            break;
90 +
        }
91 +
    }
92 +
}
93 +
94 +
template <typename typeVec, typename typeRcpp>
95 +
void GetPureOutput(const std::vector<int> &cartCombs,
96 +
                   const Rcpp::List &RList, const typeVec &standardVec, 
97 +
                   typeRcpp &result, std::size_t nCols, std::size_t nRows) {
98 +
    
99 +
    for (std::size_t i = 0, row = 0; i < nRows; ++i, row += nCols)
100 +
        for (std::size_t j = 0; j < nCols; ++j)
101 +
            result(i, j) = standardVec[cartCombs[row + j]];
102 +
    
103 +
    if (!Rf_isNull(RList.attr("names"))) {
104 +
        Rcpp::CharacterVector myNames = RList.attr("names");
105 +
        colnames(result) = myNames;
106 +
    }
107 +
}
108 +
109 +
SEXP GlueComboCart(const std::vector<int> &cartCombs,
110 +
                   Rcpp::List &RList, const Rcpp::IntegerVector &intVec,
111 +
                   const Rcpp::LogicalVector &boolVec, const Rcpp::NumericVector &dblVec,
112 +
                   const Rcpp::CharacterVector &charVec, 
113 +
                   const std::vector<std::vector<int>> &facList,
114 +
                   std::vector<int> &typeCheck, bool IsDF, std::size_t nRows,
115 +
                   std::size_t nCols, std::vector<int> IsFactor) {
116 +
    
117 +
    if (IsDF) {
118 +
        Rcpp::List resList(nCols);
119 +
        
120 +
        for (std::size_t i = 0, facInd = 0; i < nCols; ++i) {
121 +
            switch (TYPEOF(RList[i])) {
122 +
                case INTSXP: {
123 +
                    Rcpp::IntegerVector rcppVec = Rcpp::no_init_vector(nRows);
124 +
                    Rcpp::IntegerVector facVec(facList[facInd].cbegin(), facList[facInd].cend());
125 +
126 +
                    if (IsFactor[i]) {
127 +
                        for (std::size_t j = 0, row = i; j < nRows; ++j, row += nCols)
128 +
                            rcppVec[j] = facVec[cartCombs[row]];
129 +
                        
130 +
                        Rcpp::IntegerVector testFactor = Rcpp::as<Rcpp::IntegerVector>(RList[i]);
131 +
                        Rcpp::CharacterVector myClass = testFactor.attr("class");
132 +
                        Rcpp::CharacterVector myLevels = testFactor.attr("levels");
133 +
                        rcppVec.attr("class") = myClass;
134 +
                        rcppVec.attr("levels") = myLevels;
135 +
                        ++facInd;
136 +
                    } else {
137 +
                        for (std::size_t j = 0, row = i; j < nRows; ++j, row += nCols)
138 +
                            rcppVec[j] = intVec[cartCombs[row]];
139 +
                    }
140 +
141 +
                    resList[i] = rcppVec;
142 +
                    break;
143 +
                }
144 +
                case LGLSXP: {
145 +
                    Rcpp::LogicalVector rcppVec = Rcpp::no_init_vector(nRows);
146 +
147 +
                    for (std::size_t j = 0, row = i; j < nRows; ++j, row += nCols)
148 +
                        rcppVec[j] = boolVec[cartCombs[row]];
149 +
150 +
                    resList[i] = rcppVec;
151 +
                    break;
152 +
                }
153 +
                case REALSXP: {
154 +
                    Rcpp::NumericVector rcppVec = Rcpp::no_init_vector(nRows);
155 +
156 +
                    for (std::size_t j = 0, row = i; j < nRows; ++j, row += nCols)
157 +
                        rcppVec[j] = dblVec[cartCombs[row]];
158 +
159 +
                    resList[i] = rcppVec;
160 +
                    break;
161 +
                }
162 +
                case STRSXP: {
163 +
                    Rcpp::CharacterVector rcppVec = Rcpp::no_init_vector(nRows);
164 +
165 +
                    for (std::size_t j = 0, row = i; j < nRows; ++j, row += nCols)
166 +
                        rcppVec[j] = charVec[cartCombs[row]];
167 +
168 +
                    resList[i] = rcppVec;
169 +
                    break;
170 +
                }
171 +
            }
172 +
        }
173 +
174 +
        Rcpp::DataFrame myDF(resList);
175 +
        myDF.attr("names") = RList.attr("names");
176 +
        return myDF;
177 +
178 +
    } else {
179 +
        if (typeCheck[tInt]) {
180 +
            Rcpp::IntegerMatrix intMat = Rcpp::no_init_matrix(nRows, nCols);
181 +
            GetPureOutput(cartCombs, RList, intVec, intMat, nCols, nRows);
182 +
            return intMat;
183 +
        } else if (typeCheck[tFac]) {
184 +
            Rcpp::IntegerMatrix intMat = Rcpp::no_init_matrix(nRows, nCols);
185 +
            GetPureOutput(cartCombs, RList, facList.front(), intMat, nCols, nRows);
186 +
            Rcpp::IntegerVector testFactor = Rcpp::as<Rcpp::IntegerVector>(RList[0]);
187 +
            Rcpp::CharacterVector myClass = testFactor.attr("class");
188 +
            Rcpp::CharacterVector myLevels = testFactor.attr("levels");
189 +
            intMat.attr("class") = myClass;
190 +
            intMat.attr("levels") = myLevels;
191 +
            return intMat;
192 +
        } else if (typeCheck[tLog]) {
193 +
            Rcpp::LogicalMatrix boolMat = Rcpp::no_init_matrix(nRows, nCols);
194 +
            GetPureOutput(cartCombs, RList, boolVec, boolMat, nCols, nRows);
195 +
            return boolMat;
196 +
        } else if (typeCheck[tDbl]) {
197 +
            Rcpp::NumericMatrix dblMat = Rcpp::no_init_matrix(nRows, nCols);
198 +
            GetPureOutput(cartCombs, RList, dblVec, dblMat, nCols, nRows);
199 +
            return dblMat;
200 +
        } else {
201 +
            Rcpp::CharacterMatrix charMat = Rcpp::no_init_matrix(nRows, nCols);
202 +
            GetPureOutput(cartCombs, RList, charVec, charMat, nCols, nRows);
203 +
            return charMat;
204 +
        }
205 +
    }
206 +
}
207 +
208 +
void getAtLeastNPrimes(std::vector<int> &primes, std::size_t sumLength) {
209 +
210 +
    double limit = 100;
211 +
    std::size_t guess = PrimeSieve::EstimatePiPrime(1.0, limit);
212 +
213 +
    while (guess < (1.1 * sumLength)) {
214 +
        limit *= 2;
215 +
        guess = PrimeSieve::EstimatePiPrime(1.0, limit);
216 +
    }
217 +
    
218 +
    bool tempPar = false;
219 +
    int_fast64_t intMin = static_cast<int_fast64_t>(1);
220 +
    int_fast64_t intMax = static_cast<int_fast64_t>(limit);
221 +
    std::vector<std::vector<int>> tempList;
222 +
    
223 +
    PrimeSieve::PrimeSieveMaster(intMin, intMax, primes, tempList, tempPar);
224 +
}
225 +
226 +
// [[Rcpp::export]]
227 +
SEXP comboGridRcpp(Rcpp::List RList, std::vector<int> IsFactor,
228 +
                   bool IsRep, std::size_t sumLength) {
229 +
    
230 +
    std::vector<int> primes;
231 +
    getAtLeastNPrimes(primes, sumLength);
232 +
    std::size_t numFactorVec = std::accumulate(IsFactor.cbegin(), IsFactor.cend(), 0);
233 +
    
234 +
    // All duplicates have been removed from RList via lapply(RList, function(x) sort(unique(x)))
235 +
    std::size_t nCols = RList.size();
236 +
    std::vector<std::vector<int>> myVec(nCols);
237 +
    std::unordered_map<std::string, int> mapIndex;
238 +
    std::vector<int> typeCheck(5, 0);
239 +
    
240 +
    Rcpp::CharacterVector charVec(sumLength);
241 +
    Rcpp::NumericVector dblVec(sumLength);
242 +
    Rcpp::IntegerVector intVec(sumLength);
243 +
    Rcpp::LogicalVector boolVec(sumLength);
244 +
    
245 +
    std::vector<std::vector<int>> facList(numFactorVec,
246 +
                                          std::vector<int>(sumLength, 0));
247 +
    
248 +
    for (std::size_t i = 0, total = 0, myIndex = 0, facInd = 0; i < nCols; ++i) {
249 +
        std::vector<std::string> tempVec;
250 +
        rcppType myType;
251 +
        
252 +
        convertToString(tempVec, RList[i], myType, IsFactor[i]);
253 +
        std::size_t j = 0;
254 +
        
255 +
        for (const auto &v: tempVec) {
256 +
            if (mapIndex.empty()) {
257 +
                mapIndex.insert({v, total});
258 +
            } else {
259 +
                auto mapCheck = mapIndex.find(v);
260 +
                
261 +
                if (mapCheck == mapIndex.end()) {
262 +
                    ++total;
263 +
                    mapIndex.insert({v, total});
264 +
                    myIndex = total;
265 +
                } else {
266 +
                    myIndex = mapCheck->second;
267 +
                }
268 +
            }
269 +
            
270 +
            myVec[i].push_back(myIndex);
271 +
            
272 +
            switch(myType) {
273 +
                case tInt: {
274 +
                    intVec[myIndex] = Rcpp::as<Rcpp::IntegerVector>(RList[i])[j];
275 +
                    typeCheck[tInt] = 1;
276 +
                    break;
277 +
                }
278 +
                case tFac: {
279 +
                    facList[facInd][myIndex] = Rcpp::as<std::vector<int>>(RList[i])[j];
280 +
                    typeCheck[tFac] = 1;
281 +
                    break;
282 +
                }
283 +
                case tDbl: {
284 +
                    dblVec[myIndex] = Rcpp::as<Rcpp::NumericVector>(RList[i])[j];
285 +
                    typeCheck[tDbl] = 1;
286 +
                    break;
287 +
                }
288 +
                case tStr: {
289 +
                    charVec[myIndex] = Rcpp::as<Rcpp::CharacterVector>(RList[i])[j];
290 +
                    typeCheck[tStr] = 1;
291 +
                    break;
292 +
                }
293 +
                case tLog: {
294 +
                    boolVec[myIndex] = Rcpp::as<Rcpp::LogicalVector>(RList[i])[j];
295 +
                    typeCheck[tLog] = 1;
296 +
                    break;
297 +
                }
298 +
            }
299 +
            
300 +
            ++j;
301 +
        }
302 +
        
303 +
        facInd += IsFactor[i];
304 +
    }
305 +
    
306 +
    int mySum = std::accumulate(typeCheck.cbegin(), typeCheck.cend(), 0);
307 +
    std::vector<std::string> testLevels;
308 +
    Rcpp::IntegerVector facVec(sumLength);
309 +
    
310 +
    if (typeCheck[tFac] && mySum == 1) {
311 +
        for (std::size_t i = 0; i < nCols; ++i) {
312 +
            if (IsFactor[i]) {
313 +
                facVec = Rcpp::as<Rcpp::IntegerVector>(RList[i]);
314 +
                std::vector<std::string> strVec = Rcpp::as<std::vector<std::string>>(facVec.attr("levels"));
315 +
                
316 +
                if (testLevels.size()) {
317 +
                    if (strVec != testLevels) {
318 +
                        ++mySum;
319 +
                        break;
320 +
                    }
321 +
                } else {
322 +
                    testLevels = strVec;
323 +
                }
324 +
            }
325 +
        }
326 +
    }
327 +
    
328 +
    bool IsDF = (mySum > 1) ? true : false;
329 +
    std::vector<int> cartCombs;
330 +
    comboGrid(cartCombs, IsRep, myVec, primes);
331 +
    
332 +
    const std::size_t nRows = cartCombs.size() / nCols;
333 +
    return GlueComboCart(cartCombs, RList, intVec, boolVec, dblVec,
334 +
                         charVec, facList, typeCheck, IsDF, nRows, nCols, IsFactor);
335 +
}

@@ -41,7 +41,7 @@
Loading
41 41
                                                   10000000000000000.0}};
42 42
    
43 43
    // The following function is based off of the prime number theorem
44 -
    inline std::size_t EstimatePiPrime(double minNum, double maxNum) {
44 +
    std::size_t EstimatePiPrime(double minNum, double maxNum) {
45 45
        const auto it = std::upper_bound(CUTPOINTS.cbegin(), CUTPOINTS.cend(), maxNum);
46 46
        const std::size_t myIndex = it - CUTPOINTS.cbegin();
47 47
        double dblRes = std::ceil((maxNum / std::log(maxNum)) * (1 + PERCINC[myIndex]));

@@ -0,0 +1,182 @@
Loading
1 +
#include <Rcpp.h>
2 +
#include <gmp.h>
3 +
#include <unordered_set>
4 +
#include "Cpp14MakeUnique.h"
5 +
6 +
constexpr int base10 = 10;
7 +
8 +
void comboGrid(std::vector<int> &cartCombs, bool IsRep,
9 +
               const std::vector<std::vector<int>> &myVec, 
10 +
               const std::vector<int> &primes) {
11 +
    
12 +
    std::unordered_set<uint64_t> uintHash;
13 +
    std::vector<uint64_t> uintKeyKeeper;
14 +
    uint64_t maxKey = 0;
15 +
    
16 +
    for (const auto ind: myVec[0]) {
17 +
        uint64_t key = primes[ind];
18 +
        
19 +
        if (key > maxKey) {
20 +
            maxKey = key;
21 +
        }
22 +
        
23 +
        const auto it = uintHash.find(key);
24 +
        
25 +
        if (it == uintHash.end()) {
26 +
            uintHash.insert(key);
27 +
            cartCombs.push_back(ind);
28 +
            uintKeyKeeper.push_back(key);
29 +
        }
30 +
    }
31 +
    
32 +
    std::size_t i = 1;
33 +
    bool NeedsMpz = false;
34 +
35 +
    for (; i < myVec.size(); ++i) {
36 +
        if ((std::numeric_limits<uint64_t>::max() / maxKey) < primes[myVec[i].back()]) {
37 +
            NeedsMpz = true;
38 +
            break;
39 +
        }
40 +
41 +
        const std::vector<int> tempCombs = cartCombs;
42 +
        const std::vector<uint64_t> tempKeyKeeper = uintKeyKeeper;
43 +
44 +
        cartCombs.clear();
45 +
        uintKeyKeeper.clear();
46 +
        uintHash.clear();
47 +
        
48 +
        cartCombs.reserve(tempKeyKeeper.size() * myVec[i].size() * (i + 1));
49 +
        uintKeyKeeper.reserve(tempKeyKeeper.size() * myVec[i].size());
50 +
        uintHash.reserve(tempKeyKeeper.size() * myVec[i].size());
51 +
        
52 +
        if (IsRep) {
53 +
            for (std::size_t j = 0, myStrt = 0, myEnd = i;
54 +
                 j < tempKeyKeeper.size(); ++j, myStrt = myEnd, myEnd += i) {
55 +
    
56 +
                const uint64_t masterKey = tempKeyKeeper[j];
57 +
                const std::vector<int> masterVec(tempCombs.begin() + myStrt, tempCombs.begin() + myEnd);
58 +
    
59 +
                for (const auto ind: myVec[i]) {
60 +
                    uint64_t key = masterKey * primes[ind];
61 +
                    const auto it = uintHash.find(key);
62 +
                    
63 +
                    if (key > maxKey) {
64 +
                        maxKey = key;
65 +
                    }
66 +
    
67 +
                    if (it == uintHash.end()) {
68 +
                        std::vector<int> vecVal = masterVec;
69 +
                        vecVal.push_back(ind);
70 +
                        uintHash.insert(key);
71 +
                        cartCombs.insert(cartCombs.end(), vecVal.cbegin(), vecVal.cend());
72 +
                        uintKeyKeeper.push_back(key);
73 +
                    }
74 +
                }
75 +
            }
76 +
        } else {
77 +
            for (std::size_t j = 0, myStrt = 0, myEnd = i;
78 +
                 j < tempKeyKeeper.size(); ++j, myStrt = myEnd, myEnd += i) {
79 +
                
80 +
                const uint64_t masterKey = tempKeyKeeper[j];
81 +
                const std::vector<int> masterVec(tempCombs.begin() + myStrt, tempCombs.begin() + myEnd);
82 +
                
83 +
                for (const auto ind: myVec[i]) {
84 +
                    if (masterKey % primes[ind] != 0) {
85 +
                        uint64_t key = masterKey * primes[ind];
86 +
                        const auto it = uintHash.find(key);
87 +
                        
88 +
                        if (key > maxKey) {
89 +
                            maxKey = key;
90 +
                        }
91 +
                        
92 +
                        if (it == uintHash.end()) {
93 +
                            std::vector<int> vecVal = masterVec;
94 +
                            vecVal.push_back(ind);
95 +
                            uintHash.insert(key);
96 +
                            cartCombs.insert(cartCombs.end(), vecVal.cbegin(), vecVal.cend());
97 +
                            uintKeyKeeper.push_back(key);
98 +
                        }
99 +
                    }
100 +
                }
101 +
            }
102 +
        }
103 +
    }
104 +
    
105 +
    if (NeedsMpz) {
106 +
        Rcpp::Rcout << maxKey << "\n";
107 +
        std::vector<std::string> strKeyKeeper(uintKeyKeeper.size());
108 +
        
109 +
        for (std::size_t j = 0; j < uintKeyKeeper.size(); ++j)
110 +
            strKeyKeeper[j] = std::to_string(uintKeyKeeper[j]);
111 +
        
112 +
        std::unordered_set<std::string> strHash;
113 +
        
114 +
        mpz_t masterKey, key;
115 +
        mpz_init(masterKey); mpz_init(key);
116 +
        
117 +
        for (; i < myVec.size(); ++i) {
118 +
            const std::vector<int> tempCombs = cartCombs;
119 +
            const std::vector<std::string> tempKeyKeeper = strKeyKeeper;
120 +
            
121 +
            cartCombs.clear();
122 +
            strKeyKeeper.clear();
123 +
            strHash.clear();
124 +
            
125 +
            cartCombs.reserve(tempKeyKeeper.size() * myVec[i].size() * (i + 1));
126 +
            strKeyKeeper.reserve(tempKeyKeeper.size() * myVec[i].size());
127 +
            strHash.reserve(tempKeyKeeper.size() * myVec[i].size());
128 +
            
129 +
            if (IsRep) {
130 +
                for (std::size_t j = 0, myStrt = 0, myEnd = i;
131 +
                     j < tempKeyKeeper.size(); ++j, myStrt = myEnd, myEnd += i) {
132 +
                    
133 +
                    mpz_set_str(masterKey, tempKeyKeeper[j].c_str(), base10);
134 +
                    const std::vector<int> masterVec(tempCombs.begin() + myStrt, tempCombs.begin() + myEnd);
135 +
                    
136 +
                    for (const auto ind: myVec[i]) {
137 +
                        mpz_mul_si(key, masterKey, primes[ind]);
138 +
                        auto buffer = FromCpp14::make_unique<char[]>(mpz_sizeinbase(key, base10) + 2);
139 +
                        mpz_get_str(buffer.get(), base10, key);
140 +
                        const std::string strKey = buffer.get();
141 +
                        const auto it = strHash.find(strKey);
142 +
    
143 +
                        if (it == strHash.end()) {
144 +
                            std::vector<int> vecVal = masterVec;
145 +
                            vecVal.push_back(ind);
146 +
                            strHash.insert(strKey);
147 +
                            cartCombs.insert(cartCombs.end(), vecVal.cbegin(), vecVal.cend());
148 +
                            strKeyKeeper.push_back(strKey);
149 +
                        }
150 +
                    }
151 +
                }
152 +
            } else {
153 +
                for (std::size_t j = 0, myStrt = 0, myEnd = i;
154 +
                     j < tempKeyKeeper.size(); ++j, myStrt = myEnd, myEnd += i) {
155 +
                    
156 +
                    mpz_set_str(masterKey, tempKeyKeeper[j].c_str(), base10);
157 +
                    const std::vector<int> masterVec(tempCombs.begin() + myStrt, tempCombs.begin() + myEnd);
158 +
                    
159 +
                    for (const auto ind: myVec[i]) {
160 +
                        if (mpz_divisible_ui_p(masterKey, primes[ind]) == 0) {
161 +
                            mpz_mul_si(key, masterKey, primes[ind]);
162 +
                            auto buffer = FromCpp14::make_unique<char[]>(mpz_sizeinbase(key, base10) + 2);
163 +
                            mpz_get_str(buffer.get(), base10, key);
164 +
                            const std::string strKey = buffer.get();
165 +
                            const auto it = strHash.find(strKey);
166 +
                            
167 +
                            if (it == strHash.end()) {
168 +
                                std::vector<int> vecVal = masterVec;
169 +
                                vecVal.push_back(ind);
170 +
                                strHash.insert(strKey);
171 +
                                cartCombs.insert(cartCombs.end(), vecVal.cbegin(), vecVal.cend());
172 +
                                strKeyKeeper.push_back(strKey);
173 +
                            }
174 +
                        }
175 +
                    }
176 +
                }
177 +
            }
178 +
        }
179 +
        
180 +
        mpz_clear(masterKey); mpz_clear(key);
181 +
    }
182 +
}
Files Coverage
R 92.71%
inst/include 96.88%
src 93.65%
Project Totals (62 files) 93.90%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading