Skip to content

Commit

Permalink
fix for issue #33; use R based random number calls in a CRAN approved…
Browse files Browse the repository at this point in the history
… way
  • Loading branch information
sneumann committed Dec 10, 2024
1 parent ed9b59c commit 76423fd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-11-08 Jan Lisec <[email protected]>

* Rdisop-1.67.4
* fix for issue #33; use R based random number calls in a CRAN approved way.

2024-11-08 Jan Lisec <[email protected]>

* Rdisop-1.67.3
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rdisop
Title: Decomposition of Isotopic Patterns
Version: 1.67.3
Date: 2024-11-08
Version: 1.67.4
Date: 2024-12-10
Authors@R:
c(
person("Anton", "Pervukhin", , "[email protected]", role = c("aut")),
Expand Down
5 changes: 1 addition & 4 deletions src/imslib/src/ims/utils/distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ Distribution::Distribution(std::vector<double> dist): p(dist), size(p.size()) {
* Get a random number.
*/
size_t Distribution::getRand(){
// 2024-11-18 rand() statements substituted by Rcpp equivalents
// size_t i = (size_t)( rand()/(RAND_MAX+1.0)*size );
// double r = (double(rand())/RAND_MAX);
size_t i = (size_t)( R::runif(0,0.999999)*size );
size_t i = (size_t)( R::runif(0,0.999999)*size );
double r = (R::runif(0,1));

if(p[i] < r){
Expand Down
2 changes: 0 additions & 2 deletions src/imslib/tests/markovsequencegeneratortest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ void MarkovSequenceGeneratorTest::testGetSequence() {
for(size_t i=0; i<alphabet.size(); i++){
std::vector<double> p;
for(size_t n=0; n<alphabet.size(); n++){
// 2024-11-18 rand() statements substituted by Rcpp equivalents
// p.push_back((double(rand())/RAND_MAX));
p.push_back(R::runif(0,1));
}

Expand Down

0 comments on commit 76423fd

Please sign in to comment.