1 #ifndef GNUMERIC_ANALYSIS_TOOLS_H
2 #define GNUMERIC_ANALYSIS_TOOLS_H
7 #include <tools/tools.h>
8 #include <regression.h>
12 /*******************************************************************/
13 /* Section 1: Undoable tools and their data structures */
16 analysis_tools_noerr
= 0,
17 analysis_tools_reported_err
,
18 analysis_tools_reported_err_input
,
19 analysis_tools_missing_data
,
20 analysis_tools_too_few_cols
,
21 analysis_tools_too_few_rows
,
22 analysis_tools_replication_invalid
,
23 analysis_tools_no_records_found
,
24 analysis_tools_invalid_field
25 } analysis_tools_error_code_t
;
28 /********************************************************************/
29 /* Section 2: Undoable Tools using the first common generic data struct */
32 analysis_tools_error_code_t err
;
37 } analysis_tools_data_generic_t
;
39 /**************** Correlation Tool ***************/
41 gboolean
analysis_tool_correlation_engine (GOCmdContext
*gcc
,
42 data_analysis_output_t
*dao
,
44 analysis_tool_engine_t selector
,
48 /**************** Covariance Tool ***************/
50 gboolean
analysis_tool_covariance_engine (GOCmdContext
*gcc
,
51 data_analysis_output_t
*dao
,
53 analysis_tool_engine_t selector
,
57 /********************************************************************/
58 /* Section 3: Undoable Tools using the first common generic */
59 /* data struct augmented with some simple fields */
61 /************** Single Factor ANOVA *************/
64 analysis_tools_data_generic_t base
;
66 } analysis_tools_data_anova_single_t
;
68 gboolean
analysis_tool_anova_single_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
69 analysis_tool_engine_t selector
, gpointer result
);
71 /********** Descriptive Statistics Tool **********/
74 analysis_tools_data_generic_t base
;
75 gboolean summary_statistics
;
76 gboolean confidence_level
;
78 gboolean kth_smallest
;
79 gboolean use_ssmedian
;
83 } analysis_tools_data_descriptive_t
;
85 gboolean
analysis_tool_descriptive_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
86 analysis_tool_engine_t selector
, gpointer result
);
89 /************** Moving Averages **** *************/
92 moving_average_type_sma
= 0,
93 moving_average_type_cma
,
94 moving_average_type_wma
,
95 moving_average_type_spencer_ma
,
96 moving_average_type_central_sma
97 } moving_average_type_t
;
100 analysis_tools_data_generic_t base
;
106 moving_average_type_t ma_type
;
107 } analysis_tools_data_moving_average_t
;
109 gboolean
analysis_tool_moving_average_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
110 analysis_tool_engine_t selector
, gpointer result
);
113 /************** Fourier Analysis **** *************/
116 analysis_tools_data_generic_t base
;
118 } analysis_tools_data_fourier_t
;
120 gboolean
analysis_tool_fourier_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
121 analysis_tool_engine_t selector
, gpointer result
);
124 /************** Sampling Tool **********************/
127 analysis_tools_data_generic_t base
;
134 } analysis_tools_data_sampling_t
;
136 gboolean
analysis_tool_sampling_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
137 analysis_tool_engine_t selector
, gpointer result
);
140 /************** Ranking Tool *************************/
143 analysis_tools_data_generic_t base
;
145 } analysis_tools_data_ranking_t
;
147 gboolean
analysis_tool_ranking_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
148 analysis_tool_engine_t selector
, gpointer result
);
153 /********************************************************************/
154 /* Section 4: Undoable Tools using the second common generic */
155 /* data struct augmented with some simple fields */
157 /*********************** FTest ************************/
160 analysis_tools_error_code_t err
;
161 WorkbookControl
*wbc
;
166 } analysis_tools_data_generic_b_t
;
168 gboolean
analysis_tool_ftest_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
169 analysis_tool_engine_t selector
, gpointer result
);
171 /**************** Regression ********************/
174 analysis_tools_data_generic_b_t base
;
177 gboolean multiple_regression
;
181 } analysis_tools_data_regression_t
;
183 gboolean
analysis_tool_regression_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
184 analysis_tool_engine_t selector
, gpointer result
);
185 /*********************** TTest paired *****************/
188 analysis_tools_data_generic_b_t base
;
192 } analysis_tools_data_ttests_t
;
194 gboolean
analysis_tool_ttest_paired_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
195 analysis_tool_engine_t selector
, gpointer result
);
198 /*********************** TTest equal variances *********/
200 gboolean
analysis_tool_ttest_eqvar_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
201 analysis_tool_engine_t selector
, gpointer result
);
204 /*********************** TTest unequal variances *******/
206 gboolean
analysis_tool_ttest_neqvar_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
207 analysis_tool_engine_t selector
, gpointer result
);
210 /*********************** ZTest ************************/
212 gboolean
analysis_tool_ztest_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
213 analysis_tool_engine_t selector
, gpointer result
);
215 /**************** Advanced Filter ********************/
218 analysis_tools_data_generic_b_t base
;
219 gboolean unique_only_flag
;
220 } analysis_tools_data_advanced_filter_t
;
222 gboolean
analysis_tool_advanced_filter_engine (GOCmdContext
*gcc
, data_analysis_output_t
*dao
, gpointer specs
,
223 analysis_tool_engine_t selector
, gpointer result
);
228 /********************************************************************/
229 /* Section 5 Functions also needed elsewhere. */
231 gboolean
analysis_tool_generic_clean (gpointer specs
);
232 gboolean
analysis_tool_generic_b_clean (gpointer specs
);
234 int analysis_tool_calc_length (analysis_tools_data_generic_t
*info
);
236 void analysis_tools_write_label (GnmValue
*val
, /* depreceated */
237 data_analysis_output_t
*dao
,
238 analysis_tools_data_generic_t
*info
,
239 int x
, int y
, int i
);
240 void analysis_tools_write_label_ftest (GnmValue
*val
, /* depreceated */
241 data_analysis_output_t
*dao
,
243 gboolean labels
, int i
);
245 gboolean
analysis_tool_table (data_analysis_output_t
*dao
,
246 analysis_tools_data_generic_t
*info
,
247 gchar
const *title
, gchar
const *functionname
,
248 gboolean full_table
);
250 void prepare_input_range (GSList
**input_range
, group_by_t group_by
);
252 const GnmExpr
*make_cellref (int dx
, int dy
);
253 const GnmExpr
*make_rangeref (int dx0
, int dy0
, int dx1
, int dy1
);
255 gnm_float
*range_sort (gnm_float
const *xs
, int n
);
257 void set_cell_text_row (data_analysis_output_t
*dao
,
258 int col
, int row
, const char *text
);
259 void set_cell_text_col (data_analysis_output_t
*dao
,
260 int col
, int row
, const char *text
);
262 GnmFunc
*analysis_tool_get_function (char const *name
,
263 data_analysis_output_t
*dao
);