made randomnumber generators seeded with fixed values

This commit is contained in:
jkriege2 2022-08-30 21:33:22 +02:00
parent 889f95e7af
commit abd62dc341
21 changed files with 17 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -5,6 +5,8 @@
JKQTPAppSettingController::JKQTPAppSettingController(int &argc, char **argv, bool enableHighDPIIfAVailable)
{
// seed RNG
std::srand(123456);
bool deactivated=false;
for (int i=0; i<argc; i++) {
if (QString(argv[i])=="--disablehighdpi") {

View File

@ -235,9 +235,10 @@ JKQTPAdaptiveFunctionGraphEvaluator::JKQTPAdaptiveFunctionGraphEvaluator(const s
minSamples(minSamples_),
maxRefinementDegree(maxRefinementDegree_),
slopeTolerance(slopeTolerance_),
minPixelPerSample(minPixelPerSample_)
minPixelPerSample(minPixelPerSample_),
rd(), gen{rd()}, dist(0,1)
{
gen.seed(12345);
}
JKQTPAdaptiveFunctionGraphEvaluator::JKQTPAdaptiveFunctionGraphEvaluator(const std::function<QPointF (double)> &fxy_, unsigned int minSamples_, unsigned int maxRefinementDegree_, double slopeTolerance_, double minPixelPerSample_):
@ -245,9 +246,10 @@ JKQTPAdaptiveFunctionGraphEvaluator::JKQTPAdaptiveFunctionGraphEvaluator(const s
minSamples(minSamples_),
maxRefinementDegree(maxRefinementDegree_),
slopeTolerance(slopeTolerance_),
minPixelPerSample(minPixelPerSample_)
minPixelPerSample(minPixelPerSample_),
rd(), gen{rd()}, dist(0,1)
{
gen.seed(12345);
}
QVector<QPointF> JKQTPAdaptiveFunctionGraphEvaluator::evaluate(double tmin, double tmax) const
@ -285,7 +287,7 @@ void JKQTPAdaptiveFunctionGraphEvaluator::refine(JKQTPAdaptiveFunctionGraphEvalu
if (degree>=maxRefinementDegree) return;
const double ta=a->first;
const double tb=b->first;
const double tmid=ta+(tb-ta)*(0.5 +(static_cast<double>(rand())/static_cast<double>(RAND_MAX)-0.5)/5.0);
const double tmid=ta+(tb-ta)*(0.5 +(dist(gen)-0.5)/5.0);
const QPointF pa=a->second;
const QPointF pb=b->second;
const QPointF pmid(fxy(tmid));

View File

@ -33,6 +33,7 @@
#include <forward_list>
#include <cmath>
#include <utility>
#include <random>
#include <QDebug>
#include "jkqtcommon/jkqtpmathtools.h"
#include "jkqtcommon/jkqtpcodestructuring.h"
@ -105,6 +106,13 @@ protected:
double slopeTolerance;
/** \brief create one sample at least every \a minPixelPerSample pixels */
double minPixelPerSample;
/** \brief random number generation: device */
mutable std::random_device rd; // random number generators:
/** \brief random number generation: egenrator */
mutable std::mt19937 gen;
/** \brief random number generation: distribution */
mutable std::uniform_real_distribution<double> dist;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB