Added configure option to disable building rrd_graph: --disable-rrd_graph. With suppo...
[rrdtool.git] / src / rrd_hw_math.h
1 /*****************************************************************************
2  * rrd_hw_math.h  Math functions for Holt-Winters computations
3  *****************************************************************************/
4
5 #include "rrd.h"
6 #include "rrd_format.h"
7
8 /* since /usr/include/bits/mathcalls.h:265 defines gamma already */
9 #define gamma hw_gamma
10
11 /*****************************************************************************
12  * Functions for additive Holt-Winters
13  *****************************************************************************/
14
15 rrd_value_t hw_additive_calculate_prediction(
16     rrd_value_t intercept,
17     rrd_value_t slope,
18     int null_count,
19     rrd_value_t seasonal_coef);
20
21 rrd_value_t hw_additive_calculate_intercept(
22     rrd_value_t alpha,
23     rrd_value_t scratch,
24     rrd_value_t seasonal_coef,
25     unival *coefs);
26
27 rrd_value_t hw_additive_calculate_seasonality(
28     rrd_value_t gamma,
29     rrd_value_t scratch,
30     rrd_value_t intercept,
31     rrd_value_t seasonal_coef);
32
33 rrd_value_t hw_additive_init_seasonality(
34     rrd_value_t seasonal_coef,
35     rrd_value_t intercept);
36
37 /*****************************************************************************
38  * Functions for multiplicative Holt-Winters
39  *****************************************************************************/
40
41 rrd_value_t hw_multiplicative_calculate_prediction(
42     rrd_value_t intercept,
43     rrd_value_t slope,
44     int null_count,
45     rrd_value_t seasonal_coef);
46
47 rrd_value_t hw_multiplicative_calculate_intercept(
48     rrd_value_t alpha,
49     rrd_value_t scratch,
50     rrd_value_t seasonal_coef,
51     unival *coefs);
52
53 rrd_value_t hw_multiplicative_calculate_seasonality(
54     rrd_value_t gamma,
55     rrd_value_t scratch,
56     rrd_value_t intercept,
57     rrd_value_t seasonal_coef);
58
59 rrd_value_t hw_multiplicative_init_seasonality(
60     rrd_value_t seasonal_coef,
61     rrd_value_t intercept);
62
63 /*****************************************************************************
64  * Math functions common to additive and multiplicative Holt-Winters
65  *****************************************************************************/
66
67 rrd_value_t hw_calculate_slope(
68     rrd_value_t beta,
69     unival *coefs);
70
71 rrd_value_t hw_calculate_seasonal_deviation(
72     rrd_value_t gamma,
73     rrd_value_t prediction,
74     rrd_value_t observed,
75     rrd_value_t last);
76
77 rrd_value_t hw_init_seasonal_deviation(
78     rrd_value_t prediction,
79     rrd_value_t observed);
80
81
82 /* Function container */
83
84 typedef struct hw_functions_t {
85     rrd_value_t (
86     *predict) (
87     rrd_value_t intercept,
88     rrd_value_t slope,
89     int null_count,
90     rrd_value_t seasonal_coef);
91
92     rrd_value_t (
93     *intercept) (
94     rrd_value_t alpha,
95     rrd_value_t observed,
96     rrd_value_t seasonal_coef,
97     unival *coefs);
98
99     rrd_value_t (
100     *slope)   (
101     rrd_value_t beta,
102     unival *coefs);
103
104     rrd_value_t (
105     *seasonality) (
106     rrd_value_t gamma,
107     rrd_value_t observed,
108     rrd_value_t intercept,
109     rrd_value_t seasonal_coef);
110
111     rrd_value_t (
112     *init_seasonality) (
113     rrd_value_t seasonal_coef,
114     rrd_value_t intercept);
115
116     rrd_value_t (
117     *seasonal_deviation) (
118     rrd_value_t gamma,
119     rrd_value_t prediction,
120     rrd_value_t observed,
121     rrd_value_t last);
122
123     rrd_value_t (
124     *init_seasonal_deviation) (
125     rrd_value_t prediction,
126     rrd_value_t observed);
127
128     rrd_value_t identity;
129 } hw_functions_t;
130
131
132 #undef gamma