-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* random_64bit_generator and random_64bit_accessor w/o the constructor definition go to dqrng_types.h * this gets automatically included in dqrng_RcppExports.h. * constructor definition for random_64bit_accessor goes to dqrng.h. * boost modifications go to dqrng_distributions.h
- Loading branch information
Showing
9 changed files
with
117 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
#ifndef RCPP_dqrng_H_GEN_ | ||
#define RCPP_dqrng_H_GEN_ | ||
// Copyright 2023 Ralf Stubner | ||
// Copyright 2023 Henrik Sloot | ||
// | ||
// This file is part of dqrng. | ||
// | ||
// dqrng is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// dqrng is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with dqrng. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#ifndef dqrng_H | ||
#define dqrng_H | ||
|
||
#include "dqrng_generator.h" | ||
#include "dqrng_RcppExports.h" | ||
|
||
#endif // RCPP_dqrng_H_GEN_ | ||
namespace dqrng { | ||
random_64bit_accessor::random_64bit_accessor() : gen(dqrng::get_rng().get()) {} | ||
} // namespace dqrng | ||
#endif // dqrng_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2018-2019 Ralf Stubner (daqana GmbH) | ||
// Copyright 2023 Ralf Stubner | ||
// Copyright 2023 Henrik Sloot | ||
// | ||
// This file is part of dqrng. | ||
// | ||
// dqrng is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// dqrng is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with dqrng. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#ifndef DQRNG_TYPES_H | ||
#define DQRNG_TYPES_H 1 | ||
|
||
#include <mystdint.h> | ||
#include <memory> | ||
#include <stdexcept> | ||
|
||
namespace dqrng { | ||
|
||
class random_64bit_generator { | ||
public: | ||
using result_type = uint64_t; | ||
|
||
virtual ~random_64bit_generator() {}; | ||
virtual result_type operator() () = 0; | ||
virtual void seed(result_type seed) = 0; | ||
virtual void seed(result_type seed, result_type stream) = 0; | ||
static constexpr result_type min() {return 0;}; | ||
static constexpr result_type max() {return UINT64_MAX;}; | ||
virtual uint32_t operator() (uint32_t range) = 0; | ||
#ifdef LONG_VECTOR_SUPPORT | ||
virtual uint64_t operator() (uint64_t range) = 0; | ||
#endif | ||
}; | ||
|
||
using rng64_t = std::shared_ptr<random_64bit_generator>; | ||
|
||
class random_64bit_accessor : public random_64bit_generator { | ||
private: | ||
dqrng::random_64bit_generator *gen; | ||
|
||
public: | ||
explicit random_64bit_accessor(); | ||
|
||
virtual result_type operator() () override { | ||
return (*gen)(); | ||
}; | ||
|
||
virtual void seed(result_type seed) override { | ||
throw std::runtime_error("Seed handling not supported for this class!"); | ||
}; | ||
|
||
virtual void seed(result_type seed, result_type stream) override { | ||
throw std::runtime_error("Seed handling not supported for this class!"); | ||
}; | ||
|
||
virtual uint32_t operator() (uint32_t range) override { | ||
return (*gen)(range); | ||
} | ||
#ifdef LONG_VECTOR_SUPPORT | ||
virtual uint64_t operator() (uint64_t range) override { | ||
return (*gen)(range); | ||
} | ||
#endif | ||
}; | ||
|
||
|
||
} // namespace dqrng | ||
#endif // DQRNG_TYPES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters