Commit 5ea6b4bd authored by thomas.forbriger's avatar thomas.forbriger
Browse files

randomseries [FIX]: pass seeding option to rng

parent 97dabba7
......@@ -12,11 +12,12 @@
*
* REVISIONS and CHANGES
* - 31/10/2019 V1.0 Thomas Forbriger
* - 02/10/2020 V1.1 pass seed value to rng
*
* ============================================================================
*/
#define RANDOMSERIES_VERSION \
"RANDOMSERIES V1.0 provide time series of incoherent random numbers"
"RANDOMSERIES V1.1 provide time series of incoherent random numbers"
#include <iostream>
#include <fstream>
......@@ -37,7 +38,7 @@ using std::endl;
/* ---------------------------------------------------------------------- */
struct Options {
bool verbose, overwrite;
bool verbose, overwrite, setseed;
std::string rngtype, filename, filetype;
int nseries, nsamples;
double std, mean, dt;
......@@ -191,6 +192,7 @@ int main(int iargc, char* argv[])
opt.nseries=cmdline.int_arg(4);
opt.nsamples=cmdline.int_arg(5);
opt.seed=cmdline.int_arg(6);
opt.setseed=cmdline.optset(6);
opt.std=cmdline.double_arg(7);
opt.mean=cmdline.double_arg(8);
opt.rngtype=cmdline.string_arg(10);
......@@ -199,7 +201,7 @@ int main(int iargc, char* argv[])
// check parameters
TFXX_assert(opt.nseries>0, "number of series must be positive");
TFXX_assert(opt.nsamples>0, "number of samples must be positive");
TFXX_assert(opt.seed>=0, "number of samples must be non-negative");
TFXX_assert(opt.seed>=0, "seed value must be non-negative");
TFXX_assert(opt.dt>0, "sampling interval must be positive");
if (opt.verbose)
......@@ -220,6 +222,7 @@ int main(int iargc, char* argv[])
// create random number generator
tfxx::numeric::RNGgaussian rng(opt.std, opt.mean, opt.rngtype.c_str());
if (opt.setseed) { rng.set(opt.seed); } else { rng.set(); }
if (opt.verbose)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment