libvisual  0.5.0
Macros | Functions
VisMath

Macros

#define VISUAL_MATH_PI   3.141592653589793238462643383279502884197169399f
 

Functions

int visual_math_is_power_of_2 (int n)
 Checks if the given value is a power of 2. More...
 
unsigned int visual_math_round_power_of_2 (unsigned int n)
 Rounds up to the next highest power of 2. More...
 
void visual_math_simd_mul_floats_float (float *LV_RESTRICT dest, const float *LV_RESTRICT src, float k, visual_size_t count)
 Multiplies an array of floats with a constant multiplicand, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_add_floats_float (float *LV_RESTRICT dest, const float *LV_RESTRICT src, float k, visual_size_t count)
 Adds an array of floats with a constant addend, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_mul_floats_floats (float *LV_RESTRICT dest, const float *LV_RESTRICT src1, const float *LV_RESTRICT src2, visual_size_t count)
 
void visual_math_simd_floats_to_int32s (int32_t *LV_RESTRICT ints, const float *LV_RESTRICT flts, visual_size_t count)
 Converts an array of floats to 32-bit integers, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_int32s_to_floats (float *LV_RESTRICT flts, const int32_t *LV_RESTRICT ints, visual_size_t count)
 Converts an array of integers to floats, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_floats_to_int32s_mul_float (int32_t *LV_RESTRICT ints, const float *LV_RESTRICT flts, float k, visual_size_t count)
 Converts an array of floats to integers and multiplies it with a const multiplicand, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_int32s_to_floats_mul_float (float *LV_RESTRICT flts, const int32_t *LV_RESTRICT ints, float k, visual_size_t count)
 Converts an array of integers to floats and multiplies it with a const multiplier. More...
 
void visual_math_simd_denorm_floats_to_int32s (int32_t *LV_RESTRICT ints, const float *LV_RESTRICT flts, float k, visual_size_t count)
 Denormalizes an array of floats, each in [0.0, 1.0], to integers, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_denorm_neg_floats_to_int32s (int32_t *LV_RESTRICT ints, const float *LV_RESTRICT flts, float k, visual_size_t count)
 Denormalizes an array of floats, each in [-1.0, 1.0], to integers, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_sqrt_floats (float *LV_RESTRICT dest, const float *LV_RESTRICT src, visual_size_t count)
 Calculates the square root of each float element in the input array, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_complex_norm (float *LV_RESTRICT dest, const float *LV_RESTRICT real, const float *LV_RESTRICT imag, visual_size_t count)
 Calculates the norm of a list of complex numbers, using SIMD instructions on supported CPUs. More...
 
void visual_math_simd_complex_scaled_norm (float *LV_RESTRICT dest, const float *LV_RESTRICT real, const float *LV_RESTRICT imag, float k, visual_size_t count)
 Calculates the scaled norm of a list of complex numbers, using SIMD instructions on supported CPUs. More...
 

Detailed Description

Function Documentation

int visual_math_is_power_of_2 ( int  n)

Checks if the given value is a power of 2.

Parameters
nValue to be checked if it's being a power of 2.
Returns
TRUE if power of 2, FALSE if not.

Definition at line 30 of file lv_math.c.

unsigned int visual_math_round_power_of_2 ( unsigned int  n)

Rounds up to the next highest power of 2.

Parameters
nValue to round up
Returns
Next highest power of 2

Definition at line 35 of file lv_math.c.

void visual_math_simd_add_floats_float ( float *LV_RESTRICT  dest,
const float *LV_RESTRICT  src,
float  k,
visual_size_t  count 
)

Adds an array of floats with a constant addend, using SIMD instructions on supported CPUs.

Note
Destination and source may be the same.
Parameters
destpointer to the destination float array
srcpointer to the source float array
kconstant addend
countnumber of elements

Definition at line 56 of file lv_math.c.

void visual_math_simd_complex_norm ( float *LV_RESTRICT  dest,
const float *LV_RESTRICT  real,
const float *LV_RESTRICT  imag,
visual_size_t  count 
)

Calculates the norm of a list of complex numbers, using SIMD instructions on supported CPUs.

The real and imaginary parts are given in two separate arrays.

Parameters
destarray to hold the results in
realarray of real parts
imagarray of imaginary parts
countnumber of elements

Definition at line 101 of file lv_math.c.

void visual_math_simd_complex_scaled_norm ( float *LV_RESTRICT  dest,
const float *LV_RESTRICT  real,
const float *LV_RESTRICT  imag,
float  k,
visual_size_t  count 
)

Calculates the scaled norm of a list of complex numbers, using SIMD instructions on supported CPUs.

The real and imaginary parts are given in two separate arrays.

Parameters
destarray to hold the results in
realarray of real parts
imagarray of imaginary parts
kconst multiplcand
countnumber of elements

Definition at line 106 of file lv_math.c.

Referenced by LV::DFT::perform().

void visual_math_simd_denorm_floats_to_int32s ( int32_t *LV_RESTRICT  ints,
const float *LV_RESTRICT  flts,
float  k,
visual_size_t  count 
)

Denormalizes an array of floats, each in [0.0, 1.0], to integers, using SIMD instructions on supported CPUs.

Each float value is first clamped to [0.0, 1.0], and then scaled to [0.0, k]

Parameters
intspointer to the destination int32_t array.
fltspointer to the source float array.
kconstant multiplicand
countnumber of elements

Definition at line 86 of file lv_math.c.

Referenced by LV::Rect::denormalize_points().

void visual_math_simd_denorm_neg_floats_to_int32s ( int32_t *LV_RESTRICT  ints,
const float *LV_RESTRICT  flts,
float  k,
visual_size_t  count 
)

Denormalizes an array of floats, each in [-1.0, 1.0], to integers, using SIMD instructions on supported CPUs.

Each float value is first clamped to [-1.0, 1.0], and then scaled to [0.0, k].

See Also
visual_math_simd_denorm_floats_to_int32()
Parameters
intspointer to the destination int32_t array.
fltspointer to the source float array.
kconstant multiplicand
countnumber of elements

Definition at line 91 of file lv_math.c.

Referenced by LV::Rect::denormalize_points_neg().

void visual_math_simd_floats_to_int32s ( int32_t *LV_RESTRICT  ints,
const float *LV_RESTRICT  flts,
visual_size_t  count 
)

Converts an array of floats to 32-bit integers, using SIMD instructions on supported CPUs.

Parameters
intspointer to the destination int32_t array
fltspointer to the source float array
countnumber of elements

Definition at line 66 of file lv_math.c.

void visual_math_simd_floats_to_int32s_mul_float ( int32_t *LV_RESTRICT  ints,
const float *LV_RESTRICT  flts,
float  k,
visual_size_t  count 
)

Converts an array of floats to integers and multiplies it with a const multiplicand, using SIMD instructions on supported CPUs.

Parameters
intspointer to the destination int32_t array
fltspointer to the source float array
kconstant multiplicand
countnumber of elements

Definition at line 76 of file lv_math.c.

void visual_math_simd_int32s_to_floats ( float *LV_RESTRICT  flts,
const int32_t *LV_RESTRICT  ints,
visual_size_t  count 
)

Converts an array of integers to floats, using SIMD instructions on supported CPUs.

Parameters
fltspointer to the destination float array
intspointer to the source int32_t array
countnumber of elements

Definition at line 71 of file lv_math.c.

void visual_math_simd_int32s_to_floats_mul_float ( float *LV_RESTRICT  flts,
const int32_t *LV_RESTRICT  ints,
float  k,
visual_size_t  count 
)

Converts an array of integers to floats and multiplies it with a const multiplier.

Parameters
fltspointer to the destination float array.
intspointer to the source int32_t array.
kconstant multiplicand
countnumber of elements

Definition at line 81 of file lv_math.c.

void visual_math_simd_mul_floats_float ( float *LV_RESTRICT  dest,
const float *LV_RESTRICT  src,
float  k,
visual_size_t  count 
)

Multiplies an array of floats with a constant multiplicand, using SIMD instructions on supported CPUs.

Note
Destination and source maty be the same.
Parameters
destpointer to the destination float array
srcpointer to the source float array
kconstant multiplicand
countnumber of elements

Definition at line 51 of file lv_math.c.

void visual_math_simd_sqrt_floats ( float *LV_RESTRICT  dest,
const float *LV_RESTRICT  src,
visual_size_t  count 
)

Calculates the square root of each float element in the input array, using SIMD instructions on supported CPUs.

Note
This function works best with data sizes larger than 16 or equal to 16.
Parameters
destarray to hold the results in
srcarray of floats
countnumber of elements

Definition at line 96 of file lv_math.c.