<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/test_mathop_abs.c</filename>
    </added>
    <added>
      <filename>src/test_vec_comp.c</filename>
    </added>
    <added>
      <filename>toolbox/demo/vl_demo_alldist.m</filename>
    </added>
    <added>
      <filename>toolbox/misc/vl_alldist.c</filename>
    </added>
    <added>
      <filename>toolbox/misc/vl_simdctrl.c</filename>
    </added>
    <added>
      <filename>toolbox/misc/vl_simdctrl.m</filename>
    </added>
    <added>
      <filename>vl/float.th</filename>
    </added>
    <added>
      <filename>vl/mathop.tc</filename>
    </added>
    <added>
      <filename>vl/mathop_sse2.c</filename>
    </added>
    <added>
      <filename>vl/mathop_sse2.h</filename>
    </added>
    <added>
      <filename>vl/mathop_sse2.tc</filename>
    </added>
    <added>
      <filename>vl/mathop_sse2.th</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -157,6 +157,7 @@ libsrc =                \
  vl\imopv.c             \
  vl\imopv_sse2.c        \
  vl\mathop.c            \
+ vl\mathop_sse2.c       \
  vl\mser.c              \
  vl\pgm.c               \
  vl\random.c            \
@@ -190,6 +191,7 @@ mexsrc =                          \
  toolbox\kmeans\vl_hikmeanspush.c \
  toolbox\kmeans\vl_ikmeans.c      \
  toolbox\kmeans\vl_ikmeanspush.c  \
+ toolbox\misc\vl_alldist.c        \
  toolbox\misc\vl_alldist2.c       \
  toolbox\misc\vl_binsearch.c      \
  toolbox\misc\vl_binsum.c         \
@@ -199,6 +201,7 @@ mexsrc =                          \
  toolbox\misc\vl_inthist.c        \
  toolbox\misc\vl_localmax.c       \
  toolbox\misc\vl_samplinthist.c   \
+ toolbox\misc\vl_simdctrl.c       \
  toolbox\misc\vl_twister.c        \
  toolbox\misc\vl_whistc.c         \
  toolbox\mser\vl_erfill.c         \
@@ -321,6 +324,10 @@ $(mexdir) :
 # --------------------------------------------------------------------
 
 # special sources with SSE2 support
+$(objdir)\mathop_sse2.obj : vl\mathop_sse2.c
+	@echo .... CC [+SSE2] $(@)
+	@$(CC) $(CFLAGS) $(DLL_CFLAGS) /arch:SSE2 /D&quot;__SSE2__&quot; /c /Fo&quot;$(@)&quot; &quot;vl\$(@B).c&quot;
+	
 $(objdir)\imopv_sse2.obj : vl\imopv_sse2.c
 	@echo .... CC [+SSE2] $(@)
 	@$(CC) $(CFLAGS) $(DLL_CFLAGS) /arch:SSE2 /D&quot;__SSE2__&quot; /c /Fo&quot;$(@)&quot; &quot;vl\$(@B).c&quot;</diff>
      <filename>Makefile.mak</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 /** @file    mathop.c
- ** @author  Andrea Vedaldi
  ** @brief   Math operations - Definition
+ ** @author  Andrea Vedaldi
  **/
 
 /* AUTORIGHTS
@@ -11,20 +11,55 @@ General Public License version 2.
 */
 
 #include &quot;mathop.h&quot;
+#include &quot;mathop_sse2.h&quot;
+
+/** @file mathop.h
+ **
+ ** @fn vl_get_vector_comparison_function_f
+ ** @brief Get float vector comparison function from comparison type
+ ** @param type vector comparison type.
+ ** @return comparison function.
+ **/
 
-#define FLOAT_TYPE_FLOAT 1
-#define FLOAT_TYPE_DOUBLE 2
+/** @fn vl_get_vector_comparison_function_d
+ ** @brief Get double vector comparison function from comparison type
+ ** @param type vector comparison type.
+ ** @return comparison function.
+ **/
+
+/** @{ */
 
-#undef FLOAT_TYPE
-#define FLOAT_TYPE FLOAT_TYPE_DOUBLE
+/** @fn vl_eval_vector_comparison_on_all_pairs_d(double*,vl_size,
+ **     double const*,vl_size,double const*,vl_size,VlDoubleVectorComparisonFunction)
+ **/
 
+/** @fn vl_eval_vector_comparison_on_all_pairs_f(float*,vl_size,
+ **     float const*,vl_size,float const*,vl_size,VlFloatVectorComparisonFunction)
+ **
+ ** @param result comparison matrix (output).
+ ** @param dimension number of vector components (rows of @a X and @a Y).
+ ** @param X data matrix X.
+ ** @param Y data matrix Y.
+ ** @param numDataX number of vectors in @a X (columns of @a X)
+ ** @param numDataY number of vectros in @a Y (columns of @a Y)
+ ** @param comparison vector comparison function.
+ **
+ ** The function evaluates @a function on all pairs of columns
+ ** from matrices @a X and @a Y, filling a @a numDataX by @a numDataY
+ ** matrix.
+ **
+ ** If @a Y is a null pointer the function compares all columns from 
+ ** @a X with themselves.
+ **/
 
