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 00017 namespace shogun 00018 { 00026 class CDiagKernel: public CKernel 00027 { 00028 public: 00034 CDiagKernel(int32_t size, float64_t diag=1.0); 00035 00042 CDiagKernel(CFeatures* l, CFeatures* r, float64_t diag=1.0); 00043 00044 virtual ~CDiagKernel(); 00045 00050 inline virtual EFeatureType get_feature_type() 00051 { 00052 return F_ANY; 00053 } 00054 00059 inline virtual EFeatureClass get_feature_class() 00060 { 00061 return C_ANY; 00062 } 00063 00068 virtual EKernelType get_kernel_type() { return K_DIAG; } 00069 00074 virtual const char* get_name() const { return "Diagonal"; } 00075 00076 protected: 00085 inline virtual float64_t compute(int32_t idx_a, int32_t idx_b) 00086 { 00087 if (idx_a==idx_b) 00088 return diag; 00089 else 00090 return 0; 00091 } 00092 00093 protected: 00095 float64_t diag; 00096 }; 00097 } 00098 #endif /* _DIAGKERNEL_H__ */