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) 2012 Viktor Gal 00008 * Copyright (C) 2012 Viktor Gal 00009 */ 00010 00011 #ifndef _PNORM_ONE__H__ 00012 #define _PNORM_ONE__H__ 00013 00014 #include <shogun/preprocessor/DensePreprocessor.h> 00015 #include <shogun/features/Features.h> 00016 #include <shogun/lib/common.h> 00017 00018 #include <stdio.h> 00019 00020 namespace shogun 00021 { 00031 class CPNorm : public CDensePreprocessor<float64_t> 00032 { 00033 public: 00035 CPNorm (); 00036 00040 CPNorm (double p); 00041 00043 virtual ~CPNorm (); 00044 00046 virtual bool init (CFeatures* features); 00048 virtual void cleanup (); 00050 virtual bool load (FILE* f); 00052 virtual bool save (FILE* f); 00053 00057 virtual SGMatrix<float64_t> apply_to_feature_matrix (CFeatures* features); 00058 00061 virtual SGVector<float64_t> apply_to_feature_vector (SGVector<float64_t> vector); 00062 00064 virtual const char* get_name () const { return "PNorm"; } 00065 00067 virtual EPreprocessorType get_type () const { return P_PNORM; } 00068 00073 void set_pnorm (double pnorm); 00074 00079 double get_pnorm () const; 00080 00081 private: 00082 void register_param (); 00083 inline float64_t get_pnorm (float64_t* vec, int32_t vec_len) const; 00084 00085 private: 00086 double m_p; 00087 }; 00088 } 00089 #endif /* _PNORM_ONE__H__ */