Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/sketch/CT.hpp
Go to the documentation of this file.
00001 #ifndef SKYLARK_CT_HPP
00002 #define SKYLARK_CT_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 struct CT_t :
00020   public CT_data_t,
00021   virtual public sketch_transform_t<InputMatrixType, OutputMatrixType > {
00022 
00023 
00024     // We use composition to defer calls to dense_transform_t
00025     typedef dense_transform_t<InputMatrixType, OutputMatrixType,
00026                                bstrand::cauchy_distribution > transform_t;
00027 
00028     typedef CT_data_t data_type;
00029     typedef data_type::params_t params_t;
00030 
00034     CT_t(int N, int S, double C, base::context_t& context)
00035         : data_type(N, S, C, context), _transform(*this) {
00036 
00037     }
00038 
00039     CT_t(int N, int S, const params_t& params, base::context_t& context)
00040         : data_type(N, S, params, context),
00041           _transform(*this) {
00042 
00043     }
00044 
00045     CT_t(const boost::property_tree::ptree &pt)
00046         : data_type(pt), _transform(*this) {
00047 
00048     }
00049 
00050 
00054     template <typename OtherInputMatrixType,
00055               typename OtherOutputMatrixType>
00056     CT_t (const CT_t<OtherInputMatrixType, OtherOutputMatrixType>& other)
00057         : data_type(other), _transform(*this) {
00058 
00059     }
00060 
00064     CT_t (const data_type& other)
00065         : data_type(other), _transform(*this) {
00066 
00067     }
00068 
00073     void apply (const typename transform_t::matrix_type& A,
00074                 typename transform_t::output_matrix_type& sketch_of_A,
00075                 columnwise_tag dimension) const {
00076         _transform.apply(A, sketch_of_A, dimension);
00077     }
00078 
00083     void apply (const typename transform_t::matrix_type& A,
00084                 typename transform_t::output_matrix_type& sketch_of_A,
00085                 rowwise_tag dimension) const {
00086         _transform.apply(A, sketch_of_A, dimension);
00087     }
00088 
00089     int get_N() const { return this->_N; } 
00090     int get_S() const { return this->_S; } 
00092     const sketch_transform_data_t* get_data() const { return this; }
00093 
00094 private:
00095     transform_t _transform;
00096 };
00097 
00098 } } 
00100 #endif // SKYLARK_CT_HPP