Loading...
Searching...
No Matches
imath: Integer Math functions

This modules provides some integer-only math functions. More...

Detailed Description

This modules provides some integer-only math functions.

They can be used when no FPU is available or no exact precision is needed.

Author
Karl Fessel karl..nosp@m.fess.nosp@m.el@ov.nosp@m.gu.d.nosp@m.e

Macros

#define SINI_PERIOD   0x8000
 Period of the fast_sini() function.
 
#define SINI_MAX   0x1000
 Max value of the fast_sini() function.
 
#define SINI_MIN   -0x1000
 Min value of the fast_sini() function.
 

Functions

static int32_t _ihelp (int32_t x)
 Internal fast_sini/fast_cosi helper function.
 
static int32_t fast_sini (int32_t x)
 A sine approximation via a fourth-order cosine approx.
 
static int32_t fast_cosi (int32_t x)
 A a fourth-order cosine approx.
 
static unsigned sqrti (unsigned x)
 Square root of an integer.
 
static uint32_t powi (unsigned x, unsigned y)
 Returns the value of x to the power of y.
 

Macro Definition Documentation

◆ SINI_MAX

#define SINI_MAX   0x1000

Max value of the fast_sini() function.

Definition at line 31 of file imath.h.

◆ SINI_MIN

#define SINI_MIN   -0x1000

Min value of the fast_sini() function.

Definition at line 32 of file imath.h.

◆ SINI_PERIOD

#define SINI_PERIOD   0x8000

Period of the fast_sini() function.

Definition at line 30 of file imath.h.

Function Documentation

◆ _ihelp()

static int32_t _ihelp ( int32_t  x)
inlinestatic

Internal fast_sini/fast_cosi helper function.

Definition at line 43 of file imath.h.

◆ fast_cosi()

static int32_t fast_cosi ( int32_t  x)
inlinestatic

A a fourth-order cosine approx.

source: https://www.coranac.com/2009/07/sines/

Parameters
xangle (with 2^15 units/circle)
Returns
sine value (-2^12 ≤ y ≤ 2^12)

Definition at line 86 of file imath.h.

◆ fast_sini()

static int32_t fast_sini ( int32_t  x)
inlinestatic

A sine approximation via a fourth-order cosine approx.

source: https://www.coranac.com/2009/07/sines/

Parameters
xangle (with 2^15 units/circle)
Returns
sine value (-2^12 ≤ y ≤ 2^12)

Definition at line 69 of file imath.h.

◆ powi()

static uint32_t powi ( unsigned  x,
unsigned  y 
)
inlinestatic

Returns the value of x to the power of y.

Parameters
xbase
yexponent
Returns
x^y

Definition at line 128 of file imath.h.

◆ sqrti()

static unsigned sqrti ( unsigned  x)
inlinestatic

Square root of an integer.

Parameters
xunsigned integer value
Returns
square root of x

Definition at line 102 of file imath.h.