Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
math.h File Reference
#include <stddef.h>
#include <math.h>
#include <stdint.h>
#include "common/darktable.h"
+ Include dependency graph for math.h:

Go to the source code of this file.

Data Structures

union  float_int
 

Macros

#define NORM_MIN   1.52587890625e-05f
 
#define M_LN10   2.30258509299404568402
 
#define M_PI   3.14159265358979323846
 
#define M_PI_F   3.14159265358979324f
 
#define DT_M_PI_F   (3.14159265358979324f)
 
#define DT_M_PI   (3.14159265358979324)
 
#define DT_M_LN2f   (0.6931471805599453f)
 
#define DT_FMA(x, y, z)   ((x) * (y) + (z))
 
#define PHI   1.61803398874989479F
 
#define INVPHI   0.61803398874989479F
 
#define CLAMPS(A, L, H)   ((A) > (L) ? ((A) < (H) ? (A) : (H)) : (L))
 
#define CLIP(x)   (((x) >= 0) ? ((x) <= 1 ? (x) : 1) : 0)
 
#define MM_CLIP_PS(X)   (_mm_min_ps(_mm_max_ps((X), _mm_setzero_ps()), _mm_set1_ps(1.0)))
 
#define LCLIP(x)   ((x < 0) ? 0.0 : (x > 100.0) ? 100.0 : x)
 
#define CLAMPF(a, mn, mx)   ((a) >= (mn) ? ((a) <= (mx) ? (a) : (mx)) : (mn))
 

Functions

static float clamp_range_f (const float x, const float low, const float high)
 
static float Kahan_sum (const float m, float *const __restrict__ c, const float add)
 
static float Log2 (float x)
 
static float Log2Thres (float x, float Thres)
 
static float fastlog2 (float x)
 
static float fastlog (float x)
 
static void mat3mulv (float *const __restrict__ dest, const float *const mat, const float *const __restrict__ v)
 
static void mat3mul (float *const __restrict__ dest, const float *const __restrict__ m1, const float *const __restrict__ m2)
 
static void mul_mat_vec_2 (const float *m, const float *p, float *o)
 
static float scalar_product (const dt_aligned_pixel_t v_1, const dt_aligned_pixel_t v_2)
 
static float sqf (const float x)
 
static float euclidean_norm (const dt_aligned_pixel_t vector)
 
static void downscale_vector (dt_aligned_pixel_t vector, const float scaling)
 
static void upscale_vector (dt_aligned_pixel_t vector, const float scaling)
 
static float dt_log2f (const float f)
 
static float dt_fast_hypotf (const float x, const float y)
 
static float dt_fast_expf (const float x)
 
static void dt_fast_expf_4wide (const float x[4], float result[4])
 
static float dt_fast_mexp2f (const float x)
 
static float fast_mexp2f (const float x)
 
static float ceil_fast (float x)
 
static float sinf_fast (float t)
 
static int ipow (int base, int exp)
 Fast integer power, computing base^exp.
 
static void dt_vector_sin (const dt_aligned_pixel_t arg, dt_aligned_pixel_t sine)
 

Macro Definition Documentation

◆ CLAMPF

#define CLAMPF (   a,
  mn,
  mx 
)    ((a) >= (mn) ? ((a) <= (mx) ? (a) : (mx)) : (mn))

◆ CLAMPS

#define CLAMPS (   A,
  L,
  H 
)    ((A) > (L) ? ((A) < (H) ? (A) : (H)) : (L))

◆ CLIP

#define CLIP (   x)    (((x) >= 0) ? ((x) <= 1 ? (x) : 1) : 0)

◆ DT_FMA

#define DT_FMA (   x,
  y,
 
)    ((x) * (y) + (z))

◆ DT_M_LN2f

#define DT_M_LN2f   (0.6931471805599453f)

◆ DT_M_PI

#define DT_M_PI   (3.14159265358979324)

◆ DT_M_PI_F

#define DT_M_PI_F   (3.14159265358979324f)

◆ INVPHI

#define INVPHI   0.61803398874989479F

◆ LCLIP

#define LCLIP (   x)    ((x < 0) ? 0.0 : (x > 100.0) ? 100.0 : x)

◆ M_LN10

#define M_LN10   2.30258509299404568402

ln(10)

◆ M_PI

#define M_PI   3.14159265358979323846

PI

◆ M_PI_F

#define M_PI_F   3.14159265358979324f

◆ MM_CLIP_PS

#define MM_CLIP_PS (   X)    (_mm_min_ps(_mm_max_ps((X), _mm_setzero_ps()), _mm_set1_ps(1.0)))

◆ NORM_MIN

#define NORM_MIN   1.52587890625e-05f

◆ PHI

