// /** // * @file IntersectionKernelFunction.cpp // * @brief Implementation for the intersection kernel function as distance measure between two histograms interpreted as vectors // * @author Alexander Freytag // * @date 08-12-2011 (dd-mm-yyyy) // */ // // #include "IntersectionKernelFunction.h" // // using namespace NICE; // // template // IntersectionKernelFunction::IntersectionKernelFunction() // { // } // // template // IntersectionKernelFunction::~IntersectionKernelFunction() // { // } // // template // double IntersectionKernelFunction::measureDistance ( const NICE::SparseVector & a, const NICE::SparseVector & b ) // { // double distance(0.0); // // for (NICE::SparseVector::const_iterator itA = a.begin(); itA != a.end(); itA++) // { // NICE::SparseVector::const_iterator itB = b.find(itA->first); // if (itB != b.end()) // distance += std::min(itA->second , itB->second); // } // // return distance; // } // // template // NICE::Matrix IntersectionKernelFunction::computeKernelMatrix ( const std::vector & X , const double & noise) // { // NICE::Matrix K; // K.resize(X.size(), X.size()); // K.set(0.0); // // for (int i = 0; i < X.size(); i++) // { // for (int j = i; j < X.size(); j++) // { // K(i,j) = measureDistance(X[i],X[j]); // if (i!=j) // K(j,i) = K(i,j); // } // } // // //add noise on the main diagonal // for (int i = 0; i < (int) X.size(); i++) // K(i,i) += noise; // return K; // } // // template // std::vector IntersectionKernelFunction::computeKernelVector ( const std::vector & X , const NICE::SparseVector & xstar) // { // std::vector kstar; // // kstar.resize((int) X.size()); // // for (int i = 0; i < (int) X.size(); i++) // { // kstar[i] = measureDistance(X[i], xstar); // } // // return kstar; // } // // template // void IntersectionKernelFunction::sayYourName() // { // std::cerr << "I'm the Intersection Kernel." << std::endl; // }