Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/sketch/WZT.hpp
Go to the documentation of this file.
00001 #ifndef SKYLARK_WZT_HPP
00002 #define SKYLARK_WZT_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 
00028 template < typename InputMatrixType,
00029            typename OutputMatrixType = InputMatrixType >
00030 struct WZT_t :
00031         public WZT_data_t,
00032         virtual public sketch_transform_t<InputMatrixType, OutputMatrixType > {
00033 
00034 public:
00035 
00036     // We use composition to defer calls to hash_transform_t
00037     typedef hash_transform_t< InputMatrixType, OutputMatrixType,
00038                               boost::random::uniform_int_distribution,
00039                               boost::random::exponential_distribution > transform_t;
00040 
00041     typedef WZT_data_t data_type;
00042     typedef data_type::params_t params_t;
00043 
00044     WZT_t(int N, int S, double p, base::context_t& context)
00045         : data_type(N, S, p, context), _transform(*this) {
00046 
00047     }
00048 
00049     WZT_t(int N, int S, const params_t& params, base::context_t& context)
00050         : data_type(N, S, params, context),
00051           _transform(*this) {
00052 
00053     }
00054 
00055     WZT_t(const boost::property_tree::ptree &pt)
00056         : data_type(pt), _transform(*this) {
00057 
00058     }
00059 
00060     template< typename OtherInputMatrixType,
00061               typename OtherOutputMatrixType >
00062     WZT_t(const WZT_t<OtherInputMatrixType,OtherOutputMatrixType>& other)
00063         : data_type(other), _transform(*this) {
00064 
00065     }
00066 
00067     WZT_t(const data_type& other)
00068         : data_type(other), _transform(*this) {
00069 
00070     }
00071 
00076     void apply (const typename transform_t::matrix_type& A,
00077                 typename transform_t::output_matrix_type& sketch_of_A,
00078                 columnwise_tag dimension) const {
00079         _transform.apply(A, sketch_of_A, dimension);
00080     }
00081 
00086     void apply (const typename transform_t::matrix_type& A,
00087                 typename transform_t::output_matrix_type& sketch_of_A,
00088                 rowwise_tag dimension) const {
00089         _transform.apply(A, sketch_of_A, dimension);
00090     }
00091 
00092     int get_N() const { return this->_N; } 
00093     int get_S() const { return this->_S; } 
00095     const sketch_transform_data_t* get_data() const { return this; }
00096 
00097 private:
00098     transform_t _transform;
00099 };
00100 
00101 } } 
00103 #endif // SKYLARK_WZT_HPP