double zbx_forecast(double *t, double *x, int n, double now, double time, zbx_fit_t fit, unsigned k, zbx_mode_t mode)
#define ZBX_MATH_EPSILON (1e-6)
#define ZBX_IS_NAN(x) ((x) != (x))
#define ZBX_VALID_MATRIX(m) (0 < (m)->rows && 0 < (m)->columns && NULL != (m)->elements)
#define ZBX_MATRIX_EL(m, row, col) ((m)->elements[(row) * (m)->columns + (col)])
#define ZBX_MATRIX_ROW(m, row) ((m)->elements + (row) * (m)->columns)
static void zbx_matrix_struct_alloc(zbx_matrix_t **pm)
*pm = (zbx_matrix_t *)zbx_malloc(*pm, sizeof(zbx_matrix_t));
static int zbx_matrix_alloc(zbx_matrix_t *m, int rows, int columns)
if (0 >= rows || 0 >= columns)
m->elements = (double *)zbx_malloc(m->elements, sizeof(double) * rows * columns);
THIS_SHOULD_NEVER_HAPPEN;
static void zbx_matrix_free(zbx_matrix_t *m)
static int zbx_matrix_copy(zbx_matrix_t *dest, zbx_matrix_t *src)
if (!ZBX_VALID_MATRIX(src))
if (SUCCEED != zbx_matrix_alloc(dest, src->rows, src->columns))
memcpy(dest->elements, src->elements, sizeof(double) * src->rows * src->columns);
THIS_SHOULD_NEVER_HAPPEN;
static int zbx_identity_matrix(zbx_matrix_t *m, int n)
if (SUCCEED != zbx_matrix_alloc(m, n, n))
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
ZBX_MATRIX_EL(m, i, j) = (i == j ? 1.0 : 0.0);