Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/sketch/RLT.hpp
Go to the documentation of this file.
00001 #ifndef SKYLARK_RLT_HPP
00002 #define SKYLARK_RLT_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 
00023 template < typename InputMatrixType,
00024            typename OutputMatrixType,
00025            template <typename> class KernelDistribution>
00026 class RLT_t {
00027     // To be specilized and derived.
00028     typedef InputMatrixType matrix_type;
00029     typedef OutputMatrixType output_matrix_type;
00030     typedef RLT_data_t<KernelDistribution> data_type;
00031 
00032     RLT_t(int N, int S, base::context_t& context) 
00033         : data_type(N, S, context) {
00034         SKYLARK_THROW_EXCEPTION (
00035           base::sketch_exception()
00036               << base::error_msg(
00037                  "This combination has not yet been implemented for RLT"));
00038     }
00039 
00040     RLT_t(const data_type& other_data)
00041         : data_type(other_data) {
00042         SKYLARK_THROW_EXCEPTION (
00043           base::sketch_exception()
00044               << base::error_msg(
00045                  "This combination has not yet been implemented for RLT"));
00046     }
00047 
00048     RLT_t(const boost::property_tree::ptree &pt)
00049         : data_type(pt) {
00050         SKYLARK_THROW_EXCEPTION (
00051           base::sketch_exception()
00052               << base::error_msg(
00053                  "This combination has not yet been implemented for RLT"));
00054     }
00055 
00056     void apply (const matrix_type& A,
00057                 output_matrix_type& sketch_of_A,
00058                 columnwise_tag dimension) const {
00059         SKYLARK_THROW_EXCEPTION (
00060           base::sketch_exception()
00061               << base::error_msg(
00062                  "This combination has not yet been implemented for RLT"));
00063     }
00064 
00065     void apply (const matrix_type& A,
00066                 output_matrix_type& sketch_of_A,
00067                 rowwise_tag dimension) const {
00068         SKYLARK_THROW_EXCEPTION (
00069           base::sketch_exception()
00070               << base::error_msg(
00071                  "This combination has not yet been implemented for RLT"));
00072     }
00073 };
00074 
00078 template< typename InputMatrixType,
00079           typename OutputMatrixType>
00080 struct ExpSemigroupRLT_t :
00081     public ExpSemigroupRLT_data_t,
00082     virtual public sketch_transform_t<InputMatrixType, OutputMatrixType > {
00083 
00084     // We use composition to defer calls to RLT_t
00085     typedef RLT_t<InputMatrixType, OutputMatrixType,
00086                   utility::standard_levy_distribution_t > transform_t;
00087 
00088     typedef ExpSemigroupRLT_data_t data_type;
00089     typedef data_type::params_t params_t;
00090 
00091     ExpSemigroupRLT_t(int N, int S, double beta,
00092         base::context_t& context)
00093         : data_type(N, S, beta, context), _transform(*this) {
00094 
00095     }
00096 
00097     ExpSemigroupRLT_t(int N, int S, const params_t& params,
00098         base::context_t& context)
00099         : data_type(N, S, params, context), _transform(*this) {
00100 
00101     }
00102 
00103     ExpSemigroupRLT_t(const boost::property_tree::ptree &pt)
00104         : data_type(pt), _transform(*this) {
00105 
00106     }
00107 
00108     template <typename OtherInputMatrixType,
00109               typename OtherOutputMatrixType>
00110     ExpSemigroupRLT_t(
00111         const ExpSemigroupRLT_t<OtherInputMatrixType, OtherOutputMatrixType>& other)
00112         : data_type(other), _transform(*this) {
00113 
00114     }
00115 
00116     ExpSemigroupRLT_t (const data_type& other)
00117         : data_type(other), _transform(*this) {
00118 
00119     }
00120 
00125     void apply (const typename transform_t::matrix_type& A,
00126                 typename transform_t::output_matrix_type& sketch_of_A,
00127                 columnwise_tag dimension) const {
00128         _transform.apply(A, sketch_of_A, dimension);
00129     }
00130 
00135     void apply (const typename transform_t::matrix_type& A,
00136                 typename transform_t::output_matrix_type& sketch_of_A,
00137                 rowwise_tag dimension) const {
00138         _transform.apply(A, sketch_of_A, dimension);
00139     }
00140 
00141     int get_N() const { return this->_N; } 
00142     int get_S() const { return this->_S; } 
00144     const sketch_transform_data_t* get_data() const { return this; }
00145 
00146 private:
00147     transform_t _transform;
00148 
00149 };
00150 
00151 } } 
00154 #if SKYLARK_HAVE_ELEMENTAL
00155 #include "RLT_Elemental.hpp"
00156 #endif
00157 
00158 #endif // SKYLARK_RLT_HPP