summaryrefslogtreecommitdiffstats
path: root/Tests/FindGSL/rng/main.cc
blob: 050caacc731846f56db4f6868df2abf4b51d4580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <math.h>

#include "gsl/gsl_rng.h"

int main()
{
  // return code
  int retval = 1;

  // create a generator
  gsl_rng* generator;
  generator = gsl_rng_alloc(gsl_rng_mt19937);

  // Read a value.
  double const Result = gsl_rng_uniform(generator);

  // Check value
  double const expectedResult(0.999741748906672);
  if (fabs(expectedResult - Result) < 1.0e-6)
    retval = 0;

  // free allocated memory
  gsl_rng_free(generator);
  return retval;
}