RandomNumbersUnitTest.cpp File Reference
#include <iostream>
#include "DPMBase.h"
#include "Mercury2D.h"
#include "Math/ExtendedMath.h"

Classes

class  my_problem
 todo{This code is not working as is wanted} More...
 
class  my_problem_HGRID
 todo{This code is not working as is wanted} More...
 

Functions

int main (int argc UNUSED, char *argv[] UNUSED)
 

Function Documentation

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)

Start off my solving the default problem

83 {
84  logger(INFO, "First test the gamma function is working\n"
85  "---------------------------------------- \n\n"
86  "Gamma(4) = % : Error %\n"
87  "Gamma(3.5) = % : Error %",
89  mathsFunc::gamma(3.5) - 3.323);
90 
91  logger(INFO, "Second test the chi-squared distribution is working\n"
92  "---------------------------------------------------\n\n"
93  "\nFirst test chi(1.07,1) = % Error %\n"
94  "First test chi(1.07,1) = % Error %\n"
95  "First test chi(1.07,1) = % Error %",
99  helpers::check(mathsFunc::chi_squared_prob(1.07, 1) - 0.3, 0.0250886, 1e-6, "Checking quality of chi-squared test");
100 
103 
104  problem.random.setRandomNumberGenerator(RNGType::LINEAR_CONGRUENTIAL_GENERATOR);
105 
106  logger(INFO, "\nSecond test the actually random number generate : Linear Congruential Generator\n"
107  "----------------------------------------------\n\n"
108  "First with the default parameters, prob numbers are from uniform = ", Flusher::NO_FLUSH);
109  helpers::check(problem.random.test(), 0.467846, 1e-6, "Checking test result");
110 
111  problem.random.setLinearCongruentialGeneratorParmeters(65539, 0, mathsFunc::cubic(1024) * 2 - 1);
112  logger(INFO, "Third test, now with Stefans' the default parameters, prob numbers are from uniform = ",
114  helpers::check(problem.random.test(), 0.131117, 1e-6, "Checking test result");
115 
116  problem.random.setRandomNumberGenerator(RNGType::LAGGED_FIBONACCI_GENERATOR);
117  problem.random.setLinearCongruentialGeneratorParmeters(1103515245, 12345, 1024 * 1024 * 1024);
118  problem.random.setRandomSeed(0);
119 
120  logger(INFO, "\nForth test the actually random number generate : Lagged Fibonacci Generator\n"
121  "----------------------------------------------\n"
122  "First with the default parameters, prob numbers are from uniform = ", Flusher::NO_FLUSH);
123  helpers::check(problem.random.test(), 0.617585, 1e-6, "Checking test result");
124 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ LAGGED_FIBONACCI_GENERATOR
@ LINEAR_CONGRUENTIAL_GENERATOR
todo{This code is not working as is wanted}
Definition: elastic_gas.cpp:13
#define INFO(i)
Definition: mumps_solver.h:54
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:16
Mdouble gamma(Mdouble gamma_in)
This is the gamma function returns the true value for the half integer value.
Definition: ExtendedMath.cc:116
Mdouble chi_squared_prob(Mdouble x, unsigned int k)
This is the function which actually gives the probability back using a chi squared test.
Definition: ExtendedMath.cc:167
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:95
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References helpers::check(), mathsFunc::chi_squared_prob(), mathsFunc::cubic(), e(), mathsFunc::gamma(), INFO, LAGGED_FIBONACCI_GENERATOR, LINEAR_CONGRUENTIAL_GENERATOR, logger, NO_FLUSH, and problem.