1 /*
2  *  gretl -- Gnu Regression, Econometrics and Time-series Library
3  *  Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef LIBSET_H
21 #define LIBSET_H
22 
23 typedef enum {
24     NORM_PHILLIPS,
25     NORM_DIAG,
26     NORM_FIRST,
27     NORM_NONE,
28     NORM_MAX
29 } VECMnorm;
30 
31 typedef enum {
32     OPTIM_AUTO,
33     OPTIM_BFGS,
34     OPTIM_NEWTON,
35     OPTIM_MAX
36 } OptimCode;
37 
38 typedef enum {
39     USE_CWD         = 1 << 0,  /* store: use current dir as default */
40     ECHO_ON         = 1 << 1,  /* echoing commands or not */
41     MSGS_ON         = 1 << 2,  /* emitting non-error messages or not */
42     FORCE_DECPOINT  = 1 << 3,  /* override locale decimal character */
43     USE_PCSE        = 1 << 4,  /* Beck-Katz panel-corrected std errs */
44     USE_SVD         = 1 << 5,  /* SVD decomposition is matrix OLS default */
45     USE_QR          = 1 << 6,  /* QR decomp is least-squares command default */
46     PREWHITEN       = 1 << 7,  /* HAC pre-whitening? */
47     FORCE_HC        = 1 << 8,  /* don't use HAC for time series */
48     USE_LBFGS       = 1 << 9,  /* prefer LBFGS to BFGS? */
49     SHELL_OK        = 1 << 10, /* "shell" facility is approved? */
50     WARNINGS        = 1 << 11, /* print numerical warning messages */
51     SKIP_MISSING    = 1 << 12, /* skip NAs when building matrix from series */
52     BFGS_RSTEP      = 1 << 13, /* use Richardson in BFGS numerical gradient */
53     ROBUST_Z        = 1 << 14, /* use z- not t-score with HCCM/HAC */
54     MWRITE_G        = 1 << 15, /* use %g format with mwrite() */
55     MPI_USE_SMT     = 1 << 16, /* MPI: use hyperthreads by default */
56     STATE_FLAG_MAX  = 1 << 17, /* separator */
57     /* state small int (but non-boolean) vars */
58     GRETL_OPTIM,
59     VECM_NORM,
60     GARCH_VCV,
61     GARCH_ALT_VCV,
62     ARMA_VCV,
63     WILDBOOT_DIST,
64     FDJAC_QUAL,
65     MAX_VERBOSE,
66     HC_VERSION,
67     HAC_KERNEL,
68     HAC_LAG,
69     USER_HAC_LAG,
70     LBFGS_MEM,
71     QUANTILE_TYPE,
72     STATE_SMALL_INT_MAX, /* separator: start state int vars */
73     HORIZON,
74     BOOTREP,
75     LOOP_MAXITER,
76     BFGS_MAXITER,
77     BFGS_VERBSKIP,
78     BOOT_ITERS,
79     BHHH_MAXITER,
80     RQ_MAXITER,
81     GMM_MAXITER,
82     STATE_INT_MAX, /* separator: end state int vars */
83     CONV_HUGE,
84     NLS_TOLER,
85     BFGS_TOLER,
86     BFGS_MAXGRAD,
87     BHHH_TOLER,
88     QS_BANDWIDTH,
89     NADARWAT_TRIM,
90     STATE_FLOAT_MAX, /* separator: end state floats */
91     CSV_WRITE_NA,
92     CSV_READ_NA,
93     INITVALS,
94     INITCURV,
95     MATMASK,
96     STATE_VARS_MAX, /* separator */
97     /* non-state vars follow */
98     GRETL_DEBUG,
99     GRETL_ASSERT,
100     DATACOLS,
101     PLOT_COLLECT,
102     R_FUNCTIONS,
103     R_LIB,
104     LOGLEVEL,
105     LOGSTAMP,
106     CSV_DIGITS,
107     NS_SMALL_INT_MAX, /* separator */
108     GMP_BITS,
109     NS_MAX, /* separator */
110     BLAS_MNK_MIN,
111     OMP_MNK_MIN,
112     OMP_N_THREADS,
113     SIMD_K_MAX,
114     SIMD_MN_MIN,
115     USE_DCMT,
116     NS_INT_MAX, /* separator */
117     SEED,
118     CSV_DELIM,
119     STOPWATCH,
120     VERBOSE,
121     SV_WORKDIR,
122     SV_LOGFILE,
123     GRAPH_THEME,
124     DISP_DIGITS,
125     SETVAR_MAX /* sentinel */
126 } SetKey;
127 
128 typedef void (*SHOW_ACTIVITY_FUNC) (void);
129 typedef int (*DEBUG_READLINE) (void *);
130 typedef int (*DEBUG_OUTPUT) (void *);
131 typedef int (*QUERY_STOP) (void);
132 
133 #define set_nls_toler(x) (libset_set_double(NLS_TOLER, x))
134 
135 int libset_init (void);
136 void libset_cleanup (void);
137 
138 int push_program_state (void);
139 int pop_program_state (void);
140 
141 int libset_get_bool (SetKey key);
142 int libset_set_bool (SetKey key, int val);
143 
144 double libset_get_double (SetKey key);
145 int libset_set_double (SetKey key, double val);
146 
147 double libset_get_user_tolerance (SetKey key);
148 
149 int libset_get_int (SetKey key);
150 int libset_set_int (SetKey key, int val);
151 
152 int is_libset_var (const char *s);
153 
154 /* GUI setter functions */
155 void set_xsect_hccme (const char *s);
156 void set_tseries_hccme (const char *s);
157 void set_panel_hccme (const char *s);
158 void set_garch_alt_vcv (const char *s);
159 
160 int get_hac_lag (int T);
161 int data_based_hac_bandwidth (void);
162 
163 int get_bkbp_k (const DATASET *dset);
164 void get_bkbp_periods (const DATASET *dset, int *l, int *u);
165 
166 /* convenience accessor */
167 int get_mp_bits (void);
168 
169 gretl_matrix *get_initvals (void);
170 int n_initvals (void);
171 
172 gretl_matrix *get_initcurv (void);
173 int n_initcurv (void);
174 
175 const gretl_matrix *get_matrix_mask (void);
176 int get_matrix_mask_nobs (void);
177 void destroy_matrix_mask (void);
178 
179 void set_loop_on (void);
180 void set_loop_off (void);
181 
182 int gretl_looping (void);
183 int gretl_looping_currently (void);
184 
185 void gretl_iteration_push (void);
186 void gretl_iteration_pop (void);
187 int gretl_iteration_depth (void);
188 
189 void gretl_set_batch_mode (int b);
190 int gretl_in_batch_mode (void);
191 
192 void gretl_set_gui_mode (void);
193 int gretl_in_gui_mode (void);
194 
195 void gretl_set_tool_mode (void);
196 int gretl_in_tool_mode (void);
197 
198 void set_gretl_echo (int e);
199 int gretl_echo_on (void);
200 
201 void set_gretl_messages (int e);
202 int gretl_messages_on (void);
203 
204 int gretl_comments_on (void);
205 
206 int gretl_warnings_on (void);
207 int gretl_debugging_on (void);
208 
209 void set_data_export_decimal_comma (int s);
210 char get_data_export_decpoint (void);
211 
212 void set_data_export_delimiter (char c);
213 char get_data_export_delimiter (void);
214 
215 const char *get_csv_na_write_string (void);
216 int set_csv_na_write_string (const char *s);
217 
218 const char *get_csv_na_read_string (void);
219 int set_csv_na_read_string (const char *s);
220 
221 int execute_set (const char *setobj, const char *setarg,
222 		 DATASET *dset, gretlopt opt, PRN *prn);
223 
224 void set_show_activity_func (SHOW_ACTIVITY_FUNC func);
225 void show_activity_callback (void);
226 int show_activity_func_installed (void);
227 
228 void set_debug_read_func (DEBUG_READLINE dfunc);
229 DEBUG_READLINE get_debug_read_func (void);
230 
231 void set_debug_output_func (DEBUG_OUTPUT dout);
232 DEBUG_OUTPUT get_debug_output_func (void);
233 
234 void set_query_stop_func (QUERY_STOP query);
235 int check_for_stop (void);
236 
237 void set_workdir_callback (int (*callback)());
238 
239 int libset_write_script (const char *fname);
240 int libset_read_script (const char *fname);
241 
242 #endif /* LIBSET_H */
243