/** * @file IntersectionKernelFunction.h * @brief The intersection kernel function as distance measure between two histograms interpreted as vectors (Interface) * @author Alexander Freytag * @date 08-12-2011 (dd-mm-yyyy) */ #ifndef _NICE_INTERSECTIONKERNELFUNCTION #define _NICE_INTERSECTIONKERNELFUNCTION #include #include #include //TODO functions are not allowed to be virtual anymore due to the template usage - any idea how to treat this? //maybe using type erasure: http://www.artima.com/cppsource/type_erasure2.html ? namespace NICE { /** * @class IntersectionKernelFunction * @brief The intersection kernel function as distance measure between two histograms interpreted as vectors * @author Alexander Freytag */ template class IntersectionKernelFunction { protected: public: /** * @brief Default constructor * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ IntersectionKernelFunction(); /** * @brief Default desctructor * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ ~IntersectionKernelFunction(); /** * @brief Measures the distance between tow vectors using the histogram intersection distance * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ double measureDistance ( const std::vector & a, const std::vector & b ); double measureDistance ( const NICE::SparseVector & a, const NICE::SparseVector & b ); /** * @brief Computes the symmetric and positive semi-definite kernel matrix K based on the given examples using the HIK distance * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ NICE::Matrix computeKernelMatrix ( const std::vector > & X ); /** * @brief Computes the symmetric and positive semi-definite kernel matrix K based on the given examples using the HIK distance and add a given amount of noise on the main diagonal * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ NICE::Matrix computeKernelMatrix ( const std::vector > & X , const double & noise); /** * @brief Computes the symmetric and positive semi-definite kernel matrix K based on the given examples using the HIK distance and add a given amount of noise on the main diagonal * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ NICE::Matrix computeKernelMatrix ( const std::vector & X , const double & noise); /** * @brief Computes the symmetric and positive semi-definite kernel matrix K based on the given examples using the HIK distance and add a given amount of noise on the main diagonal * @author Alexander Freytag * @date 03-02-2012 (dd-mm-yyyy) */ NICE::Matrix computeKernelMatrix ( const NICE::FeatureMatrixT & X , const double & noise); /** * @brief Computes the similarity between the data and a new vector using the HIK distance * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ std::vector computeKernelVector ( const std::vector > & X , const std::vector & xstar); NICE::Vector computeKernelVector ( const std::vector & X , const NICE::SparseVector & xstar); /** * @brief Simply print the name of the class * @author Alexander Freytag * @date 23-12-2011 (dd-mm-yyyy) */ void sayYourName(); }; //! default definition for a IntersectionKernelFunction typedef IntersectionKernelFunction IntersectionKernelFunctionDouble; } #ifdef __GNUC__ #include "gp-hik-core/kernels/IntersectionKernelFunction.tcc" #endif #endif