Skylark (Sketching Library)
0.1
|
00001 #ifndef SKYLARK_JLT_HPP 00002 #define SKYLARK_JLT_HPP 00003 00004 #ifndef SKYLARK_SKETCH_HPP 00005 #error "Include top-level sketch.hpp instead of including individuals headers" 00006 #endif 00007 00008 namespace skylark { namespace sketch { 00009 00010 namespace bstrand = boost::random; 00011 00017 template < typename InputMatrixType, 00018 typename OutputMatrixType = InputMatrixType > 00019 class JLT_t : 00020 public JLT_data_t, 00021 virtual public sketch_transform_t<InputMatrixType, OutputMatrixType > { 00022 00023 public: 00024 00025 // We use composition to defer calls to dense_transform_t 00026 typedef dense_transform_t<InputMatrixType, OutputMatrixType, 00027 bstrand::normal_distribution > transform_t; 00028 00029 typedef JLT_data_t data_type; 00030 typedef data_type::params_t params_t; 00031 00032 JLT_t(int N, int S, base::context_t& context) 00033 : data_type(N, S, context), 00034 _transform(*this) { 00035 00036 } 00037 00038 JLT_t(int N, int S, const params_t& params, base::context_t& context) 00039 : data_type(N, S, params, context), 00040 _transform(*this) { 00041 00042 } 00043 00044 00045 JLT_t(const boost::property_tree::ptree &pt) 00046 : data_type(pt), _transform(*this) { 00047 00048 } 00049 00053 template <typename OtherInputMatrixType, 00054 typename OtherOutputMatrixType> 00055 JLT_t (const JLT_t<OtherInputMatrixType, OtherOutputMatrixType>& other) 00056 : data_type(other), _transform(*this) { 00057 00058 } 00059 00063 JLT_t (const data_type& other) 00064 : data_type(other), _transform(*this) { 00065 00066 } 00067 00072 void apply (const typename transform_t::matrix_type& A, 00073 typename transform_t::output_matrix_type& sketch_of_A, 00074 columnwise_tag dimension) const { 00075 _transform.apply(A, sketch_of_A, dimension); 00076 } 00077 00082 void apply (const typename transform_t::matrix_type& A, 00083 typename transform_t::output_matrix_type& sketch_of_A, 00084 rowwise_tag dimension) const { 00085 _transform.apply(A, sketch_of_A, dimension); 00086 } 00087 00088 int get_N() const { return this->_N; } 00089 int get_S() const { return this->_S; } 00091 const sketch_transform_data_t* get_data() const { return this; } 00092 00093 private: 00094 transform_t _transform; 00095 }; 00096 00097 } } 00099 #endif // SKYLARK_JLT_HPP