SHOGUN
v3.2.0
|
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); 00103 00109 float64_t compute_rec2(int32_t idx_a, int32_t idx_b); 00110 protected: 00111 00119 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00120 00122 void register_params(); 00123 00124 private: 00125 float64_t compute_recursive1(float64_t* avec, float64_t* bvec, int32_t len); 00126 float64_t compute_recursive2(float64_t* avec, float64_t* bvec, int32_t len); 00127 00128 protected: 00130 int32_t cardinality; 00131 }; 00132 } 00133 00134 #endif /* ANOVAKERNEL_H_ */