Skylark (Sketching Library)  0.1
Public Member Functions | Friends
skylark::base::context_t Struct Reference

#include <context.hpp>

List of all members.

Public Member Functions

 context_t (int seed, int counter=0)
 context_t (const boost::property_tree::ptree &json)
boost::property_tree::ptree to_ptree () const
template<typename Distribution >
skylark::utility::random_samples_array_t
< Distribution > 
allocate_random_samples_array (size_t size, Distribution &distribution)
template<typename Distribution >
std::vector< typename
Distribution::result_type > 
generate_random_samples_array (size_t size, Distribution &distribution)
skylark::utility::random_array_t allocate_random_array (size_t size)
int random_int ()
size_t get_counter ()

Friends

boost::property_tree::ptree & operator<< (boost::property_tree::ptree &sk, const context_t &data)

Detailed Description

A structure that holds basic information about the state of the random number stream.

Definition at line 19 of file context.hpp.


Constructor & Destructor Documentation

skylark::base::context_t::context_t ( int  seed,
int  counter = 0 
) [inline]

Initialize context with a seed.

Parameters:
[in]seedRandom seed to be used for all computations.

Definition at line 24 of file context.hpp.

skylark::base::context_t::context_t ( const boost::property_tree::ptree &  json) [inline]

Load context from a serialized JSON structure.

Parameters:
[in]filenameof JSON structure encoding serialized state.

Definition at line 49 of file context.hpp.


Member Function Documentation

Returns a container of random numbers to be accessed as an array.

Parameters:
[in]sizeThe size of the container.
Returns:
Random numbers' container.

This should be used as a global operation to keep the the internal state of the context synchronized.

Definition at line 138 of file context.hpp.

Referenced by random_int().

template<typename Distribution >
skylark::utility::random_samples_array_t<Distribution> skylark::base::context_t::allocate_random_samples_array ( size_t  size,
Distribution &  distribution 
) [inline]

Returns a container of samples drawn from a distribution to be accessed as an array.

Parameters:
[in]sizeThe size of the container.
[in]distributionThe distribution to draw samples from.
Returns:
Random samples' container.

This is the main facility for creating a "stream" of samples of given size and distribution. size is needed for reserving up-front a portion of the linear space of the 2^64 samples that can be provided by a context with a fixed seed.

Definition at line 95 of file context.hpp.

Referenced by skylark::sketch::dense_transform_data_t< bstrand::cauchy_distribution >::build(), skylark::utility::uniform_matrix_t< FullyDistVec< IndexType, ValueType > >::generate(), skylark::utility::uniform_matrix_t< SpParMat< IndexType, ValueType, SpDCCols< IndexType, ValueType > > >::generate(), skylark::utility::uniform_matrix_t< elem::Matrix< ValueType > >::generate(), and skylark::utility::uniform_matrix_t< elem::DistMatrix< ValueType, CD, RD > >::generate().

template<typename Distribution >
std::vector<typename Distribution::result_type> skylark::base::context_t::generate_random_samples_array ( size_t  size,
Distribution &  distribution 
) [inline]

Definition at line 160 of file context.hpp.

Returns an integer random number.

Returns:
Random integer number.

This should be used as a global operation to keep the the internal state of the context synchronized.

Definition at line 152 of file context.hpp.

References allocate_random_array().

Here is the call graph for this function:

boost::property_tree::ptree skylark::base::context_t::to_ptree ( ) const [inline]

Definition at line 54 of file context.hpp.

References VERSION.

Referenced by skylark::sketch::sketch_transform_data_t::add_common().


Friends And Related Function Documentation

boost::property_tree::ptree& operator<< ( boost::property_tree::ptree &  sk,
const context_t data 
) [friend]

Serializes the context to a JSON structure.

Parameters:
[out]JSONencoded state of the context.

Definition at line 176 of file context.hpp.


The documentation for this struct was generated from the following file: