WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

Mathematics and Statistics

Data Structures

struct  pj_math_stat
 

Macros

#define PJ_PI   3.14159265358979323846 /* pi */
 
#define PJ_1_PI   0.318309886183790671538 /* 1/pi */
 
#define PJ_ABS(x)   ((x) > 0 ? (x) : -(x))
 
#define PJ_MAX(x, y)   ((x) > (y)? (x) : (y))
 
#define PJ_MIN(x, y)   ((x) < (y)? (x) : (y))
 

Functions

unsigned pj_isqrt (unsigned i)
 
void pj_math_stat_init (pj_math_stat *stat)
 
void pj_math_stat_update (pj_math_stat *stat, int val)
 
unsigned pj_math_stat_get_stddev (const pj_math_stat *stat)
 
void pj_math_stat_set_stddev (pj_math_stat *stat, unsigned dev)
 

Detailed Description

Provides common mathematics constants and operations, and also standard statistics calculation (min, max, mean, standard deviation). Statistics calculation is done in realtime (statistics state is updated on time each new sample comes).

Macro Definition Documentation

◆ PJ_1_PI

#define PJ_1_PI   0.318309886183790671538 /* 1/pi */

1/pi

◆ PJ_ABS

#define PJ_ABS (   x)    ((x) > 0 ? (x) : -(x))

Mathematical macros Get the absolute value

◆ PJ_MAX

#define PJ_MAX (   x,
 
)    ((x) > (y)? (x) : (y))

Get the maximum of two values

◆ PJ_MIN

#define PJ_MIN (   x,
 
)    ((x) < (y)? (x) : (y))

Get the minimum of two values

◆ PJ_PI

#define PJ_PI   3.14159265358979323846 /* pi */

Mathematical constants pi

Function Documentation

◆ pj_isqrt()

unsigned pj_isqrt ( unsigned  i)

Calculate integer square root of an integer.

Parameters
iInteger to be calculated.
Returns
Square root result.

Referenced by pj_math_stat_get_stddev().

◆ pj_math_stat_get_stddev()

unsigned pj_math_stat_get_stddev ( const pj_math_stat stat)

Get the standard deviation of specified statistics state.

Parameters
statStatistic state.
Returns
The standard deviation.

References pj_math_stat::m2_, pj_math_stat::n, and pj_isqrt().

◆ pj_math_stat_init()

void pj_math_stat_init ( pj_math_stat stat)

Initialize statistics state.

Parameters
statStatistic state.

References pj_bzero().

◆ pj_math_stat_set_stddev()

void pj_math_stat_set_stddev ( pj_math_stat stat,
unsigned  dev 
)

Set the standard deviation of statistics state. This is useful when the statistic state is operated in 'read-only' mode as a storage of statistical data.

Parameters
statStatistic state.
devThe standard deviation.

References pj_math_stat::m2_, and pj_math_stat::n.

◆ pj_math_stat_update()

void pj_math_stat_update ( pj_math_stat stat,
int  val 
)

Update statistics state as a new sample comes.

Parameters
statStatistic state.
valThe new sample data.

References pj_math_stat::last, pj_math_stat::m2_, pj_math_stat::max, pj_math_stat::mean, pj_math_stat::mean_res_, pj_math_stat::min, and pj_math_stat::n.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.