Tapkee
pimpl_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
00004  */
00005 
00006 #ifndef TAPKEE_PIMPL_CALLBACKS_H_
00007 #define TAPKEE_PIMPL_CALLBACKS_H_
00008 
00009 // Kernel function callback that computes
00010 // similarity function values on vectors 
00011 // given by their indices. This impl. computes 
00012 // kernel i.e. dot product between two vectors.
00013 template<class Implementation>
00014 struct pimpl_kernel_callback
00015 {
00016     pimpl_kernel_callback(Implementation* i) : impl(i) {};
00017     inline tapkee::ScalarType kernel(int a, int b) const
00018     {
00019         return impl->kernel(a,b);
00020     }
00021     Implementation* impl;
00022 };
00023 
00024 // Distance function callback that provides
00025 // dissimilarity function values on vectors
00026 // given by their indices. This impl. computes
00027 // euclidean distance between two vectors.
00028 template<class Implementation>
00029 struct pimpl_distance_callback
00030 {
00031     pimpl_distance_callback(Implementation* i) : impl(i) {};
00032     inline tapkee::ScalarType distance(int a, int b) const
00033     {
00034         return impl->distance(a,b);
00035     }
00036     Implementation* impl;
00037 };
00038 
00039 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines