LCOV - code coverage report
Current view: top level - sc/source/core/tool - random.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 8 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * Contributor(s):
      10             :  *   Copyright (C) 2012 Tino Kluge <tino.kluge@hrz.tu-chemnitz.de>
      11             :  */
      12             : 
      13             : #include <boost/random.hpp>
      14             : 
      15             : // this is nothing but a simple wrapper around
      16             : // the boost random generators
      17             : 
      18             : namespace sc
      19             : {
      20             : namespace rng
      21             : {
      22             : 
      23             : // underlying random number generator
      24             : // boost::mt19937 implements the Mersenne twister algorithm which
      25             : // is fast and has good statistical properties, it produces integers
      26             : // in the range of [0, 2^32-1] internally
      27             : // memory requirement: 625*sizeof(uint32_t)
      28             : // http://en.wikipedia.org/wiki/Mersenne_twister
      29             : #define BOOST_RNG_ALGO  boost::mt19937
      30           0 : BOOST_RNG_ALGO global_rng;
      31             : 
      32             : // initialises the state of the global random number generator
      33             : // should only be called once at the start of the main programme
      34             : // (note, a few boost::variate_generator<> (like normal) have their
      35             : // own state which would need a reset as well to guarantee identical
      36             : // sequence of numbers, e.g. via myrand.distribution().reset())
      37           0 : void seed(int i)
      38             : {
      39           0 :     global_rng.seed(i);
      40           0 : }
      41             : 
      42             : // uniform [0,1) or [a,b) distribution
      43           0 : double uniform()
      44             : {
      45           0 :     static boost::uniform_01<BOOST_RNG_ALGO&> myrand(global_rng);
      46           0 :     return myrand();
      47             : }
      48             : 
      49             : } // namespace
      50           0 : } // namespace
      51             : 
      52             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10