RandomLib  1.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
RandomLib::RandomType< bits, UIntType > Class Template Reference

Class to hold bit-width and unsigned type. More...

#include <RandomLib/RandomType.hpp>

Public Types

typedef UIntType type
 

Static Public Member Functions

template<typename IntType >
static type cast (IntType x) throw ()
 
static void Read32 (std::istream &is, bool bin, type &x)
 
static void Write32 (std::ostream &os, bool bin, int &cnt, type x)
 
static void CheckSum (type n, uint32_t &check) throw ()
 

Static Public Attributes

static const unsigned width = bits
 
static const type mask
 
static const type min = type(0)
 
static const type max = mask
 

Detailed Description

template<int bits, typename UIntType>
class RandomLib::RandomType< bits, UIntType >

Class to hold bit-width and unsigned type.

This provides a simple class to couple a bit-width and an unsigned type capable of holding all the bits. In addition is offers static methods for I/O and checksumming.

Template Parameters
bitsthe number of significant bits.
UIntTypethe C++ unsigned integer type capable of holding the bits.

Definition at line 32 of file RandomType.hpp.

Member Typedef Documentation

template<int bits, typename UIntType >
typedef UIntType RandomLib::RandomType< bits, UIntType >::type

The unsigned C++ type

Definition at line 37 of file RandomType.hpp.

Member Function Documentation

template<int bits, typename UIntType >
template<typename IntType >
static type RandomLib::RandomType< bits, UIntType >::cast ( IntType  x)
throw (
)
inlinestatic

A combined masking and casting operation

Template Parameters
IntTypethe integer type of the x.
Parameters
[in]xthe input integer.
Returns
the masked and casted result.

Definition at line 62 of file RandomType.hpp.

Referenced by RandomLib::RandomSeed::SeedVector(), RandomLib::RandomSeed::SeedWord(), and RandomLib::RandomSeed::StringToVector().

void RandomLib::Random_u64::Read32 ( std::istream &  is,
bool  bin,
Random_u32::type x 
)
static

Read a data value from a stream of 32-bit quantities (binary or text)

Parameters
[in,out]isthe input stream.
[in]bintrue if the stream is binary.
[out]xthe data value read from the stream.

Definition at line 125 of file Random.cpp.

References RandomLib::RandomType< bits, UIntType >::mask.

void RandomLib::Random_u64::Write32 ( std::ostream &  os,
bool  bin,
int &  cnt,
Random_u32::type  x 
)
static

Write the data value to a stream of 32-bit quantities (binary or text)

Parameters
[in,out]osthe output stream.
[in]bintrue if the stream is binary.
[in,out]cntcontrols the use of spaces and newlines for text output.
[in]xthe data value to be written to the stream.

cnt should be zero on the first invocation of a series of writes. This function increments it by one on each call.

Definition at line 99 of file Random.cpp.

template<int bits, typename UIntType >
static void RandomLib::RandomType< bits, UIntType >::CheckSum ( type  n,
uint32_t &  check 
)
throw (
)
static

Accumulate a checksum of a integer into a 32-bit check. This implements a very simple checksum and is intended to avoid accidental corruption only.

Parameters
[in]nthe number to be included in the checksum.
[in,out]checkthe running checksum.

Referenced by RandomLib::RandomSeed::SeedWord().

Member Data Documentation

template<int bits, typename UIntType >
const unsigned RandomLib::RandomType< bits, UIntType >::width = bits
static

The number of significant bits

Definition at line 41 of file RandomType.hpp.

template<int bits, typename UIntType >
const type RandomLib::RandomType< bits, UIntType >::mask
static
Initial value:
=
~type(0) >> (std::numeric_limits<type>::digits - width)

A mask for the significant bits.

Definition at line 45 of file RandomType.hpp.

Referenced by RandomLib::RandomCanonical< Generator >::Integer(), RandomLib::RandomCanonical< Generator >::IntegerC(), and RandomLib::RandomType< bits, UIntType >::Read32().

template<int bits, typename UIntType >
const type RandomLib::RandomType< bits, UIntType >::min = type(0)
static

The minimum representable value

Definition at line 50 of file RandomType.hpp.

template<int bits, typename UIntType >
const type RandomLib::RandomType< bits, UIntType >::max = mask
static

The maximum representable value

Definition at line 54 of file RandomType.hpp.


The documentation for this class was generated from the following files: