Skylark (Sketching Library)
0.1
|
00001 #ifndef SKYLARK_CT_DATA_HPP 00002 #define SKYLARK_CT_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 <boost/random.hpp> 00009 #include <boost/property_tree/ptree.hpp> 00010 00011 namespace skylark { namespace sketch { 00012 00013 namespace bstrand = boost::random; 00014 00020 struct CT_data_t : 00021 public dense_transform_data_t<bstrand::cauchy_distribution> { 00022 00023 typedef dense_transform_data_t<bstrand::cauchy_distribution> base_t; 00024 00026 struct params_t : public sketch_params_t { 00027 00028 params_t(double C) : C(C) { 00029 00030 } 00031 00032 const double C; 00033 }; 00034 00035 CT_data_t(int N, int S, double C, skylark::base::context_t& context) 00036 : base_t(N, S, C / static_cast<double>(S), context, "CT"), _C(C) { 00037 00038 context = base_t::build(); 00039 } 00040 00041 CT_data_t(int N, int S, const params_t& params, 00042 skylark::base::context_t& context) 00043 : base_t(N, S, params.C / static_cast<double>(S), context, "CT"), 00044 _C(params.C) { 00045 00046 context = base_t::build(); 00047 } 00048 00049 CT_data_t(const boost::property_tree::ptree &pt) : 00050 base_t(pt.get<int>("N"), pt.get<int>("S"), 00051 pt.get<double>("C") / pt.get<double>("S"), 00052 base::context_t(pt.get_child("creation_context")), "CT"), 00053 _C(pt.get<double>("C")) { 00054 00055 base_t::build(); 00056 } 00057 00063 virtual 00064 boost::property_tree::ptree to_ptree() const { 00065 boost::property_tree::ptree pt; 00066 sketch_transform_data_t::add_common(pt); 00067 pt.put("C", _C); 00068 return pt; 00069 } 00070 00071 protected: 00072 00073 CT_data_t(int N, int S, double C, const skylark::base::context_t& context, 00074 std::string type) 00075 : base_t(N, S, C / static_cast<double>(S), context, type), _C(C) { 00076 00077 } 00078 00079 private: 00080 00081 double _C; 00082 }; 00083 00084 } } 00086 #endif // SKYLARK_CT_DATA_HPP