Defines | Enumerations | Functions | Variables
vl_alldist2.c File Reference
#include <mexutils.h>
#include <vl/mathop.h>
#include <vl/generic.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <assert.h>
Include dependency graph for vl_alldist2.c:

Go to the source code of this file.

Defines

#define ABS(x)   ((x) >= 0 ? (x) : -(x))
#define ABS_DIFF(x, y)   ((x) >= (y) ? ((x) - (y)) : ((y) - (x)))
#define CMP(s1, s2)   ((double)MIN(s1,s2))
#define CORE(NORM, F, DC, AC)
#define CORE_SPARSE(NORM, F)
#define DEF_CLASS(NORM, F)
#define DISPATCH_CLASS(NORM, DC, AC)
#define DISPATCH_NORM(NORM)
#define DOUBLE_t   double
#define F_CHI2(AC, x, y)
#define F_HELL(AC, x, y)   F_HELL_ ## AC (x,y)
#define F_HELL_DOUBLE(x, y)   { acc += x + y - 2 * sqrt (x * y) ; }
#define F_HELL_INT16(x, y)   { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }
#define F_HELL_INT32(x, y)   { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }
#define F_HELL_INT8(x, y)   { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }
#define F_HELL_SINGLE(x, y)   { acc += x + y - 2 * sqrtf (x * y) ; }
#define F_HELL_UINT16(x, y)   { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }
#define F_HELL_UINT32(x, y)   { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }
#define F_HELL_UINT8(x, y)   { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }
#define F_KCHI2(AC, x, y)
#define F_KHELL(AC, x, y)   F_KHELL_ ## AC (x,y)
#define F_KHELL_DOUBLE(x, y)   { acc += sqrt (x * y) ; }
#define F_KHELL_INT16(x, y)   { acc += vl_fast_sqrt_ui32 (x * y) ; }
#define F_KHELL_INT32(x, y)   { acc += vl_fast_sqrt_ui32 (x * y) ; }
#define F_KHELL_INT8(x, y)   { acc += vl_fast_sqrt_ui32 (x * y) ; }
#define F_KHELL_SINGLE(x, y)   { acc += sqrtf (x * y) ; }
#define F_KHELL_UINT16(x, y)   { acc += vl_fast_sqrt_ui32 (x * y) ; }
#define F_KHELL_UINT32(x, y)   { acc += vl_fast_sqrt_ui32 (x * y) ; }
#define F_KHELL_UINT8(x, y)   { acc += vl_fast_sqrt_ui32 (x * y) ; }
#define F_KL1(AC, x, y)   { acc += MIN(x,y) ; }
#define F_KL2(AC, x, y)   { acc += (x*y) ; }
#define F_L0(AC, x, y)   { acc += (x) != (y) ; }
#define F_L1(AC, x, y)   { acc += ABS_DIFF(x,y) ; }
#define F_L2(AC, x, y)   { AC ## _t tmp = ABS_DIFF(x,y) ; acc += tmp * tmp ; }
#define F_LINF(AC, x, y)   { acc = MAX(acc, ABS_DIFF(x,y)) ; }
#define F_MIN(AC, x, y)   { acc += MIN(x,y) ; }
#define INT16_t   vl_int16
#define INT32_t   vl_int32
#define INT8_t   vl_int8
#define MAX(x, y)   ((x) >= (y) ? (x) : (y))
#define MIN(x, y)   ((x) <= (y) ? (x) : (y))
#define SINGLE_t   float
#define sqrtf(x)   ((float)sqrt(x))
#define UINT16_t   vl_uint16
#define UINT32_t   vl_uint32
#define UINT8_t   vl_uint8

Enumerations

enum  {
  opt_LINF, opt_L2, opt_L1, opt_L0,
  opt_CHI2, opt_HELL, opt_KL2, opt_KL1,
  opt_KCHI2, opt_KHELL, opt_MIN
}

Functions

void mexFunction (int nout, mxArray *out[], int nin, const mxArray *in[])

Variables

vlmxOption options []

Define Documentation

#define ABS (   x)    ((x) >= 0 ? (x) : -(x))

Definition at line 67 of file vl_alldist2.c.

#define ABS_DIFF (   x,
 
)    ((x) >= (y) ? ((x) - (y)) : ((y) - (x)))

Definition at line 68 of file vl_alldist2.c.

#define CMP (   s1,
  s2 
)    ((double)MIN(s1,s2))

Definition at line 78 of file vl_alldist2.c.

