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) 2007-2009 Christian Gehl 00008 * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #include <shogun/lib/config.h> 00012 00013 00014 #ifndef _DISTANCEKERNEL_H___ 00015 #define _DISTANCEKERNEL_H___ 00016 00017 #include <shogun/lib/common.h> 00018 #include <shogun/kernel/Kernel.h> 00019 #include <shogun/distance/Distance.h> 00020 00021 namespace shogun 00022 { 00023 class CDistance; 00024 00033 class CDistanceKernel: public CKernel 00034 { 00035 public: 00037 CDistanceKernel(void); 00038 00045 CDistanceKernel(int32_t cache, float64_t width, CDistance* dist); 00046 00054 CDistanceKernel( 00055 CFeatures *l, CFeatures *r, float64_t width, CDistance* dist); 00056 00057 virtual ~CDistanceKernel(); 00058 00065 virtual bool init(CFeatures* l, CFeatures* r); 00066 00070 virtual void register_params(); 00071 00076 inline virtual EKernelType get_kernel_type() { return K_DISTANCE; } 00081 inline virtual EFeatureType get_feature_type() { return distance->get_feature_type(); } 00082 00087 inline virtual EFeatureClass get_feature_class() { return distance->get_feature_class(); } 00088 00093 inline virtual const char* get_name() const { return "DistanceKernel"; } 00094 00099 inline virtual void set_width(float64_t w) 00100 { 00101 width=w; 00102 } 00103 00108 inline virtual float64_t get_width() const 00109 { 00110 return width; 00111 } 00112 00113 00114 protected: 00123 float64_t compute(int32_t idx_a, int32_t idx_b); 00124 00126 CDistance* distance; 00128 float64_t width; 00129 }; 00130 } 00131 #endif /* _DISTANCEKERNEL_H__ */