00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2010-2011 Alexander Binder 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 * Copyright (C) 2010-2011 Berlin Institute of Technology 00010 */ 00011 00012 #ifndef _RANDOMFOURIERGAUSSPREPROC__H__ 00013 #define _RANDOMFOURIERGAUSSPREPROC__H__ 00014 00015 #include <vector> 00016 #include <algorithm> 00017 00018 #include <shogun/lib/common.h> 00019 #include <shogun/mathematics/Math.h> 00020 #include <shogun/preprocessor/SimplePreprocessor.h> 00021 00022 namespace shogun { 00049 class CRandomFourierGaussPreproc: public CSimplePreprocessor<float64_t> { 00050 public: 00052 CRandomFourierGaussPreproc(); 00053 00055 CRandomFourierGaussPreproc(const CRandomFourierGaussPreproc & pr); 00056 00060 ~CRandomFourierGaussPreproc(); 00061 00067 virtual SGMatrix<float64_t> apply_to_feature_matrix(CFeatures* features); // ref count fo the feature matrix??? 00068 00069 00075 virtual SGVector<float64_t> apply_to_feature_vector(SGVector<float64_t> vector); 00076 00080 virtual EFeatureType get_feature_type(); 00081 00085 virtual EFeatureClass get_feature_class(); 00086 00094 virtual bool init(CFeatures *f); 00095 00099 void set_kernelwidth(const float64_t width); 00100 00105 float64_t get_kernelwidth( ) const; 00106 00112 void get_randomcoefficients(float64_t ** randomcoeff_additive2, 00113 float64_t ** randomcoeff_multiplicative2, 00114 int32_t *dim_feature_space2, int32_t *dim_input_space2, float64_t* kernelwidth2 ) const; 00115 00122 void set_randomcoefficients(float64_t *randomcoeff_additive2, 00123 float64_t * randomcoeff_multiplicative2, 00124 const int32_t dim_feature_space2, const int32_t dim_input_space2, const float64_t kernelwidth2); 00125 00130 void set_dim_input_space(const int32_t dim); 00131 00137 void set_dim_feature_space(const int32_t dim); 00138 00150 bool init_randomcoefficients(); 00151 00152 00156 int32_t get_dim_input_space() const; 00157 00161 int32_t get_dim_feature_space() const; 00162 00166 void cleanup(); 00167 00169 virtual inline const char* get_name() const { return "RandomFourierGaussPreproc"; } 00170 00172 virtual inline EPreprocessorType get_type() const { return P_RANDOMFOURIERGAUSS; } 00173 00174 protected: 00175 00179 void copy(const CRandomFourierGaussPreproc & feats); // helper for two constructors 00180 00181 00185 float64_t kernelwidth; 00186 00190 float64_t cur_kernelwidth; 00191 00195 int32_t dim_input_space; 00196 00200 int32_t cur_dim_input_space; 00201 00202 00206 int32_t dim_feature_space; 00207 00211 int32_t cur_dim_feature_space; 00212 00216 bool test_rfinited() const; 00217 00222 float64_t* randomcoeff_additive; 00223 00228 float64_t* randomcoeff_multiplicative; 00229 }; 00230 } 00231 #endif