ANOVAKernel.h

Go to the documentation of this file.
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) 2011 Andrew Tereskin
00008  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
00009  */
00010 
00011 #include <shogun/lib/config.h>
00012 
00013 #ifndef ANOVAKERNEL_H_
00014 #define ANOVAKERNEL_H_
00015 
00016 #include <shogun/lib/common.h>
00017 #include <shogun/kernel/DotKernel.h>
00018 #include <shogun/features/Features.h>
00019 #include <shogun/features/DenseFeatures.h>
00020 
00021 namespace shogun
00022 {
00023 
00024 class CDistance;
00025 
00037 class CANOVAKernel: public CDotKernel
00038 {
00039 public:
00041     CANOVAKernel();
00042 
00047     CANOVAKernel(int32_t cache, int32_t d);
00048 
00055     CANOVAKernel(
00056         CDenseFeatures<float64_t>* l, CDenseFeatures<float64_t>* r, int32_t d, int32_t cache);
00057 
00058     virtual ~CANOVAKernel();
00059 
00065     virtual bool init(CFeatures* l, CFeatures* r);
00066 
00070     virtual EKernelType get_kernel_type() { return K_ANOVA; }
00071 
00075     virtual EFeatureType get_feature_type() { return F_DREAL; }
00076 
00080     virtual EFeatureClass get_feature_class() { return C_DENSE; }
00081 
00085     virtual const char* get_name() const { return "ANOVAKernel"; }
00086 
00090     inline int32_t get_cardinality() { return this->cardinality; }
00091 
00095     inline void set_cardinality(int32_t value) { this->cardinality = value; }
00096 
00102     float64_t compute_rec1(int32_t idx_a, int32_t idx_b);
00108     float64_t compute_rec2(int32_t idx_a, int32_t idx_b);
00109 protected:
00110 
00118     virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00119 
00121     void init();
00122 
00124     void allocate_arrays();
00125 
00127     virtual void cleanup();
00128 
00130     void register_params();
00131 
00140     virtual void load_serializable_post() throw (ShogunException);
00141 
00142 private:
00143     float64_t compute_recursive1(float64_t* avec, float64_t* bvec, int32_t len);
00144     float64_t compute_recursive2(float64_t* avec, float64_t* bvec, int32_t len);
00145 
00146 protected:
00148     int32_t cardinality;
00149 
00151     float64_t* DP;
00153     int32_t DP_len;
00154 
00156     float64_t* KD;
00158     float64_t* KS;
00160     float64_t* vec_pow;
00161 };
00162 }
00163 
00164 #endif /* ANOVAKERNEL_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation