Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/sketch/CWT.hpp
Go to the documentation of this file.
00001 #ifndef SKYLARK_CWT_HPP
00002 #define SKYLARK_CWT_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 
00021 template < typename InputMatrixType,
00022            typename OutputMatrixType = InputMatrixType >
00023 class CWT_t :
00024         public CWT_data_t,
00025         virtual public sketch_transform_t<InputMatrixType, OutputMatrixType > {
00026 
00027 public:
00028 
00029     // We use composition to defer calls to hash_transform_t
00030     typedef hash_transform_t<InputMatrixType, OutputMatrixType,
00031                              boost::random::uniform_int_distribution,
00032                              utility::rademacher_distribution_t> transform_t;
00033 
00034     typedef CWT_data_t data_type;
00035     typedef data_type::params_t params_t;
00036 
00037     CWT_t(int N, int S, base::context_t& context)
00038         : data_type(N, S, context), _transform(*this) {
00039 
00040     }
00041 
00042     CWT_t(int N, int S, const params_t& params, base::context_t& context)
00043         : data_type(N, S, params, context),
00044           _transform(*this) {
00045 
00046     }
00047 
00048     CWT_t(const boost::property_tree::ptree &pt)
00049         : data_type(pt), _transform(*this) {
00050 
00051     }
00052 
00053     template <typename OtherInputMatrixType,
00054               typename OtherOutputMatrixType>
00055     CWT_t(const CWT_t<OtherInputMatrixType,OtherOutputMatrixType>& other)
00056         : data_type(other), _transform(*this) {
00057 
00058     }
00059 
00060     CWT_t(const data_type& other)
00061         : data_type(other), _transform(*this) {
00062 
00063     }
00064 
00069     void apply (const typename transform_t::matrix_type& A,
00070                 typename transform_t::output_matrix_type& sketch_of_A,
00071                 columnwise_tag dimension) const {
00072         _transform.apply(A, sketch_of_A, dimension);
00073     }
00074 
00079     void apply (const typename transform_t::matrix_type& A,
00080                 typename transform_t::output_matrix_type& sketch_of_A,
00081                 rowwise_tag dimension) const {
00082         _transform.apply(A, sketch_of_A, dimension);
00083     }
00084 
00085     int get_N() const { return this->_N; } 
00086     int get_S() const { return this->_S; } 
00088     const sketch_transform_data_t* get_data() const { return this; }
00089 
00090 private:
00091     transform_t _transform;
00092 };
00093 
00094 } } 
00096 #endif // SKYLARK_CWT_HPP