Tapkee
precomputed_callbacks.hpp
Go to the documentation of this file.
00001 /* This software is distributed under BSD 3-clause license (see LICENSE file).
00002  *
00003  * Copyright (c) 2012-2013 Sergey Lisitsyn, Fernando Iglesias
00004  */
00005 
00006 #ifndef TAPKEE_PRECOMPUTED_CALLBACKS_H_
00007 #define TAPKEE_PRECOMPUTED_CALLBACKS_H_
00008 
00009 namespace tapkee
00010 {
00011 // Here we provide basic but still full set of callbacks
00012 // based on the Eigen3 template matrix library
00013 
00014 // Kernel function callback that computes
00015 // similarity function values on vectors 
00016 // given by their indices. This impl. computes 
00017 // linear kernel i.e. dot product between two vectors.
00018 struct precomputed_kernel_callback
00019 {
00020     precomputed_kernel_callback(const tapkee::DenseMatrix& matrix) : kernel_matrix(matrix) {};
00021     inline tapkee::ScalarType kernel(int a, int b) const
00022     {
00023         return kernel_matrix(a,b);
00024     }
00025     const tapkee::DenseMatrix& kernel_matrix;
00026 };
00027 
00028 // Distance function callback that provides
00029 // dissimilarity function values on vectors
00030 // given by their indices. This impl. computes
00031 // euclidean distance between two vectors.
00032 struct precomputed_distance_callback
00033 {
00034     precomputed_distance_callback(const tapkee::DenseMatrix& matrix) : distance_matrix(matrix) {};
00035     inline tapkee::ScalarType distance(int a, int b) const
00036     {
00037         return distance_matrix(a,b);
00038     }
00039     const tapkee::DenseMatrix& distance_matrix;
00040 };
00041 
00042 }
00043 #endif
00044 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines