diff options
author | Luca Deri <deri@ntop.org> | 2023-04-08 09:52:14 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2023-04-08 09:52:14 +0200 |
commit | c47e9d201d57acf9e4946e47cd63aac3b506ce7c (patch) | |
tree | ce444f11676e03ae45c6400bff896bb33a6aabe2 /src/lib/ndpi_analyze.c | |
parent | 7714507f816b36055ca25c67b6228637bd600cf9 (diff) |
Implemented ndpi_XXX_reset() API calls whre XXX is ses, des, hw
Diffstat (limited to 'src/lib/ndpi_analyze.c')
-rw-r--r-- | src/lib/ndpi_analyze.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 5eb2c1bea..178097b9f 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -1206,6 +1206,17 @@ int ndpi_hw_add_value(struct ndpi_hw_struct *hw, const u_int64_t _value, double } } +/* *********************************************************** */ + +void ndpi_hw_reset(struct ndpi_hw_struct *hw) { + hw->prev_error.sum_square_error = 0, hw->prev_error.num_values_rollup = 0; + hw->num_values = 0; + hw->u = hw->v = hw->sum_square_error = 0; + + memset(&hw->y, 0, (hw->params.num_season_periods * sizeof(u_int64_t))); + memset(&hw->s, 0, (hw->params.num_season_periods * sizeof(double))); +} + /* ********************************************************************************* */ /* ********************************************************************************* */ @@ -1348,6 +1359,14 @@ int ndpi_ses_add_value(struct ndpi_ses_struct *ses, const double _value, double /* *********************************************************** */ +void ndpi_ses_reset(struct ndpi_ses_struct *ses) { + ses->prev_error.sum_square_error = 0, ses->prev_error.num_values_rollup = 0; + ses->num_values = 0; + ses->sum_square_error = ses->last_forecast = ses->last_value = 0; +} + +/* *********************************************************** */ + /* Computes the best alpha value using the specified values used for training */ @@ -1430,6 +1449,14 @@ int ndpi_des_init(struct ndpi_des_struct *des, double alpha, double beta, float /* *********************************************************** */ +void ndpi_des_reset(struct ndpi_des_struct *des) { + des->prev_error.sum_square_error = 0, des->prev_error.num_values_rollup = 0; + des->num_values = 0; + des->sum_square_error = des->last_forecast = des->last_trend = des->last_value = 0; +} + +/* *********************************************************** */ + /* Returns the forecast and the band (forecast +/- band are the upper and lower values) |