#define PHI   1.61803398874989479F

Function Documentation

◆ ceil_fast()

static float ceil_fast ( float  x)
inlinestatic

Compute ceil value of a float

Remarks
Avoid libc ceil for now. Maybe we'll revert to libc later.
Parameters
xValue to ceil
Returns
ceil value

Referenced by _compute_downsampling_kernel(), and _prepare_resampling_plan().

◆ clamp_range_f()

static float clamp_range_f ( const float  x,
const float  low,
const float  high 
)
inlinestatic

◆ downscale_vector()

static void downscale_vector ( dt_aligned_pixel_t  vector,
const float  scaling 
)
inlinestatic

◆ dt_fast_expf()

static float dt_fast_expf ( const float  x)
inlinestatic

◆ dt_fast_expf_4wide()

static void dt_fast_expf_4wide ( const float  x[4],
float  result[4] 
)
inlinestatic

References float_int::f, and float_int::k.

Referenced by heat_PDE_diffusion().

◆ dt_fast_hypotf()

static float dt_fast_hypotf ( const float  x,
const float  y 
)
inlinestatic

◆ dt_fast_mexp2f()

static float dt_fast_mexp2f ( const float  x)
inlinestatic

References float_int::f.

Referenced by gh().

◆ dt_log2f()

static float dt_log2f ( const float  f)
inlinestatic

◆ dt_vector_sin()

static void dt_vector_sin ( const dt_aligned_pixel_t  arg,
dt_aligned_pixel_t  sine 
)
inlinestatic

Compute approximate sines, four at a time. This function behaves correctly for the range [-pi pi] only. It has the following properties:

  • It has exact values for 0, pi/2, pi, -pi/2, -pi
  • It has matching derivatives to sine for these same points
  • Its relative error margin is <= 1% iirc
  • It computational cost is 5 mults + 3 adds + 2 abs
Parameters
argRadian parameters
Returns
sine: guess what

References for_four_channels, and M_PI_F.

Referenced by _maketaps_lanczos().

◆ euclidean_norm()

static float euclidean_norm ( const dt_aligned_pixel_t  vector)
inlinestatic

References NORM_MIN, and sqf().

Referenced by _extract_patches(), and luma_chroma().

◆ fast_mexp2f()

static float fast_mexp2f ( const float  x)
inlinestatic

References f().

Referenced by dn_weight().

◆ fastlog()

static float fastlog ( float  x)
inlinestatic

References DT_M_LN2f, and fastlog2().

Referenced by kernel().

◆ fastlog2()

static float fastlog2 ( float  x)
inlinestatic

References f().

Referenced by fastlog(), and process().

◆ ipow()

static int ipow ( int  base,
int  exp 
)
inlinestatic

Fast integer power, computing base^exp.

Parameters
base
exp
Returns
int

Referenced by _bh_round_to_n_digits(), _bh_slider_get_min_step(), _slider_add_step(), and dt_bauhaus_slider_set_normalized().

◆ Kahan_sum()

static float Kahan_sum ( const float  m,
float *const __restrict__  c,
const float  add 
)
inlinestatic

References m.

Referenced by blur_vertical_1wide_Kahan().

◆ Log2()

static float Log2 ( float  x)
inlinestatic

◆ Log2Thres()

static float Log2Thres ( float  x,
float  Thres 
)
inlinestatic

◆ mat3mul()

static void mat3mul ( float *const __restrict__  dest,
const float *const __restrict__  m1,
const float *const __restrict__  m2 
)
inlinestatic

◆ mat3mulv()

static void mat3mulv ( float *const __restrict__  dest,
const float *const  mat,
const float *const __restrict__  v 
)
inlinestatic

◆ mul_mat_vec_2()

static void mul_mat_vec_2 ( const float *  m,
const float *  p,
float *  o 
)
inlinestatic

References m.

Referenced by backtransform(), backtransform(), transform(), and transform().

◆ scalar_product()

static float scalar_product ( const dt_aligned_pixel_t  v_1,
const dt_aligned_pixel_t  v_2 
)
inlinestatic

◆ sinf_fast()

static float sinf_fast ( float  t)
inlinestatic

Compute an approximate sine. This function behaves correctly for the range [-pi pi] only. It has the following properties:

  • It has exact values for 0, pi/2, pi, -pi/2, -pi
  • It has matching derivatives to sine for these same points
  • Its relative error margin is <= 1% iirc
  • It computational cost is 5 mults + 3 adds + 2 abs
Parameters
tRadian parameter
Returns
guess what

References M_PI, and M_PI_F.

◆ sqf()

◆ upscale_vector()

static void upscale_vector ( dt_aligned_pixel_t  vector,
const float  scaling 
)
inlinestatic