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-2008 Soeren Sonnenburg
00008  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _DIAGKERNEL_H___
00012 #define _DIAGKERNEL_H___
00013 
00014 #include "lib/common.h"
00015 #include "kernel/Kernel.h"
00016 
00023 class CDiagKernel: public CKernel
00024 {
00025     public:
00031         CDiagKernel(INT size, DREAL diag=1.0);
00032 
00039         CDiagKernel(CFeatures* l, CFeatures* r, DREAL diag=1.0);
00040 
00041         virtual ~CDiagKernel();
00042 
00048         virtual bool load_init(FILE* src);
00049 
00055         virtual bool save_init(FILE* dest);
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() { return "Diagonal"; }
00086 
00087     protected:
00096         inline virtual DREAL compute(INT idx_a, INT idx_b)
00097         {
00098             if (idx_a==idx_b)
00099                 return diag;
00100             else
00101                 return 0;
00102         }
00103 
00104     protected:
00106         double diag;
00107 };
00108 
00109 #endif /* _DIAGKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation