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