jwood000 / RcppAlgos

Compare 435ef31 ... +4 ... 15ad291

Coverage Reach
src/Eratosthenes.cpp src/ComboFunClass.cpp src/ComboClass.cpp src/NthResult.cpp src/ConstraintsUtils.cpp src/PollardRhoUtils.cpp src/ComboGroups.cpp src/PrimeCount.cpp src/CartesianContainer.cpp src/NextPartitions.cpp src/StandardCount.cpp src/GmpDependUtils.cpp src/StandardUtils.cpp src/ConstraintsGeneral.cpp src/GetLowerBound.cpp src/SampCombPerm.cpp src/PartitionsGeneral.cpp src/PartitionEsqueAlgo.cpp src/BigNumCount.cpp src/ConstraintsMaster.cpp src/DivNumSieve.cpp src/CombPermMaster.cpp src/ComboGroupsUtils.cpp src/PartitionsMaster.cpp src/ComboCartesian.cpp src/PollardRho.cpp src/MotleyPrimes.cpp src/PollardRhoDepends.cpp src/PartitionsCounts.cpp src/PermutationResults.cpp src/PrevCombinatorics.cpp src/ComboClassUtils.cpp src/CombinatoricsApply.cpp src/PrimeFactorizeSieve.cpp src/ImportExportMPZ.cpp src/PrimeSieve.cpp src/NextCombinatorics.cpp src/EulerPhiSieve.cpp src/ConstraintsSpecial.cpp src/CombinationResults.cpp src/CheckReturn.cpp src/CombinatoricsCount.cpp src/CombPermPtr.cpp src/NumThreads.cpp inst/include/Permutations.h inst/include/UserConstraintFuns.h inst/include/NextStandard.h inst/include/PermutationsApply.h inst/include/CombinationApply.h inst/include/Combinations.h inst/include/PhiTinyLookup.h inst/include/ConstraintsUtils.h inst/include/GmpDependUtils.h inst/include/CombPermResultPtr.h inst/include/MotleyStartIndex.h inst/include/RMatrix.h inst/include/Cpp14MakeUnique.h inst/include/ComboFunClass.h inst/include/ComboClass.h R/Combinatorics.R R/CombPermIterator.R R/NumberTheory.R

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -1,18 +1,94 @@
Loading
1 1
#include "ComboClass.h"
2 2
3 +
SEXP Combo::VecReturn(const SEXP &v) {
4 +
    
5 +
    switch (TYPEOF(v)) {
6 +
        case LGLSXP: {
7 +
            Rcpp::LogicalVector boolVec(Rcpp::clone(v));
8 +
            return VecPopulate(boolVec);
9 +
        } case INTSXP: {
10 +
            Rcpp::IntegerVector intVec(Rcpp::clone(v));
11 +
            return VecPopulate(intVec);
12 +
        } case STRSXP: {
13 +
            Rcpp::CharacterVector charVec(Rcpp::clone(v));
14 +
            return VecPopulate(charVec);
15 +
        } case CPLXSXP: {
16 +
            Rcpp::ComplexVector cmplxVec(Rcpp::clone(v));
17 +
            return VecPopulate(cmplxVec);
18 +
        } case RAWSXP: {
19 +
            Rcpp::RawVector rawVec(Rcpp::clone(v));
20 +
            return VecPopulate(rawVec);
21 +
        } default: {
22 +
            Rcpp::NumericVector numVec(Rcpp::clone(v));
23 +
            return VecPopulate(numVec);
24 +
        }
25 +
    }
26 +
}
27 +
28 +
SEXP Combo::MatReturn(const SEXP &v, int nr, bool IsReverse) {
29 +
    
30 +
    switch (TYPEOF(v)) {
31 +
        case LGLSXP: {
32 +
            Rcpp::LogicalVector bv(Rcpp::clone(v));
33 +
            return (IsReverse) ? MatComboReverse(bv, nr) : MatCombo(bv, nr);
34 +
        } case INTSXP: {
35 +
            Rcpp::IntegerVector iv(Rcpp::clone(v));
36 +
            return (IsReverse) ? MatComboReverse(iv, nr) : MatCombo(iv, nr);
37 +
        } case STRSXP: {
38 +
            Rcpp::CharacterVector cv(Rcpp::clone(v));
39 +
            return (IsReverse) ? MatComboReverse(cv, nr) : MatCombo(cv, nr);
40 +
        } case CPLXSXP: {
41 +
            Rcpp::ComplexVector xv(Rcpp::clone(v));
42 +
            return (IsReverse) ? MatComboReverse(xv, nr) : MatCombo(xv, nr);
43 +
        } case RAWSXP: {
44 +
            Rcpp::RawVector rv(Rcpp::clone(v));
45 +
            return (IsReverse) ? MatComboReverse(rv, nr) : MatCombo(rv, nr);
46 +
        } default: {
47 +
            Rcpp::NumericVector nv(Rcpp::clone(v));
48 +
            return (IsReverse) ? MatComboReverse(nv, nr) : MatCombo(nv, nr);
49 +
        }
50 +
    }
51 +
}
52 +
53 +
SEXP Combo::SampReturn(const SEXP &v, const std::vector<double> &mySample,
54 +
                       mpz_t *const myBigSamp, std::size_t sampSize) {
55 +
    
56 +
    switch (TYPEOF(v)) {
57 +
        case LGLSXP: {
58 +
            Rcpp::LogicalVector boolVec(Rcpp::clone(v));
59 +
            return SampMatrix(boolVec, mySample, myBigSamp, sampSize);
60 +
        } case INTSXP: {
61 +
            Rcpp::IntegerVector intVec(Rcpp::clone(v));
62 +
            return SampMatrix(intVec, mySample, myBigSamp, sampSize);
63 +
        } case STRSXP: {
64 +
            Rcpp::CharacterVector charVec(Rcpp::clone(v));
65 +
            return SampMatrix(charVec, mySample, myBigSamp, sampSize);
66 +
        } case CPLXSXP: {
67 +
            Rcpp::ComplexVector cmplxVec(Rcpp::clone(v));
68 +
            return SampMatrix(cmplxVec, mySample, myBigSamp, sampSize);
69 +
        } case RAWSXP: {
70 +
            Rcpp::RawVector rawVec(Rcpp::clone(v));
71 +
            return SampMatrix(rawVec, mySample, myBigSamp, sampSize);
72 +
        } default: {
73 +
            Rcpp::NumericVector numVec(Rcpp::clone(v));
74 +
            return SampMatrix(numVec, mySample, myBigSamp, sampSize);
75 +
        }
76 +
    }
77 +
}
78 +
3 79
template <int RTYPE>
4 -
Rcpp::Vector<RTYPE> Combo::VecRes(const Rcpp::Vector<RTYPE> &v) {
80 +
Rcpp::Vector<RTYPE> Combo::VecPopulate(const Rcpp::Vector<RTYPE> &v) {
5 81
    
6 82
    Rcpp::Vector<RTYPE> vOut(m);
7 -
83 +
    
8 84
    for (int j = 0; j < m; ++j)
9 85
        vOut[j] = v[z[j]];
10 -
86 +
    
11 87
    if (IsFactor) {
12 88
        Rf_setAttrib(vOut, R_ClassSymbol, myClass);
13 89
        Rf_setAttrib(vOut, R_LevelsSymbol, myLevels);
14 90
    }
15 -
91 +
    
16 92
    return vOut;
17 93
}
18 94
@@ -152,11 +228,11 @@
Loading
152 228
    
153 229
    if (CheckEqSi(IsGmp, mpzIndex[0], dblIndex, 0)) {
154 230
        increment(IsGmp, mpzIndex[0], dblIndex);
155 -
        RCPP_RETURN_VECTOR(VecRes, sexpVec);
231 +
        return VecReturn(sexpVec);
156 232
    } else if (CheckIndLT(IsGmp, mpzIndex[0], dblIndex, computedRowsMpz[0], computedRows)) {
157 233
        increment(IsGmp, mpzIndex[0], dblIndex);
158 234
        nextIter(freqs, z, n1, m1);
159 -
        RCPP_RETURN_VECTOR(VecRes, sexpVec);
235 +
        return VecReturn(sexpVec);
160 236
    } else if (CheckEqInd(IsGmp, mpzIndex[0], dblIndex, computedRowsMpz[0], computedRows)) {
161 237
        Rcpp::Rcout << "No more results. To see the last result,"
162 238
                       " use the prevIter method(s)\n" << std::endl;
@@ -171,11 +247,11 @@
Loading
171 247
    
172 248
    if (CheckIndGrT(IsGmp, mpzIndex[0], dblIndex, computedRowsMpz[0], computedRows)) {
173 249
        decrement(IsGmp, mpzIndex[0], dblIndex);
174 -
        RCPP_RETURN_VECTOR(VecRes, sexpVec);
250 +
        return VecReturn(sexpVec);
175 251
    } else if (CheckGrTSi(IsGmp, mpzIndex[0], dblIndex, 1)) {
176 252
        decrement(IsGmp, mpzIndex[0], dblIndex);
177 253
        prevIter(freqs, z, n1, m1);
178 -
        RCPP_RETURN_VECTOR(VecRes, sexpVec);
254 +
        return VecReturn(sexpVec);
179 255
    } else if (CheckEqSi(IsGmp, mpzIndex[0], dblIndex, 1)) {
180 256
        Rcpp::Rcout << "Iterator Initialized. To see the first result,"
181 257
                       " use the nextIter method(s)\n" << std::endl;
@@ -209,7 +285,7 @@
Loading
209 285
            nextIter(freqs, z, n1, m1);
210 286
        
211 287
        increment(IsGmp, mpzIndex[0], dblIndex, numIncrement);
212 -
        RCPP_RETURN_VECTOR(MatCombo, sexpVec, nRows);
288 +
        return MatReturn(sexpVec, nRows, false);
213 289
    } else if (CheckEqInd(IsGmp, mpzIndex[0], dblIndex, computedRowsMpz[0], computedRows)) {
214 290
        Rcpp::Rcout << "No more results. To see the last result,"
215 291
                       " use the prevIter method(s)\n" << std::endl;
@@ -243,7 +319,7 @@
Loading
243 319
            prevIter(freqs, z, n1, m1);
244 320
        
245 321
        decrement(IsGmp, mpzIndex[0], dblIndex, numDecrement);
246 -
        RCPP_RETURN_VECTOR(MatComboReverse, sexpVec, nRows);
322 +
        return MatReturn(sexpVec, nRows, true);
247 323
    } else if (CheckEqSi(IsGmp, mpzIndex[0], dblIndex, 2)) {
248 324
        Rcpp::Rcout << "No more results. To see the last result,"
249 325
                       " use the prevIter method(s)\n" << std::endl;
@@ -284,7 +360,7 @@
Loading
284 360
            dblIndex = computedRows + 1;
285 361
        }
286 362
        
287 -
        RCPP_RETURN_VECTOR(MatCombo, sexpVec, nRows);
363 +
        return MatReturn(sexpVec, nRows, false);
288 364
    } else {
289 365
        return Rcpp::wrap(false);
290 366
    }
@@ -320,7 +396,7 @@
Loading
320 396
            dblIndex = 0;
321 397
        }
322 398
        
323 -
        RCPP_RETURN_VECTOR(MatComboReverse, sexpVec, nRows);
399 +
        return MatReturn(sexpVec, nRows, true);
324 400
    } else {
325 401
        return Rcpp::wrap(false);
326 402
    }
@@ -333,7 +409,7 @@
Loading
333 409
                        " use the prevIter method(s)\n" << std::endl;
334 410
        return Rcpp::wrap(false);
335 411
    } else if (CheckGrTSi(IsGmp, mpzIndex[0], dblIndex, 0)) {
336 -
        RCPP_RETURN_VECTOR(VecRes, sexpVec);
412 +
        return VecReturn(sexpVec);
337 413
    } else {
338 414
        Rcpp::Rcout << "Iterator Initialized. To see the first result,"
339 415
                       " use the nextIter method(s)\n" << std::endl;
@@ -357,7 +433,7 @@
Loading
357 433
        SetIndexVecMpz(RindexVec, mpzVec.get(), sampSize, computedRowsMpz[0]);
358 434
359 435
    if (sampSize > 1) {
360 -
        RCPP_RETURN_VECTOR(SampMatrix, sexpVec, mySample, mpzVec.get(), sampSize);
436 +
        return SampReturn(sexpVec, mySample, mpzVec.get(), sampSize);
361 437
    } else {
362 438
        if (IsGmp) {
363 439
            mpz_add_ui(mpzIndex[0], mpzVec[0], 1u);
@@ -369,7 +445,7 @@
Loading
369 445
        
370 446
        z = nthResFun(n, m, dblTemp, mpzTemp, myReps);
371 447
        TopOffPartialPerm(z, myReps, n, m, IsComb, IsRep, IsMult);
372 -
        RCPP_RETURN_VECTOR(VecRes, sexpVec);
448 +
        return VecReturn(sexpVec);
373 449
    }
374 450
}
375 451
@@ -385,7 +461,7 @@
Loading
385 461
    
386 462
    z = nthResFun(n, m, dblTemp, mpzTemp, myReps);
387 463
    TopOffPartialPerm(z, myReps, n, m, IsComb, IsRep, IsMult);
388 -
    RCPP_RETURN_VECTOR(VecRes, sexpVec);
464 +
    return VecReturn(sexpVec);
389 465
}
390 466
391 467
SEXP Combo::back() {
@@ -400,7 +476,7 @@
Loading
400 476
    
401 477
    z = nthResFun(n, m, dblTemp, mpzTemp, myReps);
402 478
    TopOffPartialPerm(z, myReps, n, m, IsComb, IsRep, IsMult);
403 -
    RCPP_RETURN_VECTOR(VecRes, sexpVec);
479 +
    return VecReturn(sexpVec);
404 480
}
405 481
406 482
SEXP Combo::sourceVector() const {

@@ -43,8 +43,13 @@
Loading
43 43
    // depends on freqs.size, IsMult, and n
44 44
    const int n1;
45 45
    
46 +
    SEXP VecReturn(const SEXP &v);
47 +
    SEXP MatReturn(const SEXP &v, int nRows, bool IsReverse);
48 +
    SEXP SampReturn(const SEXP &v, const std::vector<double> &mySample,
49 +
                    mpz_t *const myBigSamp, std::size_t sampSize);
50 +
    
46 51
    template <int RTYPE>
47 -
    Rcpp::Vector<RTYPE> VecRes(const Rcpp::Vector<RTYPE> &v);
52 +
    Rcpp::Vector<RTYPE> VecPopulate(const Rcpp::Vector<RTYPE> &v);
48 53
    
49 54
    template <int RTYPE>
50 55
    Rcpp::Matrix<RTYPE> MatCombo(const Rcpp::Vector<RTYPE> &v, int nRows);

@@ -33,19 +33,16 @@
Loading
33 33
}
34 34
35 35
template <int RTYPE>
36 -
Rcpp::Matrix<RTYPE> SampNoThrdSafe(const Rcpp::Vector<RTYPE> &v, const std::vector<int> &myReps,
37 -
                                   const std::vector<double> &mySample, mpz_t *const myBigSamp, 
38 -
                                   std::size_t m, std::size_t sampSize, nthResultPtr nthResFun,
39 -
                                   int lenV, bool IsGmp, bool IsNamed) {
36 +
void SampNoThrdSafe(const Rcpp::Vector<RTYPE> &v, Rcpp::Matrix<RTYPE> &matRcpp,
37 +
                    const std::vector<int> &myReps, const std::vector<double> &mySample,
38 +
                    mpz_t *const myBigSamp, std::size_t m, std::size_t sampSize,
39 +
                    nthResultPtr nthResFun, int lenV, bool IsGmp, bool IsNamed) {
40 40
    
41 -
    Rcpp::Matrix<RTYPE> matRcpp = Rcpp::no_init_matrix(sampSize, m);
42 41
    SampleResults(v, m, myReps, 0, sampSize, nthResFun,
43 42
                  mySample, myBigSamp, matRcpp, lenV, IsGmp);
44 43
    
45 44
    if (IsNamed)
46 45
        SetSampleNames(IsGmp, sampSize, matRcpp, mySample, myBigSamp);
47 -
    
48 -
    return matRcpp;
49 46
}
50 47
51 48
template <typename typeRcpp, typename typeVector>
@@ -59,13 +56,13 @@
Loading
59 56
}
60 57
61 58
template <int RTYPE>
62 -
Rcpp::List SampleApplyFun(const Rcpp::Vector<RTYPE> &v, std::size_t m, const std::vector<int> &myReps,
63 -
                          std::size_t sampSize, const std::vector<double> &mySample, 
64 -
                          mpz_t *const myBigSamp, SEXP func, SEXP rho, nthResultPtr nthResFun,
65 -
                          bool IsNamed, bool IsGmp, int lenV) {
59 +
void SampleApplyFun(const Rcpp::Vector<RTYPE> &v, Rcpp::List &myList, std::size_t m,
60 +
                    const std::vector<int> &myReps, std::size_t sampSize,
61 +
                    const std::vector<double> &mySample, mpz_t *const myBigSamp,
62 +
                    SEXP func, SEXP rho, nthResultPtr nthResFun, bool IsNamed,
63 +
                    bool IsGmp, int lenV) {
66 64
67 65
    Rcpp::Vector<RTYPE> vectorPass(m);
68 -
    Rcpp::List myList(sampSize);
69 66
    SEXP sexpFun = PROTECT(Rf_lang2(func, R_NilValue));
70 67
    
71 68
    if (IsGmp) {
@@ -99,8 +96,6 @@
Loading
99 96
    
100 97
    if (IsNamed)
101 98
        SetSampleNames(IsGmp, sampSize, myList, mySample, myBigSamp, false);
102 -
    
103 -
    return myList;
104 99
}
105 100
106 101
template <typename typeRcpp, typename typeElem>
@@ -194,31 +189,82 @@
Loading
194 189
        if (!Rf_isFunction(stdFun))
195 190
            Rcpp::stop("FUN must be a function!");
196 191
        
197 -
        const SEXP sexpCopy = CopyRv(Rv, vInt, vNum, myType);
198 -
        RCPP_RETURN_VECTOR(SampleApplyFun, sexpCopy, m, myReps, sampSize, mySample,
199 -
                           myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
192 +
        Rcpp::List myList(sampSize);
193 +
        
194 +
        switch (myType) {
195 +
            case VecType::Character : {
196 +
                Rcpp::CharacterVector charVec(Rcpp::clone(Rv));
197 +
                SampleApplyFun(charVec, myList, m, myReps, sampSize, mySample,
198 +
                               myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
199 +
                break;
200 +
            } case VecType::Complex : {
201 +
                Rcpp::ComplexVector cmplxVec(Rcpp::clone(Rv));
202 +
                SampleApplyFun(cmplxVec, myList, m, myReps, sampSize, mySample,
203 +
                               myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
204 +
                break;
205 +
            } case VecType::Raw : {
206 +
                Rcpp::RawVector rawVec(Rcpp::clone(Rv));
207 +
                SampleApplyFun(rawVec, myList, m, myReps, sampSize, mySample,
208 +
                               myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
209 +
                break;
210 +
            } case VecType::Logical : {
211 +
                Rcpp::LogicalVector boolVec(Rcpp::clone(Rv));
212 +
                SampleApplyFun(boolVec, myList, m, myReps, sampSize, mySample,
213 +
                               myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
214 +
                break;
215 +
            } case VecType::Integer : {
216 +
                Rcpp::IntegerVector intVec = Rcpp::wrap(vInt);
217 +
                SampleApplyFun(intVec, myList, m, myReps, sampSize, mySample,
218 +
                               myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
219 +
                break;
220 +
            } default : {
221 +
                Rcpp::NumericVector numVec = Rcpp::wrap(vNum);
222 +
                SampleApplyFun(numVec, myList, m, myReps, sampSize, mySample,
223 +
                               myVec.get(), stdFun, myEnv, nthResFun, IsNamed, IsGmp, n);
224 +
                break;
225 +
            }
226 +
        }
227 +
        
228 +
        return myList;
200 229
    }
201 230
    
202 -
    if (myType > VecType::Logical) {
203 -
        const SEXP sexpCopy(Rcpp::clone(Rv));
204 -
        RCPP_RETURN_VECTOR(SampNoThrdSafe, sexpCopy, myReps, mySample, 
205 -
                           myVec.get(), m, sampSize, nthResFun, n, IsGmp, IsNamed);
206 -
    } else if (myType == VecType::Logical) {
207 -
        Rcpp::LogicalMatrix matBool = Rcpp::no_init_matrix(sampSize, m);
208 -
        MasterSample(vInt, m, myReps, sampSize, nthResFun, mySample,
209 -
                     myVec.get(), matBool, nThreads, Parallel, IsNamed, IsGmp, n);
210 -
        return matBool;
211 -
    } else if (myType == VecType::Integer) {
212 -
        Rcpp::IntegerMatrix matInt = Rcpp::no_init_matrix(sampSize, m);
213 -
        MasterSample(vInt, m, myReps, sampSize, nthResFun, mySample, 
214 -
                     myVec.get(), matInt, nThreads, Parallel, IsNamed, IsGmp, n);
215 -
        if (IsFactor) {SetFactorClass(matInt, Rv);}
216 -
        return matInt;
217 -
    } else {
218 -
        Rcpp::NumericMatrix matNum = Rcpp::no_init_matrix(sampSize, m);
219 -
        MasterSample(vNum, m, myReps, sampSize, nthResFun, mySample,
220 -
                     myVec.get(), matNum, nThreads, Parallel, IsNamed, IsGmp, n);
221 -
        return matNum;
231 +
    switch (myType) {
232 +
        case VecType::Character : {
233 +
            Rcpp::CharacterVector charVec(Rcpp::clone(Rv));
234 +
            Rcpp::CharacterMatrix matChar = Rcpp::no_init_matrix(sampSize, m);
235 +
            SampNoThrdSafe(charVec, matChar, myReps, mySample, myVec.get(),
236 +
                           m, sampSize, nthResFun, n, IsGmp, IsNamed);
237 +
            return matChar;
238 +
        } case VecType::Complex : {
239 +
            Rcpp::ComplexVector cmplxVec(Rcpp::clone(Rv));
240 +
            Rcpp::ComplexMatrix matCmplx = Rcpp::no_init_matrix(sampSize, m);
241 +
            SampNoThrdSafe(cmplxVec, matCmplx, myReps, mySample, myVec.get(),
242 +
                           m, sampSize, nthResFun, n, IsGmp, IsNamed);
243 +
            return matCmplx;
244 +
        } case VecType::Raw : {
245 +
            Rcpp::RawVector rawVec(Rcpp::clone(Rv));
246 +
            Rcpp::RawMatrix matRaw = Rcpp::no_init_matrix(sampSize, m);
247 +
            SampNoThrdSafe(rawVec, matRaw, myReps, mySample, myVec.get(),
248 +
                           m, sampSize, nthResFun, n, IsGmp, IsNamed);
249 +
            return matRaw;
250 +
        } case VecType::Logical : {
251 +
            Rcpp::LogicalVector boolVec(Rcpp::clone(Rv));
252 +
            Rcpp::LogicalMatrix matBool = Rcpp::no_init_matrix(sampSize, m);
253 +
            SampNoThrdSafe(boolVec, matBool, myReps, mySample, myVec.get(),
254 +
                           m, sampSize, nthResFun, n, IsGmp, IsNamed);
255 +
            return matBool;
256 +
        } case VecType::Integer : {
257 +
            Rcpp::IntegerMatrix matInt = Rcpp::no_init_matrix(sampSize, m);
258 +
            MasterSample(vInt, m, myReps, sampSize, nthResFun, mySample, 
259 +
                         myVec.get(), matInt, nThreads, Parallel, IsNamed, IsGmp, n);
260 +
            if (IsFactor) {SetFactorClass(matInt, Rv);}
261 +
            return matInt;
262 +
        } default : {
263 +
            Rcpp::NumericMatrix matNum = Rcpp::no_init_matrix(sampSize, m);
264 +
            MasterSample(vNum, m, myReps, sampSize, nthResFun, mySample,
265 +
                         myVec.get(), matNum, nThreads, Parallel, IsNamed, IsGmp, n);
266 +
            return matNum;
267 +
        }
222 268
    }
223 269
}
224 270

@@ -100,18 +100,6 @@
Loading
100 100
               nRows, IsNamed, mySample, myBigSamp, IsGmp);
101 101
}
102 102
103 -
template <int T>
104 -
Rcpp::Matrix<T> NonThreadSafe(const Rcpp::Vector<T> &v, const std::vector<int> &z, int n,
105 -
                              bool IsGmp, int r, int grpSize, int nRows, bool IsSample,
106 -
                              const std::vector<double> &mySample, mpz_t *const myBigSamp,
107 -
                              double computedRows, mpz_t &computedRowMpz, bool IsArray, bool IsNamed) {
108 -
    
109 -
    Rcpp::Matrix<T> matRcpp = Rcpp::no_init_matrix(nRows, n);
110 -
    SerialGlue(n, v, matRcpp, IsGmp, z, r, grpSize, nRows, IsSample, mySample, 
111 -
               myBigSamp, computedRows, computedRowMpz, IsArray, IsNamed);
112 -
    return matRcpp;
113 -
}
114 -
115 103
template <typename typeRcpp, typename typeElem>
116 104
void ParallelGlue(std::size_t n, const std::vector<typeElem> &v, typeRcpp &GroupsMat, bool IsGmp,
117 105
                  const std::vector<int> &z, int r, int grpSize, std::size_t strtIdx, std::size_t endIdx,
@@ -314,30 +302,49 @@
Loading
314 302
        SetRandomSampleMpz(RindexVec, RmySeed, sampSize, IsGmp, computedRowMpz, myVec.get());
315 303
    }
316 304
    
317 -
    if (myType > VecType::Logical) {
318 -
        const SEXP sexpCopy(Rcpp::clone(Rv));
319 -
        RCPP_RETURN_VECTOR(NonThreadSafe, sexpCopy, startZ, n, IsGmp, numGroups, grpSize,
320 -
                           nRows, IsSample, mySample, myVec.get(), computedRows, 
321 -
                           computedRowMpz, IsArray, IsNamed);
322 -
    } else if (myType == VecType::Logical) {
323 -
        Rcpp::LogicalMatrix boolGroupsMat(nRows, n);
324 -
        GroupsMaster(n, vInt, boolGroupsMat, startZ, numGroups, grpSize, nRows, Parallel,
325 -
                     nThreads, IsGmp, lower, lowerMpz[0], computedRows, computedRowMpz,
326 -
                     IsSample, mySample, myVec.get(), IsArray, IsNamed);
327 -
        return boolGroupsMat;
328 -
    } else if (myType == VecType::Integer) {
329 -
        Rcpp::IntegerMatrix intGroupsMat = Rcpp::no_init_matrix(nRows, n);
330 -
        GroupsMaster(n, vInt, intGroupsMat, startZ, numGroups, grpSize, nRows, Parallel,
331 -
                     nThreads, IsGmp, lower, lowerMpz[0], computedRows, computedRowMpz,
332 -
                     IsSample, mySample, myVec.get(), IsArray, IsNamed);
333 -
334 -
        if (IsFactor) {SetFactorClass(intGroupsMat, Rv);}
335 -
        return intGroupsMat;
336 -
    } else {
337 -
        Rcpp::NumericMatrix numGroupsMat = Rcpp::no_init_matrix(nRows, n);
338 -
        GroupsMaster(n, vNum, numGroupsMat, startZ, numGroups, grpSize, nRows, Parallel,
339 -
                     nThreads, IsGmp, lower, lowerMpz[0], computedRows, computedRowMpz,
340 -
                     IsSample, mySample, myVec.get(), IsArray, IsNamed);
341 -
        return numGroupsMat;
305 +
    switch (myType) {
306 +
        case VecType::Character: {
307 +
            Rcpp::CharacterVector charVec(Rcpp::clone(Rv));
308 +
            Rcpp::CharacterMatrix charGroupsMat(nRows, n);
309 +
            SerialGlue(n, charVec, charGroupsMat, IsGmp, startZ, numGroups,
310 +
                       grpSize, nRows, IsSample, mySample, myVec.get(),
311 +
                       computedRows, computedRowMpz, IsArray, IsNamed);
312 +
            return charGroupsMat;
313 +
        } case VecType::Complex: {
314 +
            Rcpp::ComplexVector cmplxVec(Rcpp::clone(Rv));
315 +
            Rcpp::ComplexMatrix cmplxGroupsMat(nRows, n);
316 +
            SerialGlue(n, cmplxVec, cmplxGroupsMat, IsGmp, startZ, numGroups,
317 +
                       grpSize, nRows, IsSample, mySample, myVec.get(),
318 +
                       computedRows, computedRowMpz, IsArray, IsNamed);
319 +
            return cmplxGroupsMat;
320 +
        } case VecType::Raw : {
321 +
            Rcpp::RawVector rawVec(Rcpp::clone(Rv));
322 +
            Rcpp::RawMatrix rawGroupsMat(nRows, n);
323 +
            SerialGlue(n, rawVec, rawGroupsMat, IsGmp, startZ, numGroups,
324 +
                       grpSize, nRows, IsSample, mySample, myVec.get(),
325 +
                       computedRows, computedRowMpz, IsArray, IsNamed);
326 +
            return rawGroupsMat;
327 +
        } case VecType::Logical : {
328 +
            Rcpp::LogicalVector boolVec(Rcpp::clone(Rv));
329 +
            Rcpp::LogicalMatrix boolGroupsMat(nRows, n);
330 +
            SerialGlue(n, boolVec, boolGroupsMat, IsGmp, startZ, numGroups,
331 +
                       grpSize, nRows, IsSample, mySample, myVec.get(),
332 +
                       computedRows, computedRowMpz, IsArray, IsNamed);
333 +
            return boolGroupsMat;
334 +
        } case VecType::Integer : {
335 +
            Rcpp::IntegerMatrix intGroupsMat = Rcpp::no_init_matrix(nRows, n);
336 +
            GroupsMaster(n, vInt, intGroupsMat, startZ, numGroups, grpSize, nRows, Parallel,
337 +
                         nThreads, IsGmp, lower, lowerMpz[0], computedRows, computedRowMpz,
338 +
                         IsSample, mySample, myVec.get(), IsArray, IsNamed);
339 +
    
340 +
            if (IsFactor) {SetFactorClass(intGroupsMat, Rv);}
341 +
            return intGroupsMat;
342 +
        } default : {
343 +
            Rcpp::NumericMatrix numGroupsMat = Rcpp::no_init_matrix(nRows, n);
344 +
            GroupsMaster(n, vNum, numGroupsMat, startZ, numGroups, grpSize, nRows, Parallel,
345 +
                         nThreads, IsGmp, lower, lowerMpz[0], computedRows, computedRowMpz,
346 +
                         IsSample, mySample, myVec.get(), IsArray, IsNamed);
347 +
            return numGroupsMat;
348 +
        }
342 349
    }
343 350
}

@@ -44,9 +44,14 @@
Loading
44 44
    
45 45
    const SEXP stdFun;
46 46
    const SEXP rho;
47 +
    
48 +
    SEXP VecFUNReturn(const SEXP &v);
49 +
    SEXP ListReturn(const SEXP &v, int nRows, bool IsReverse);
50 +
    SEXP SampListReturn(const SEXP &v, const std::vector<double> &mySample,
51 +
                        mpz_t *const myBigSamp, std::size_t sampSize);
47 52
48 53
    template <int RTYPE>
49 -
    SEXP VecFUNRes(const Rcpp::Vector<RTYPE> &v);
54 +
    SEXP VecPopFUNRes(const Rcpp::Vector<RTYPE> &v);
50 55
51 56
    template <int RTYPE>
52 57
    Rcpp::List ListComboFUN(const Rcpp::Vector<RTYPE> &v, int nRows);

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 1 files with coverage changes found.

New file src/CombPermPtr.cpp
New
Loading file...
Files Coverage
R 95.83%
inst/include -0.10% 96.78%
src -0.28% 94.91%
Project Totals (62 files) 95.07%
Loading