mathop.h File Reference


Detailed Description

Author:
Andrea Vedaldi

Definition in file mathop.h.

#include "generic.h"

Go to the source code of this file.


Functions

VL_INLINE float vl_mod_2pi_f (float x)
 Modulo 2 PI.
VL_INLINE double vl_mod_2pi_d (double x)
 Modulo 2 PI.
VL_INLINE int vl_floor_f (float x)
 Floor operation ((int) floor(x)).
VL_INLINE int vl_floor_d (double x)
 Floor operation ((int) floor(x)).
VL_INLINE float vl_abs_f (float x)
 Fast abs(x).
VL_INLINE double vl_abs_d (double x)
 Fast abs(x).
VL_INLINE float vl_fast_atan2_f (float y, float x)
 Fast atan2 approximation.
VL_INLINE double vl_fast_atan2_d (double y, double x)
 Fast atan2 approximation.
VL_INLINE float vl_fast_resqrt_f (float x)
 Fast resqrt approximation.
VL_INLINE double vl_fast_resqrt_d (double x)
 Fast resqrt approximation.
VL_INLINE float vl_fast_sqrt_f (float x)
 Fast sqrt approximation.
VL_INLINE double vl_fast_sqrt_d (float x)
 Fast sqrt approximation.
VL_INLINE vl_uint32 vl_fast_sqrt_i (vl_uint32 x)
 Fast sqrt approximation.

Function Documentation

VL_INLINE double vl_abs_d ( double  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
abs(x)

Definition at line 84 of file mathop.h.

Referenced by vl_fast_atan2_d(), and vl_sift_detect().

VL_INLINE float vl_abs_f ( float  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
abs(x)

Definition at line 77 of file mathop.h.

Referenced by vl_fast_atan2_f(), vl_sift_calc_keypoint_descriptor(), and vl_sift_calc_raw_descriptor().

VL_INLINE double vl_fast_atan2_d ( double  y,
double  x 
)

----------------------------------------------------------------

Algorithm

We approximate the function f(r)=atan((1-r)/(1+r)) for r in [-1,1] by fitting a third order polynomial f(r)=c0 + c1 r + c2 r^2 + + c3 r^3. We impose the constraints

 f(+1) = c0 + c1 + c2 + c3 = atan(0) = 0
 f(-1) = c0 - c1 + c2 - c3 = atan(inf) = pi/2
 f(0)  = c0                = atan(1) = pi/4
 

We are still missing a constraint, which we may obtain by minimizing the Linf approximation error. This yields

 c0=pi/4, c1=-0.9675, c2=0, c3=0.1821
 

which has maxerr = 0.0061 rad = 0.35 grad.

Parameters:
x argument.
y argument.
Returns:
Approximation of atan2(x).

Definition at line 146 of file mathop.h.

References vl_abs_d(), and VL_PI.

VL_INLINE float vl_fast_atan2_f ( float  y,
float  x 
)

----------------------------------------------------------------

Algorithm

We approximate the function f(r)=atan((1-r)/(1+r)) for r in [-1,1] by fitting a third order polynomial f(r)=c0 + c1 r + c2 r^2 + + c3 r^3. We impose the constraints

 f(+1) = c0 + c1 + c2 + c3 = atan(0) = 0
 f(-1) = c0 - c1 + c2 - c3 = atan(inf) = pi/2
 f(0)  = c0                = atan(1) = pi/4
 

We are still missing a constraint, which we may obtain by minimizing the Linf approximation error. This yields

 c0=pi/4, c1=-0.9675, c2=0, c3=0.1821
 

which has maxerr = 0.0061 rad = 0.35 grad.

Parameters:
x argument.
y argument.
Returns:
Approximation of atan2(x).

Definition at line 122 of file mathop.h.

References vl_abs_f(), and VL_PI.

Referenced by vl_dhog_process().

VL_INLINE double vl_fast_resqrt_d ( double  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
Approximation to resqrt(x).

Definition at line 200 of file mathop.h.

Referenced by vl_fast_sqrt_d().

VL_INLINE float vl_fast_resqrt_f ( float  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
Approximation to resqrt(x).

Definition at line 175 of file mathop.h.

Referenced by vl_fast_sqrt_f().

VL_INLINE double vl_fast_sqrt_d ( float  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
Approximation to sqrt(x).

Definition at line 244 of file mathop.h.

References vl_fast_resqrt_d().

VL_INLINE float vl_fast_sqrt_f ( float  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
Approximation to sqrt(x).

Definition at line 237 of file mathop.h.

References vl_fast_resqrt_f().

Referenced by normalize_histogram(), and vl_dhog_process().

VL_INLINE vl_uint32 vl_fast_sqrt_i ( vl_uint32  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
Approximation to sqrt(x).

Definition at line 251 of file mathop.h.

VL_INLINE int vl_floor_d ( double  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
(int) floor(x)

Definition at line 60 of file mathop.h.

Referenced by fast_expn(), vl_sift_calc_keypoint_orientations(), and vl_sift_keypoint_init().

VL_INLINE int vl_floor_f ( float  x  ) 

---------------------------------------------------------------

Parameters:
x argument.
Returns:
(int) floor(x)

Definition at line 51 of file mathop.h.

Referenced by vl_dhog_process(), vl_sift_calc_keypoint_descriptor(), and vl_sift_calc_raw_descriptor().

VL_INLINE double vl_mod_2pi_d ( double  x  ) 

--------------------------------------------------------------- The function is optimized for small values of x.

Returns:
mod(x, 2 * VL_PI)

Definition at line 35 of file mathop.h.

References VL_PI.

VL_INLINE float vl_mod_2pi_f ( float  x  ) 

--------------------------------------------------------------- The function is optimized for small values of x.

Returns:
mod(x, 2 * VL_PI)

Definition at line 27 of file mathop.h.

References VL_PI.

Referenced by vl_dhog_process(), vl_sift_calc_keypoint_descriptor(), and vl_sift_calc_raw_descriptor().