PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
math_fixed.h File Reference
#include <inttypes.h>
#include <stdbool.h>
#include <pbl/kernel/compiler.h>

Data Structures

union  Fixed_S16_3
 Fixed-point number with 1 sign bit, 12 integer bits and 3 fraction bits. More...
 
union  Fixed_S32_16
 Fixed-point number with 1 sign bit, 15 integer bits and 16 fraction bits. More...
 
union  Fixed_S64_32
 Fixed-point number with 1 sign bit, 31 integer bits and 32 fraction bits. More...
 
struct  Fixed_S16_3.__unnamed102__
 
struct  Fixed_S32_16.__unnamed104__
 
struct  Fixed_S64_32.__unnamed106__
 

Macros

#define Fixed_S16_3(raw)   ((Fixed_S16_3){.raw_value = (raw)})
 Make a Fixed_S16_3 from its raw value.
 
#define FIXED_S16_3_PRECISION   3
 Number of fraction bits of Fixed_S16_3.
 
#define FIXED_S16_3_FACTOR   (1 << FIXED_S16_3_PRECISION)
 Scale factor of Fixed_S16_3.
 
#define FIXED_S16_3_ZERO   ((Fixed_S16_3){.integer = 0, .fraction = 0})
 Fixed_S16_3 zero.
 
#define FIXED_S16_3_ONE   ((Fixed_S16_3){.integer = 1, .fraction = 0})
 Fixed_S16_3 one.
 
#define FIXED_S16_3_HALF   ((Fixed_S16_3){.raw_value = FIXED_S16_3_ONE.raw_value / 2})
 Fixed_S16_3 one half.
 
#define Fixed_S32_16(raw)   ((Fixed_S32_16){.raw_value = (raw)})
 Make a Fixed_S32_16 from its raw value.
 
#define FIXED_S32_16_PRECISION   16
 Number of fraction bits of Fixed_S32_16.
 
#define FIXED_S32_16_ONE   ((Fixed_S32_16){.integer = 1, .fraction = 0})
 Fixed_S32_16 one.
 
#define FIXED_S32_16_ZERO   ((Fixed_S32_16){.integer = 0, .fraction = 0})
 Fixed_S32_16 zero.
 
#define FIXED_S64_32_PRECISION   32
 Number of fraction bits of Fixed_S64_32.
 
#define FIXED_S64_32_ONE   ((Fixed_S64_32){.integer = 1, .fraction = 0})
 Fixed_S64_32 one.
 
#define FIXED_S64_32_ZERO   ((Fixed_S64_32){.integer = 0, .fraction = 0})
 Fixed_S64_32 zero.
 
#define FIXED_S64_32_FROM_RAW(raw)   ((Fixed_S64_32){.raw_value = (raw)})
 Make a Fixed_S64_32 from its raw value.
 
#define FIXED_S64_32_FROM_INT(x)   ((Fixed_S64_32){.integer = x, .fraction = 0})
 Make a Fixed_S64_32 from an integer.
 
#define FIXED_S64_32_TO_INT(x)   (x.integer)
 Get the integer part of a Fixed_S64_32, rounded towards negative infinity.
 

Typedefs

typedef Fixed_S32_16 Fixed_S32_16Return
 Alias of Fixed_S32_16 for function return types.
 

Functions

static __inline__ Fixed_S16_3 Fixed_S16_3_mul (Fixed_S16_3 a, Fixed_S16_3 b)
 Multiply two Fixed_S16_3 values.
 
static __inline__ Fixed_S16_3 Fixed_S16_3_add (Fixed_S16_3 a, Fixed_S16_3 b)
 Add two Fixed_S16_3 values.
 
static __inline__ Fixed_S16_3 Fixed_S16_3_sub (Fixed_S16_3 a, Fixed_S16_3 b)
 Subtract two Fixed_S16_3 values.
 
static __inline__ Fixed_S16_3 Fixed_S16_3_add3 (Fixed_S16_3 a, Fixed_S16_3 b, Fixed_S16_3 c)
 Add three Fixed_S16_3 values.
 
static __inline__ bool Fixed_S16_3_equal (Fixed_S16_3 a, Fixed_S16_3 b)
 Compare two Fixed_S16_3 values.
 
static __inline__ int16_t Fixed_S16_3_rounded_int (Fixed_S16_3 a)
 Round a Fixed_S16_3 value to the nearest integer, halves away from zero.
 
static __inline__ Fixed_S32_16 Fixed_S32_16_mul (Fixed_S32_16 a, Fixed_S32_16 b)
 Multiply two Fixed_S32_16 values.
 
static __inline__ Fixed_S32_16 Fixed_S32_16_add (Fixed_S32_16 a, Fixed_S32_16 b)
 Add two Fixed_S32_16 values.
 
static __inline__ Fixed_S32_16 Fixed_S32_16_add3 (Fixed_S32_16 a, Fixed_S32_16 b, Fixed_S32_16 c)
 Add three Fixed_S32_16 values.
 
static __inline__ Fixed_S32_16 Fixed_S32_16_sub (Fixed_S32_16 a, Fixed_S32_16 b)
 Subtract two Fixed_S32_16 values.
 
static __inline__ Fixed_S64_32 Fixed_S64_32_mul (Fixed_S64_32 a, Fixed_S64_32 b)
 Multiply two Fixed_S64_32 values.
 
static __inline__ Fixed_S64_32 Fixed_S64_32_add (Fixed_S64_32 a, Fixed_S64_32 b)
 Add two Fixed_S64_32 values.
 
static __inline__ Fixed_S64_32 Fixed_S64_32_add3 (Fixed_S64_32 a, Fixed_S64_32 b, Fixed_S64_32 c)
 Add three Fixed_S64_32 values.
 
static __inline__ Fixed_S64_32 Fixed_S64_32_sub (Fixed_S64_32 a, Fixed_S64_32 b)
 Subtract two Fixed_S64_32 values.
 
static __inline__ Fixed_S16_3 Fixed_S16_3_S32_16_mul (Fixed_S16_3 a, Fixed_S32_16 b)
 Multiply a Fixed_S16_3 by a Fixed_S32_16.
 
Fixed_S64_32 math_fixed_recursive_filter (Fixed_S64_32 x, int num_input_coefficients, int num_output_coefficients, const Fixed_S64_32 *cb, const Fixed_S64_32 *ca, Fixed_S64_32 *state_x, Fixed_S64_32 *state_y)
 Run a value through an Nth order linear recursive (IIR) filter.