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 "lib/common.h"
00015 #include "kernel/Kernel.h"
00016 
00024 class CDiagKernel: public CKernel
00025 {
00026     public:
00032         CDiagKernel(int32_t size, float64_t diag=1.0);
00033 
00040         CDiagKernel(CFeatures* l, CFeatures* r, float64_t diag=1.0);
00041 
00042         virtual ~CDiagKernel();
00043 
00049         virtual bool load_init(FILE* src);
00050 
00056         virtual bool save_init(FILE* dest);
00057 
00062         inline virtual EFeatureType get_feature_type()
00063         {
00064             return F_ANY;
00065         }
00066 
00071         inline virtual EFeatureClass get_feature_class()
00072         {
00073             return C_ANY;
00074         }
00075 
00080         virtual EKernelType get_kernel_type() { return K_DIAG; }
00081 
00086         virtual const char* get_name() const { return "Diagonal"; }
00087 
00088     protected:
00097         inline virtual float64_t compute(int32_t idx_a, int32_t idx_b)
00098         {
00099             if (idx_a==idx_b)
00100                 return diag;
00101             else
00102                 return 0;
00103         }
00104 
00105     protected:
00107         float64_t diag;
00108 };
00109 
00110 #endif /* _DIAGKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation