... | ... |
@@ -83,6 +83,13 @@ nPumpSamples=0, ...) |
83 | 83 |
if (whichMatrixFixed == 'P' & ncol(fixedPatterns) != ncol(D)) |
84 | 84 |
stop('invalid number of columns for fixedPatterns') |
85 | 85 |
thresholdEnum <- c("unique", "cut") |
86 |
+ |
|
87 |
+ # get seed |
|
88 |
+ if (seed < 0) |
|
89 |
+ { |
|
90 |
+ # TODO get time in milliseconds |
|
91 |
+ seed <- 0 |
|
92 |
+ } |
|
86 | 93 |
|
87 | 94 |
# run algorithm with call to C++ code |
88 | 95 |
result <- cogaps_cpp(D, S, nFactor, nEquil, nEquil/10, nSample, nOutputs, |
... | ... |
@@ -13,23 +13,14 @@ |
13 | 13 |
Rcpp::List cogaps_cpp(const Rcpp::NumericMatrix &D, |
14 | 14 |
const Rcpp::NumericMatrix &S, unsigned nFactor, unsigned nEquil, |
15 | 15 |
unsigned nEquilCool, unsigned nSample, unsigned nOutputs, unsigned nSnapshots, |
16 |
-float alphaA, float alphaP, float maxGibbmassA, float maxGibbmassP, int seed, |
|
17 |
-bool messages, bool singleCellRNASeq, char whichMatrixFixed, |
|
16 |
+float alphaA, float alphaP, float maxGibbmassA, float maxGibbmassP, |
|
17 |
+unsigned seed, bool messages, bool singleCellRNASeq, char whichMatrixFixed, |
|
18 | 18 |
const Rcpp::NumericMatrix &FP, unsigned checkpointInterval, |
19 | 19 |
const std::string &cptFile, unsigned pumpThreshold, unsigned nPumpSamples) |
20 | 20 |
{ |
21 |
- // get seed, TODO do this on R side, multiple benefits (same seed in R, C++) |
|
22 |
- uint32_t seedUsed = static_cast<uint32_t>(seed); |
|
23 |
- if (seed < 0) |
|
24 |
- { |
|
25 |
- bpt::ptime epoch(boost::gregorian::date(1970,1,1)); |
|
26 |
- bpt::time_duration diff = bpt_now() - epoch; |
|
27 |
- seedUsed = static_cast<uint32_t>(diff.total_milliseconds() % 1000); |
|
28 |
- } |
|
29 |
- |
|
30 | 21 |
// create internal state from parameters and run from there |
31 | 22 |
GapsRunner runner(D, S, nFactor, nEquil, nEquilCool, nSample, |
32 |
- nOutputs, nSnapshots, alphaA, alphaP, maxGibbmassA, maxGibbmassP, seedUsed, |
|
23 |
+ nOutputs, nSnapshots, alphaA, alphaP, maxGibbmassA, maxGibbmassP, seed, |
|
33 | 24 |
messages, singleCellRNASeq, checkpointInterval, cptFile, |
34 | 25 |
whichMatrixFixed, FP); |
35 | 26 |
return runner.run(); |