-#undef FLOAT_TYPE
-#define FLOAT_TYPE FLOAT_TYPE_FLOAT
+/** @} */
 
+#undef FLT
+#define FLT VL_TYPE_FLOAT
+#include &quot;mathop.tc&quot;
 
-float
-vl_dist_l2_f (float * dist, int M, int NX, int NY,
-              float const* x, float const* y) ;
+#undef FLT
+#define FLT VL_TYPE_DOUBLE
+#include &quot;mathop.tc&quot;
 
 </diff>
      <filename>vl/mathop.c</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,7 @@ General Public License version 2.
 #define VL_MATHOP_H
 
 #include &quot;generic.h&quot;
+#include &lt;math.h&gt;
 
 /** @brief Logarithm of 2 (math constant)*/
 #define VL_LOG_OF_2 0.693147180559945
@@ -93,7 +94,7 @@ static union { vl_uint64 raw ; double value ; }
  **
  ** The function is optimized for small absolute values of @a x.
  **
- ** The result is guaranteed not to be smaller than 0. However, due to
+ ** The result is guaranteed to be not smaller than 0. However, due to
  ** finite numerical precision and rounding errors, the result can be
  ** equal to 2 * VL_PI (for instance, if @c x is a very small negative
  ** number).
@@ -150,18 +151,24 @@ vl_floor_d (double x)
  ** @return @c abs(x)
  **/
 
-VL_INLINE
-float
+VL_INLINE float
 vl_abs_f (float x)
 {
-  return (x &gt;= 0) ? x : -x ;
+#ifdef VL_COMPILER_GNU
+  return __builtin_fabsf (x) ;
+#else
+  return fabsf(x) ;
+#endif
 }
 
-VL_INLINE
-double
+VL_INLINE double
 vl_abs_d (double x)
 {
-  return (x &gt;= 0) ? x : -x ;
+#ifdef VL_COMPILER_GNU
+  return __builtin_fabs (x) ;
+#else
+  return fabs(x) ;
+#endif
 }
 /** @} */
 
@@ -333,6 +340,7 @@ vl_fast_resqrt_d (double x)
  ** @{
  ** @brief Fast @c sqrt approximation
  ** @param x argument.
+ ** @return Approximation of @c sqrt(x).
  **
  ** The function computes a fast approximation of @c sqrt(x). 
  **
@@ -373,8 +381,6 @@ vl_fast_resqrt_d (double x)
  ** stored.  Thus initially, @f$ w = 0 @f$ and @f$ k = m - 1 = n/2 - 1
  ** @f$. Then, at each iteration the equation is tested, determining
  ** @f$ b_{m-1}, b_{m-2}, ... @f$ in this order.
- **
- ** @return Approximation of @c sqrt(x).
  **/
 
 VL_INLINE float
@@ -415,31 +421,57 @@ VL_INLINE vl_uint8  vl_fast_sqrt_ui8  (vl_uint8  x) ;
     return y ;                                  \
   }
 
+#ifdef __DOXYGEN__
+#undef VL_FAST_SQRT_UI
+#define VL_FAST_SQRT_UI(T,SFX)
+#endif
 
 VL_FAST_SQRT_UI(vl_uint32, ui32)
 VL_FAST_SQRT_UI(vl_uint16, ui16)
 VL_FAST_SQRT_UI(vl_uint8,  ui8 )
 
-/** ------------------------------------------------------------------
- ** @{
- ** @brief Auto distances.
- ** @param dist pointer to the distance matrix (out).
- ** @param M number of dimensions
- ** @param NX number of data points in X.
- ** @param NY number of data points in Y.
- ** @param X first data set.
- ** @param Y second data set.
- **/
+/** @} */
 
-float
-vl_dist_l2_f (float * dist, int M, int NX, int NY,
-              float const* x, float const* y) ;
+/* ---------------------------------------------------------------- */
 
-float
-vl_dist_l2_d (double * dist, int M, int NX, int NY,
-              double const* x, double const* y) ;
+#ifndef __DOXYGEN__
+typedef float (*VlFloatVectorComparisonFunction)(vl_size dimension, float const * X, float const * Y) ;
+typedef double (*VlDoubleVectorComparisonFunction)(vl_size dimension, double const * X, double const * Y) ;
+#else
+typedef void VlFloatVectorComparisonFunction ;
+typedef void VlDoubleVectorComparisonFunction ;
+#endif
 
-/** @} */
+/** @brief Vector comparison types */
+enum _VlVectorComparisonType {
+  VlDistanceL1,   /**&lt; l1 distance */
+  VlDistanceL2,   /**&lt; l2 distance */
+  VlDistanceChi2, /**&lt; Chi2 distance */
+  VlKernelL1,     /**&lt; l1 kernel */
+  VlKernelL2,     /**&lt; l2 kernel */
+  VlKernelChi2    /**&lt; Chi2 kernel */
+} ;
+
+/** @brief Vector comparison types */
+typedef enum _VlVectorComparisonType VlVectorComparisonType ;
+
+VL_EXPORT VlFloatVectorComparisonFunction
+vl_get_vector_comparison_function_f (VlVectorComparisonType type) ;
+
+VL_EXPORT VlDoubleVectorComparisonFunction
+vl_get_vector_comparison_function_d (VlVectorComparisonType type) ;
+
+VL_EXPORT void
+vl_eval_vector_comparison_on_all_pairs_f (float * result, vl_size dimension,
+                                          float const * X, vl_size numDataX, 
+                                          float const * Y, vl_size numDataY,
+                                          VlFloatVectorComparisonFunction function) ;
+
+VL_EXPORT void
+vl_eval_vector_comparison_on_all_pairs_d (double * result, vl_size dimension,
+                                          double const * X, vl_size numDataX, 
+                                          double const * Y, vl_size numDataY,
+                                          VlDoubleVectorComparisonFunction) ;
 
 /* VL_MATHOP_H */
 #endif </diff>
      <filename>vl/mathop.h</filename>
    </modified>
    <modified>
      <diff>@@ -7,9 +7,20 @@
 	objects = {
 
 /* Begin PBXFileReference section */
+		2D0E6C4A1003DFA300F0864E /* mathop.tc */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 4; path = mathop.tc; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D0E6C4B1003E0DF00F0864E /* float.th */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = float.th; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13EEE1100A511200C072E8 /* mathop_sse2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mathop_sse2.c; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13EEE2100A512C00C072E8 /* mathop_sse2.tc */ = {isa = PBXFileReference; explicitFileType = sourcecode.c; fileEncoding = 4; path = mathop_sse2.tc; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13EEE3100A51F000C072E8 /* mathop_sse2.th */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = mathop_sse2.th; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13EEE4100A539200C072E8 /* mathop_sse2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mathop_sse2.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13EEF8100A5CFE00C072E8 /* test_vec_comp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test_vec_comp.c; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13F028100A6E8800C072E8 /* vl_alldist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vl_alldist.c; path = toolbox/misc/vl_alldist.c; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13F02C100A718600C072E8 /* vl_simdctrl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vl_simdctrl.c; path = toolbox/misc/vl_simdctrl.c; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D13F039100A733D00C072E8 /* vl_simdctrl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = vl_simdctrl.m; path = toolbox/misc/vl_simdctrl.m; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D36D6310DE337C700F6EFD5 /* mexversion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mexversion.c; path = /Applications/MATLAB7/extern/src/mexversion.c; sourceTree = &quot;&lt;absolute&gt;&quot;; };
-		2D624AD20FF927E300DB3122 /* heap-t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = &quot;heap-t.h&quot;; path = &quot;vl/heap-t.h&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D624AD20FF927E300DB3122 /* heap-t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = &quot;heap-t.h&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D624AD60FF9306700DB3122 /* test_heap-t.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = &quot;test_heap-t.c&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D6DD0F4100F5E5E006AE152 /* test_mathop_abs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test_mathop_abs.c; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D6F09EC0E4C6ACA00B77055 /* imopv.tc */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 4; path = imopv.tc; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D70CC780DDE1135000A23DE /* mexutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mexutils.h; path = toolbox/mexutils.h; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D72EAF00E48A42F005DAA47 /* imopv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = imopv.c; sourceTree = &quot;&lt;group&gt;&quot;; };
@@ -67,7 +78,7 @@
 		2D7AD0AC0E38C18600783252 /* doxygen.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = doxygen.conf; path = docsrc/doxygen.conf; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D7AD0AD0E38C18600783252 /* hikm.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = hikm.html; path = docsrc/hikm.html; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D7AD0AE0E38C18600783252 /* ikm.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = ikm.html; path = docsrc/ikm.html; sourceTree = &quot;&lt;group&gt;&quot;; };
-		2D7AD0AF0E38C18600783252 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = index.html; path = docsrc/index.html; sourceTree = &quot;&lt;group&gt;&quot;; };
+		2D7AD0AF0E38C18600783252 /* index.html */ = {isa = PBXFileReference; explicitFileType = text.html.documentation; fileEncoding = 4; name = index.html; path = docsrc/index.html; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D7AD0B00E38C18600783252 /* mser.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = mser.html; path = docsrc/mser.html; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D7AD0B10E38C18600783252 /* sift.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = sift.html; path = docsrc/sift.html; sourceTree = &quot;&lt;group&gt;&quot;; };
 		2D7AD0B20E38C18600783252 /* template.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = template.html; path = docsrc/template.html; sourceTree = &quot;&lt;group&gt;&quot;; };
@@ -139,7 +150,6 @@
 				2D732EAF0CF8C3950099B03C /* toolbox */,
 				2D732DE40CF8C2E40099B03C /* src */,
 				2D7AD0870E38C15700783252 /* doc */,
-				2D624AD20FF927E300DB3122 /* heap-t.h */,
 			);
 			name = vlfeat;
 			sourceTree = &quot;&lt;group&gt;&quot;;
@@ -176,6 +186,8 @@
 				2D732DED0CF8C2E40099B03C /* test_stringop.c */,
 				2D72EB080E48A934005DAA47 /* test_imopv.c */,
 				2D624AD60FF9306700DB3122 /* test_heap-t.c */,
+				2D13EEF8100A5CFE00C072E8 /* test_vec_comp.c */,
+				2D6DD0F4100F5E5E006AE152 /* test_mathop_abs.c */,
 			);
 			path = src;
 			sourceTree = &quot;&lt;group&gt;&quot;;
@@ -195,6 +207,7 @@
 				2D732E830CF8C2E40099B03C /* getopt_long.h */,
 				2DD6700B0FEFE56C005A3664 /* heap.h */,
 				2DD6700C0FEFE56C005A3664 /* heap.c */,
+				2D624AD20FF927E300DB3122 /* heap-t.h */,
 				2D732E840CF8C2E40099B03C /* hikmeans.c */,
 				2D732E850CF8C2E40099B03C /* hikmeans.h */,
 				2D732E860CF8C2E40099B03C /* ikmeans.c */,
@@ -213,8 +226,14 @@
 				2DD99CC70E58A90F00CE1DA1 /* imopv_sse2.tc */,
 				2D765BAD0FEC076700D08578 /* kdtree.c */,
 				2D765BAE0FEC076700D08578 /* kdtree.h */,
-				2D732E8E0CF8C2E40099B03C /* mathop.c */,
+				2D0E6C4B1003E0DF00F0864E /* float.th */,
 				2D732E8F0CF8C2E40099B03C /* mathop.h */,
+				2D732E8E0CF8C2E40099B03C /* mathop.c */,
+				2D0E6C4A1003DFA300F0864E /* mathop.tc */,
+				2D13EEE4100A539200C072E8 /* mathop_sse2.h */,
+				2D13EEE1100A511200C072E8 /* mathop_sse2.c */,
+				2D13EEE3100A51F000C072E8 /* mathop_sse2.th */,
+				2D13EEE2100A512C00C072E8 /* mathop_sse2.tc */,
 				2D732E900CF8C2E40099B03C /* mser.c */,
 				2D732E910CF8C2E40099B03C /* mser.h */,
 				2D732E920CF8C2E40099B03C /* pgm.c */,
@@ -239,6 +258,9 @@
 				2D86B1080F24CC9B00E625D6 /* vl_aib.c */,
 				2D86B1090F24CC9B00E625D6 /* vl_aibhist.c */,
 				2D86B10A0F24CC9B00E625D6 /* vl_alldist2.c */,
+				2D13F028100A6E8800C072E8 /* vl_alldist.c */,
+				2D13F02C100A718600C072E8 /* vl_simdctrl.c */,
+				2D13F039100A733D00C072E8 /* vl_simdctrl.m */,
 				2D86B10B0F24CC9B00E625D6 /* vl_binsearch.c */,
 				2D86B10C0F24CC9B00E625D6 /* vl_binsum.c */,
 				2DE5B3A80FDC3471008CEB1D /* vl_dsift.c */,</diff>
      <filename>vlfeat.xcodeproj/project.pbxproj</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ec8d4e5daa14e856db3ac141dfebf6df5a2ab043</id>
    </parent>
  </parents>
  <author>
    <name>Andrea Vedaldi</name>
    <email>vedaldi@gmail.com</email>
  </author>
  <url>http://github.com/vlfeat/vlfeat/commit/a08d8f42df7143a4899e36772648ca16f23ca48c</url>
  <id>a08d8f42df7143a4899e36772648ca16f23ca48c</id>
  <committed-date>2009-08-25T06:07:53-07:00</committed-date>
  <authored-date>2009-08-23T04:02:44-07:00</authored-date>
  <message>NEW: adds improved vector-vetcor comparison functions</message>
  <tree>72a4d940791d20b5bc0804882f3614577eb494cc</tree>
  <committer>
    <name>Andrea Vedaldi</name>
    <email>vedaldi@gmail.com</email>
  </committer>
</commit>