#define CORE (   NORM,
  F,
  DC,
  AC 
)
Value:
void                                                                  \
  dist ## NORM ## _ ## DC ## _ ## AC                                    \
  (                                                                     \
   AC ## _t * pt, DC ## _t * s1_pt,                                     \
   DC ## _t * s2_pt,                                                    \
   vl_size L, vl_size N1, vl_size N2,                                   \
   bool self)                                                           \
  {                                                                     \
    vl_uindex j1,j2,l ;                                                 \
    for(j2 = 0 ; j2 < N2 ; ++j2)  {                                     \
      for(j1 = 0 ; j1 < N1 ; ++j1) {                                    \
        if(! self || j1>=j2) {                                          \
          AC ## _t acc = 0 ;                                            \
          DC ## _t * s1_it = s1_pt + L*j1 ;                             \
          DC ## _t * s2_it = s2_pt + L*j2 ;                             \
          for(l = 0 ; l < L ; ++l) {                                    \
            AC ## _t s1 = *s1_it++ ;                                    \
            AC ## _t s2 = *s2_it++ ;                                    \
            F(AC, s1, s2)                                               \
          }                                                             \
          *pt = acc;                                                    \
        } else {                                                        \
          *pt = *(pt + (j1 - j2) * (N1 - 1))  ;                         \
        }                                                               \
        pt++ ;                                                          \
      }                                                                 \
    }                                                                   \
  }                                                                     \

Definition at line 89 of file vl_alldist2.c.

#define CORE_SPARSE (   NORM,
 
)

Definition at line 119 of file vl_alldist2.c.

#define DEF_CLASS (   NORM,
 
)
Value:
CORE (NORM,  F,  INT8,     INT32)                \
  CORE (NORM,  F,  UINT8,   UINT32)                \
  CORE (NORM,  F,  INT16,    INT32)                \
  CORE (NORM,  F,  UINT16,  UINT32)                \
  CORE (NORM,  F,  INT32,    INT32)                \
  CORE (NORM,  F,  UINT32,  UINT32)                \
  CORE (NORM,  F,  SINGLE,  SINGLE)                \
  CORE (NORM,  F,  DOUBLE,  DOUBLE)

Definition at line 203 of file vl_alldist2.c.

#define DISPATCH_CLASS (   NORM,
  DC,
  AC 
)
Value:
case mx ## DC ## _CLASS :                                             \
    acc_class = mx ## AC ## _CLASS ;                                    \
  out[OUT_D] = mxCreateNumericArray(2,dims,acc_class,mxREAL) ;          \
  dist ## NORM ## _ ## DC ## _ ## AC                                    \
    ( (AC ## _t *)mxGetData(out[OUT_D]),                                \
      (DC ## _t *)s1_pt,                                                \
      (DC ## _t *)s2_pt,                                                \
      L, N1, N2,                                                        \
      self ) ;                                                          \
  break ;
#define DISPATCH_NORM (   NORM)
Value:
case opt_ ## NORM :                                                   \
    if (sparse) {                                                       \
      out[OUT_D] = mxCreateNumericArray(2,dims,mxDOUBLE_CLASS,mxREAL) ; \
      CORE_SPARSE(NORM, VL_XCAT(F_, NORM))                              \
    } else {                                                            \
      switch (data_class) {                                             \
        DISPATCH_CLASS(NORM,  UINT8 , UINT32)                           \
          DISPATCH_CLASS(NORM,  INT8 ,  INT32)                          \
          DISPATCH_CLASS(NORM, UINT16, UINT32)                          \
          DISPATCH_CLASS(NORM,  INT16,  INT32)                          \
          DISPATCH_CLASS(NORM, UINT32, UINT32)                          \
          DISPATCH_CLASS(NORM,  INT32,  INT32)                          \
          DISPATCH_CLASS(NORM, SINGLE, SINGLE)                          \
          DISPATCH_CLASS(NORM, DOUBLE,DOUBLE)                           \
      default:                                                          \
        mexErrMsgTxt("Data class not supported!") ;                     \
      }                                                                 \
    }                                                                   \
  break ;
#define DOUBLE_t   double

Definition at line 87 of file vl_alldist2.c.

#define F_CHI2 (   AC,
  x,
 
)
Value:
{                                                      \
    AC ## _t  meant2 = ((x) + (y))  ;                    \
    if (meant2 != 0) {                                   \
      AC ## _t tmp  = ABS_DIFF(x,y) ;                    \
      acc += tmp * tmp / meant2 ;                        \
    }                                                    \
  }

Definition at line 217 of file vl_alldist2.c.

#define F_HELL (   AC,
  x,
 
)    F_HELL_ ## AC (x,y)

Definition at line 233 of file vl_alldist2.c.

#define F_HELL_DOUBLE (   x,
 
)    { acc += x + y - 2 * sqrt (x * y) ; }

Definition at line 226 of file vl_alldist2.c.

#define F_HELL_INT16 (   x,
 
)    { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 230 of file vl_alldist2.c.

#define F_HELL_INT32 (   x,
 
)    { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 228 of file vl_alldist2.c.

#define F_HELL_INT8 (   x,
 
)    { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 232 of file vl_alldist2.c.

#define F_HELL_SINGLE (   x,
 
)    { acc += x + y - 2 * sqrtf (x * y) ; }

Definition at line 225 of file vl_alldist2.c.

