/** @file mathop.c ** @brief Math operations - Definition ** @author Andrea Vedaldi, David Novotny **/ /* Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. All rights reserved. This file is part of the VLFeat library and is made available under the terms of the BSD license (see the COPYING file). */ /** @file mathop.h @section mathop-usage-vector-comparison Comparing vectors @ref mathop.h includes a number of functions to quickly compute distances or similarity of pairs of vector. Applications include clustering and evaluation of SVM-like classifiers. Use ::vl_get_vector_comparison_function_f or ::vl_get_vector_comparison_function_d obtain an approprite function to comprare vectors of floats or doubles, respectively. Such functions are usually optimized (for instance, on X86 platforms they use the SSE vector extension) and are several times faster than a naive implementation. ::vl_eval_vector_comparison_on_all_pairs_f and ::vl_eval_vector_comparison_on_all_pairs_d can be used to evaluate the comparison function on all pairs of one or two sequences of vectors. Let @f$ \mathbf{x} = (x_1,\dots,x_d) @f$ and @f$ \mathbf{y} = (y_1,\dots,y_d) @f$ be two vectors. The following comparison functions are supported:
@f$ l^1 @f$ | ::VlDistanceL1 | @f$ \sum_{i=1}^d |x_i - y_i| @f$ | l1 distance (squared intersection metric) |
@f$ l^2 @f$ | ::VlDistanceL2 | @f$\sum_{i=1}^d (x_i - y_i)^2@f$ | Squared Euclidean disance |
@f$ \chi^2 @f$ | ::VlDistanceChi2 | @f$\sum_{i=1}^d \frac{(x_i - y_i)^2}{x_i + y_i}@f$ | Squared chi-square distance |
- | ::VlDistanceHellinger | @f$\sum_{i=1}^d (\sqrt{x_i} - \sqrt{y_i})^2@f$ | Squared Hellinger's distance |
- | ::VlDistanceJS | @f$ \sum_{i=1}^d \left( x_i \log\frac{2x_i}{x_i+y_i} + y_i \log\frac{2y_i}{x_i+y_i} \right) @f$ | Squared Jensen-Shannon distance |
@f$ l^1 @f$ | ::VlKernelL1 | @f$ \sum_{i=1}^d \min\{ x_i, y_i \} @f$ | intersection kernel |
@f$ l^2 @f$ | ::VlKernelL2 | @f$\sum_{i=1}^d x_iy_i @f$ | linear kernel |
@f$ \chi^2 @f$ | ::VlKernelChi2 | @f$\sum_{i=1}^d 2 \frac{x_iy_i}{x_i + y_i}@f$ | chi-square kernel |
- | ::VlKernelHellinger | @f$\sum_{i=1}^d 2 \sqrt{x_i y_i}@f$ | Hellinger's kernel (Bhattacharya coefficient) |
- | ::VlKernelJS | @f$ \sum_{i=1}^d \left( \frac{x_i}{2} \log_2\frac{x_i+y_i}{x_i} + \frac{y_i}{2} \log_2\frac{x_i+y_i}{y_i} \right) @f$ | Jensen-Shannon kernel |