DiagKernel.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) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _DIAGKERNEL_H___
00012 #define _DIAGKERNEL_H___
00013 
00014 #include <shogun/lib/common.h>
00015 #include <shogun/kernel/Kernel.h>
00016 
00017 namespace shogun
00018 {
00026 class CDiagKernel: public CKernel
00027 {
00028     public:
00030         CDiagKernel();
00031 
00037         CDiagKernel(int32_t size, float64_t diag=1.0);
00038 
00045         CDiagKernel(CFeatures* l, CFeatures* r, float64_t diag=1.0);
00046 
00047         virtual ~CDiagKernel();
00048 
00055         virtual bool init(CFeatures* l, CFeatures* r);
00056 
00061         inline virtual EFeatureType get_feature_type()
00062         {
00063             return F_ANY;
00064         }
00065 
00070         inline virtual EFeatureClass get_feature_class()
00071         {
00072             return C_ANY;
00073         }
00074 
00079         virtual EKernelType get_kernel_type() { return K_DIAG; }
00080 
00085         virtual const char* get_name() const { return "DiagKernel"; }
00086 
00087     protected:
00096         inline virtual float64_t compute(int32_t idx_a, int32_t idx_b)
00097         {
00098             if (idx_a==idx_b)
00099                 return diag;
00100             else
00101                 return 0;
00102         }
00103     private:
00104         void init();
00105 
00106     protected:
00108         float64_t diag;
00109 };
00110 }
00111 #endif /* _DIAGKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation