Skylark (Sketching Library)
0.1
|
00001 #ifndef SKYLARK_FJLT_DATA_HPP 00002 #define SKYLARK_FJLT_DATA_HPP 00003 00004 #ifndef SKYLARK_SKETCH_HPP 00005 #error "Include top-level sketch.hpp instead of including individuals headers" 00006 #endif 00007 00008 #include <vector> 00009 00010 #include "../utility/randgen.hpp" 00011 #include "../utility/distributions.hpp" 00012 00013 namespace skylark { namespace sketch { 00014 00020 struct FJLT_data_t : public sketch_transform_data_t { 00021 00022 typedef boost::random::uniform_int_distribution<size_t> 00023 value_distribution_type; 00024 typedef utility::rademacher_distribution_t<double> 00025 underlying_value_distribution_type; 00026 00027 typedef sketch_transform_data_t base_t; 00028 00030 struct params_t : public sketch_params_t { 00031 00032 }; 00033 00034 FJLT_data_t (int N, int S, base::context_t& context) 00035 : base_t(N, S, context, "FJLT"), 00036 samples(base_t::_S) { 00037 00038 context = build(); 00039 } 00040 00041 FJLT_data_t (int N, int S, const params_t& params, base::context_t& context) 00042 : base_t(N, S, context, "FJLT"), 00043 samples(base_t::_S) { 00044 00045 context = build(); 00046 } 00047 00048 FJLT_data_t (const boost::property_tree::ptree &pt) : 00049 base_t(pt.get<int>("N"), pt.get<int>("S"), 00050 base::context_t(pt.get_child("creation_context")), "FJLT"), 00051 samples(base_t::_S) { 00052 00053 build(); 00054 } 00055 00061 virtual 00062 boost::property_tree::ptree to_ptree() const { 00063 boost::property_tree::ptree pt; 00064 sketch_transform_data_t::add_common(pt); 00065 return pt; 00066 } 00067 00068 protected: 00069 00070 FJLT_data_t (int N, int S, const base::context_t& context, 00071 std::string type) 00072 : base_t(N, S, context, type), 00073 samples(base_t::_S) { 00074 } 00075 00076 base::context_t build() { 00077 base::context_t ctx = base_t::build(); 00078 underlying_data = boost::shared_ptr<underlying_data_type>(new 00079 underlying_data_type(base_t::_N, ctx)); 00080 value_distribution_type distribution(0, base_t::_N - 1); 00081 samples = ctx.generate_random_samples_array(base_t::_S, distribution); 00082 return ctx; 00083 } 00084 00085 typedef RFUT_data_t<underlying_value_distribution_type> 00086 underlying_data_type; 00087 00088 std::vector<size_t> samples; 00089 boost::shared_ptr<underlying_data_type> underlying_data; 00091 }; 00092 00093 } } 00095 #endif