Group pj_math

group pj_math

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).

Defines

PJ_PI

Mathematical constants

PJ_1_PI
PJ_ABS(x)

Mathematical macro

PJ_MAX(x, y)
PJ_MIN(x, y)

Functions

unsigned pj_isqrt(unsigned i)

Calculate integer square root of an integer.

Return

Square root result.

Parameters
  • i: Integer to be calculated.

void pj_math_stat_init(pj_math_stat *stat)

Initialize statistics state.

Parameters
  • stat: Statistic state.

void pj_math_stat_update(pj_math_stat *stat, int val)

Update statistics state as a new sample comes.

Parameters
  • stat: Statistic state.

  • val: The new sample data.

unsigned pj_math_stat_get_stddev(const pj_math_stat *stat)

Get the standard deviation of specified statistics state.

Return

The standard deviation.

Parameters
  • stat: Statistic state.

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
  • stat: Statistic state.

  • dev: The standard deviation.

struct pj_math_stat
#include <math.h>

This structure describes statistics state.