test/random_test.cc
author Balazs Dezso <deba@inf.elte.hu>
Thu, 17 Apr 2008 15:18:45 +0100
changeset 127 1c9a9e2f7d4d
parent 92 5d4decd1b870
child 171 02f4d5d9bfd7
permissions -rw-r--r--
Redesigned lgf related tools
alpar@10
     1
/* -*- C++ -*-
alpar@10
     2
 *
alpar@10
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@10
     4
 *
alpar@39
     5
 * Copyright (C) 2003-2008
alpar@10
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@10
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@10
     8
 *
alpar@10
     9
 * Permission to use, modify and distribute this software is granted
alpar@10
    10
 * provided that this copyright notice appears in all copies. For
alpar@10
    11
 * precise terms see the accompanying LICENSE file.
alpar@10
    12
 *
alpar@10
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@10
    14
 * express or implied, and with no claim as to its suitability for any
alpar@10
    15
 * purpose.
alpar@10
    16
 *
alpar@10
    17
 */
alpar@10
    18
alpar@10
    19
#include <lemon/random.h>
alpar@10
    20
#include "test_tools.h"
alpar@10
    21
alpar@10
    22
///\file \brief Test cases for random.h
alpar@10
    23
///
alpar@10
    24
///\todo To be extended
alpar@10
    25
///
alpar@10
    26
deba@102
    27
int seed_array[] = {1, 2};
deba@102
    28
alpar@10
    29
int main()
alpar@10
    30
{
alpar@10
    31
  double a=lemon::rnd();
alpar@10
    32
  check(a<1.0&&a>0.0,"This should be in [0,1)");
alpar@10
    33
  a=lemon::rnd.gauss();
alpar@10
    34
  a=lemon::rnd.gamma(3.45,0);
alpar@10
    35
  a=lemon::rnd.gamma(4);
alpar@10
    36
  //Does gamma work with integer k?
alpar@10
    37
  a=lemon::rnd.gamma(4.0,0);
alpar@92
    38
  a=lemon::rnd.poisson(.5);
deba@102
    39
deba@102
    40
  lemon::rnd.seed(100);
deba@102
    41
  lemon::rnd.seed(seed_array, seed_array + 
deba@102
    42
		  (sizeof(seed_array) / sizeof(seed_array[0])));
deba@102
    43
deba@102
    44
  return 0;
alpar@10
    45
}