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