Tapkee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
eigen_callbacks.hpp
Go to the documentation of this file.
1 /* This software is distributed under BSD 3-clause license (see LICENSE file).
2  *
3  * Copyright (c) 2012-2013 Sergey Lisitsyn, Fernando Iglesias
4  */
5 
6 #ifndef TAPKEE_EIGEN_CALLBACKS_H_
7 #define TAPKEE_EIGEN_CALLBACKS_H_
8 
9 namespace tapkee
10 {
11  // Features callback that provides operation that
12  // puts contents of the specified feature
13  // vector to given DenseVector instance.
15  {
18  {
19  return feature_matrix.rows();
20  }
21  inline void vector(tapkee::IndexType i, tapkee::DenseVector& v) const
22  {
23  v = feature_matrix.col(i);
24  }
26  };
27 
28  // Kernel function callback that computes
29  // similarity function values on vectors
30  // given by their indices. This impl. computes
31  // linear kernel i.e. dot product between two vectors.
33  {
36  {
37  return feature_matrix.col(a).dot(feature_matrix.col(b));
38  }
40  {
41  return kernel(a,b);
42  }
44  };
45 
46  // Distance function callback that provides
47  // dissimilarity function values on vectors
48  // given by their indices. This impl. computes
49  // euclidean distance between two vectors.
51  {
54  {
55  return (feature_matrix.col(a)-feature_matrix.col(b)).norm();
56  }
58  {
59  return distance(a,b);
60  }
62 };
63 
64 }
65 
66 #endif
Eigen::Matrix< tapkee::ScalarType, Eigen::Dynamic, Eigen::Dynamic > DenseMatrix
dense matrix type (non-overridable)
Definition: types.hpp:23
tapkee::ScalarType operator()(tapkee::IndexType a, tapkee::IndexType b) const
void vector(tapkee::IndexType i, tapkee::DenseVector &v) const
double ScalarType
default scalar value (can be overrided with TAPKEE_CUSTOM_INTERNAL_NUMTYPE define) ...
Definition: types.hpp:15
tapkee::IndexType dimension() const
Eigen::Matrix< tapkee::ScalarType, Eigen::Dynamic, 1 > DenseVector
dense vector type (non-overridable)
Definition: types.hpp:21
eigen_distance_callback(const tapkee::DenseMatrix &matrix)
int IndexType
indexing type (non-overridable) set to int for compatibility with OpenMP 2.0
Definition: types.hpp:19
tapkee::ScalarType kernel(tapkee::IndexType a, tapkee::IndexType b) const
eigen_features_callback(const tapkee::DenseMatrix &matrix)
eigen_kernel_callback(const tapkee::DenseMatrix &matrix)
const tapkee::DenseMatrix & feature_matrix
tapkee::ScalarType distance(tapkee::IndexType a, tapkee::IndexType b) const
tapkee::ScalarType operator()(tapkee::IndexType a, tapkee::IndexType b) const
const tapkee::DenseMatrix & feature_matrix
const tapkee::DenseMatrix & feature_matrix