#define F_HELL_UINT16 (   x,
 
)    { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 229 of file vl_alldist2.c.

#define F_HELL_UINT32 (   x,
 
)    { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 227 of file vl_alldist2.c.

#define F_HELL_UINT8 (   x,
 
)    { acc += x + y - 2 * vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 231 of file vl_alldist2.c.

#define F_KCHI2 (   AC,
  x,
 
)
Value:
{                                                      \
    AC ## _t  mean = ((x) + (y)) / 2  ;                  \
    if (mean != 0) {                                     \
      AC ## _t tmp  = (x) * (y) ;                        \
      acc += tmp / mean ;                                \
    }                                                    \
  }

Definition at line 238 of file vl_alldist2.c.

#define F_KHELL (   AC,
  x,
 
)    F_KHELL_ ## AC (x,y)

Definition at line 254 of file vl_alldist2.c.

#define F_KHELL_DOUBLE (   x,
 
)    { acc += sqrt (x * y) ; }

Definition at line 247 of file vl_alldist2.c.

#define F_KHELL_INT16 (   x,
 
)    { acc += vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 251 of file vl_alldist2.c.

#define F_KHELL_INT32 (   x,
 
)    { acc += vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 249 of file vl_alldist2.c.

#define F_KHELL_INT8 (   x,
 
)    { acc += vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 253 of file vl_alldist2.c.

#define F_KHELL_SINGLE (   x,
 
)    { acc += sqrtf (x * y) ; }

Definition at line 246 of file vl_alldist2.c.

#define F_KHELL_UINT16 (   x,
 
)    { acc += vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 250 of file vl_alldist2.c.

#define F_KHELL_UINT32 (   x,
 
)    { acc += vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 248 of file vl_alldist2.c.

#define F_KHELL_UINT8 (   x,
 
)    { acc += vl_fast_sqrt_ui32 (x * y) ; }

Definition at line 252 of file vl_alldist2.c.

#define F_KL1 (   AC,
  x,
 
)    { acc += MIN(x,y) ; }

Definition at line 236 of file vl_alldist2.c.

#define F_KL2 (   AC,
  x,
 
)    { acc += (x*y) ; }

Definition at line 235 of file vl_alldist2.c.

#define F_L0 (   AC,
  x,
 
)    { acc += (x) != (y) ; }

Definition at line 213 of file vl_alldist2.c.

#define F_L1 (   AC,
  x,
 
)    { acc += ABS_DIFF(x,y) ; }

Definition at line 214 of file vl_alldist2.c.

#define F_L2 (   AC,
  x,
 
)    { AC ## _t tmp = ABS_DIFF(x,y) ; acc += tmp * tmp ; }

Definition at line 215 of file vl_alldist2.c.

#define F_LINF (   AC,
  x,
 
)    { acc = MAX(acc, ABS_DIFF(x,y)) ; }

Definition at line 216 of file vl_alldist2.c.

#define F_MIN (   AC,
  x,
 
)    { acc += MIN(x,y) ; }

Definition at line 237 of file vl_alldist2.c.

#define INT16_t   vl_int16

Definition at line 83 of file vl_alldist2.c.

#define INT32_t   vl_int32

Definition at line 85 of file vl_alldist2.c.

#define INT8_t   vl_int8

Definition at line 81 of file vl_alldist2.c.

#define MAX (   x,
 
)    ((x) >= (y) ? (x) : (y))

Definition at line 66 of file vl_alldist2.c.

#define MIN (   x,
 
)    ((x) <= (y) ? (x) : (y))

Definition at line 65 of file vl_alldist2.c.

#define SINGLE_t   float

Definition at line 86 of file vl_alldist2.c.

#define sqrtf (   x)    ((float)sqrt(x))

Definition at line 71 of file vl_alldist2.c.

#define UINT16_t   vl_uint16

Definition at line 82 of file vl_alldist2.c.

#define UINT32_t   vl_uint32

Definition at line 84 of file vl_alldist2.c.

#define UINT8_t   vl_uint8

Definition at line 80 of file vl_alldist2.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
opt_LINF 
opt_L2 
opt_L1 
opt_L0 
opt_CHI2 
opt_HELL 
opt_KL2 
opt_KL1 
opt_KCHI2 
opt_KHELL 
opt_MIN 

Definition at line 25 of file vl_alldist2.c.


Function Documentation

void mexFunction ( int nout  ,
mxArray *  out[],
int  nin,
const mxArray *  in[] 
)

----------------------------------------------------------------- Check the arguments --------------------------------------------------------------

Definition at line 272 of file vl_alldist2.c.


Variable Documentation

Initial value:
 {
  {"linf",         0,   opt_LINF          },
  {"l2",           0,   opt_L2            },
  {"l1",           0,   opt_L1            },
  {"l0",           0,   opt_L0            },
  {"chi2",         0,   opt_CHI2          },
  {"hell",         0,   opt_HELL          },

  {"kl2",          0,   opt_KL2           },
  {"kl1",          0,   opt_KL1           },
  {"kchi2",        0,   opt_KCHI2         },
  {"khell",        0,   opt_KHELL         },

  {"min",          0,   opt_MIN           },
  {0,              0,   0                 }
}

Definition at line 41 of file vl_alldist2.c.



libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:52