/usr/include/givaro/givrandom.h is in libgivaro-dev 3.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | // =================================================================== //
// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
// Time-stamp: <04 Jun 12 14:31:40 Jean-Guillaume.Dumas@imag.fr>
// =================================================================== //
/*! @file givrandom.h
* @ingroup system
* @brief NO DOC
* @bib
* - Fishman, GS <i>Multiplicative congruential random
* number generators...</i> Math. Comp. 54:331-344 (1990).
*
*/
#ifndef __GIVARO_random_H
#define __GIVARO_random_H
#include <givaro/givconfig.h>
extern "C" {
# include <sys/time.h>
# include <sys/resource.h>
}
#if __GIVARO__DONOTUSE_longlong__
#define _GIVRAN_MULTIPLYER_ 950706376UL
#define _GIVRAN_MODULO_ 2147483647UL
#else
#define _GIVRAN_MULTIPLYER_ 950706376ULL
#define _GIVRAN_MODULO_ 2147483647ULL
#endif
namespace Givaro {
//! GivRandom
class GivRandom {
mutable unsigned long _seed;
public:
typedef GivRandom random_generator;
GivRandom(const unsigned long s = 0)
: _seed(s)
{
if (! s) {
struct timeval tp;
gettimeofday(&tp, 0) ;
_seed = (unsigned long)(tp.tv_usec);
}
}
GivRandom(const GivRandom& R) :
_seed(R._seed)
{}
GivRandom& operator= (const GivRandom& R)
{
_seed = R._seed;
return *this;
}
unsigned long seed() const
{
return _seed;
}
unsigned long max_rand() const
{
return _GIVRAN_MODULO_;
}
// #if defined(__GIVARO_INT64)
#if 1
unsigned long operator() () const
{
return _seed = (unsigned long)(
(int64_t)_GIVRAN_MULTIPLYER_
* (int64_t)_seed
% (int64_t)_GIVRAN_MODULO_ );
}
#else
unsigned long operator() () const
{
return _seed = (unsigned long)(
(unsigned long)_GIVRAN_MULTIPLYER_
* _seed
% (unsigned long)_GIVRAN_MODULO_ );
}
#endif
template<class XXX> XXX& operator() (XXX& x) const
{
return x = (XXX)this->operator() ();
}
};
} // namespace Givaro
#endif // __GIVARO_random_H
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
|