Skylark (Sketching Library)
0.1
|
#include <context.hpp>
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) |
A structure that holds basic information about the state of the random number stream.
Definition at line 19 of file context.hpp.
skylark::base::context_t::context_t | ( | int | seed, |
int | counter = 0 |
||
) | [inline] |
Initialize context with a seed.
[in] | seed | Random 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.
[in] | filename | of JSON structure encoding serialized state. |
Definition at line 49 of file context.hpp.
skylark::utility::random_array_t skylark::base::context_t::allocate_random_array | ( | size_t | size | ) | [inline] |
Returns a container of random numbers to be accessed as an array.
[in] | size | The size of the 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().
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.
[in] | size | The size of the container. |
[in] | distribution | The distribution to draw samples from. |
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().
std::vector<typename Distribution::result_type> skylark::base::context_t::generate_random_samples_array | ( | size_t | size, |
Distribution & | distribution | ||
) | [inline] |
Returns a vector of samples drawn from a distribution.
[in] | size | The size of the vector. |
[in] | distribution | The distribution to draw samples from. |
Definition at line 110 of file context.hpp.
References SKYLARK_THROW_EXCEPTION.
Referenced by skylark::algorithms::accelerated_regression_solver_t< regression_problem_t< elem::DistMatrix< ValueType, VD, elem::STAR >, linear_tag, l2_tag, no_reg_tag >, elem::DistMatrix< ValueType, VD, elem::STAR >, elem::DistMatrix< ValueType, elem::STAR, elem::STAR >, blendenpik_tag< PrecondTag > >::accelerated_regression_solver_t(), skylark::sketch::RFUT_data_t< ValueDistributionType >::build(), skylark::sketch::hash_transform_data_t< boost::random::uniform_int_distribution, skylark::utility::rademacher_distribution_t >::build(), skylark::sketch::RFT_data_t< bstrand::cauchy_distribution >::build(), skylark::sketch::FJLT_data_t::build(), and skylark::sketch::PPT_data_t::build().
size_t skylark::base::context_t::get_counter | ( | ) | [inline] |
Definition at line 160 of file context.hpp.
int skylark::base::context_t::random_int | ( | ) | [inline] |
Returns an integer random 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().
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().
boost::property_tree::ptree& operator<< | ( | boost::property_tree::ptree & | sk, |
const context_t & | data | ||
) | [friend] |
Serializes the context to a JSON structure.
[out] | JSON | encoded state of the context. |
Definition at line 176 of file context.hpp.