Source
double zbx_forecast(double *t, double *x, int n, double now, double time, zbx_fit_t fit, unsigned k, zbx_mode_t mode)
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
typedef struct
{
int rows;
int columns;
double *elements;
}
zbx_matrix_t;
static void zbx_matrix_struct_alloc(zbx_matrix_t **pm)
{
*pm = (zbx_matrix_t *)zbx_malloc(*pm, sizeof(zbx_matrix_t));
(*pm)->rows = 0;
(*pm)->columns = 0;
(*pm)->elements = NULL;
}
static int zbx_matrix_alloc(zbx_matrix_t *m, int rows, int columns)
{
if (0 >= rows || 0 >= columns)
goto error;
m->rows = rows;
m->columns = columns;
m->elements = (double *)zbx_malloc(m->elements, sizeof(double) * rows * columns);
return SUCCEED;
error:
THIS_SHOULD_NEVER_HAPPEN;
return FAIL;
}
static void zbx_matrix_free(zbx_matrix_t *m)
{
if (NULL != m)
zbx_free(m->elements);