"Fossies" - the Fresh Open Source Software Archive

Member "gretl-2020e/lib/src/gretl_utils.h" (28 Sep 2020, 5453 Bytes) of package /linux/misc/gretl-2020e.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gretl_utils.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2020d_vs_2020e.

    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 GRETL_UTILS_H
   21 #define GRETL_UTILS_H
   22 
   23 #include "libgretl.h"
   24 
   25 #include <float.h>
   26 #include <limits.h>
   27 
   28 #define floateq(x, y)  (fabs((x) - (y)) < DBL_EPSILON)
   29 #define floatneq(x, y) (fabs((x) - (y)) > DBL_EPSILON)
   30 #define floatgt(x, y)  ((x) - (y) > DBL_EPSILON)
   31 #define floatlt(x, y)  ((y) - (x) > DBL_EPSILON)
   32 
   33 #define ok_int(x) (x <= (double) INT_MAX && x >= (double) INT_MIN)
   34 
   35 enum {
   36     SESSION_CLEAR_ALL,
   37     SESSION_CLEAR_DATASET
   38 };
   39 
   40 enum {
   41     BLAS_UNKNOWN,
   42     BLAS_NETLIB,
   43     BLAS_ATLAS,
   44     BLAS_OPENBLAS,
   45     BLAS_MKL,
   46     BLAS_VECLIB
   47 };
   48 
   49 void libgretl_init (void);
   50 
   51 #ifdef HAVE_MPI
   52 int libgretl_mpi_init (int self, int np, int dcmt);
   53 #else
   54 /* dummy function */
   55 int gretl_mpi_initialized (void);
   56 #endif
   57 
   58 int blas_is_openblas (void);
   59 
   60 void blas_set_num_threads (int nt);
   61 
   62 int blas_get_num_threads (void);
   63 
   64 int auto_mpi_ok (void);
   65 
   66 void libgretl_session_cleanup (int mode);
   67 
   68 void libgretl_cleanup (void);
   69 
   70 double date_as_double (int t, int pd, double sd0);
   71 
   72 /* checks on variables */
   73 
   74 int gretl_isdummy (int t1, int t2, const double *x);
   75 
   76 int gretl_iszero (int t1, int t2, const double *x);
   77 
   78 int gretl_isconst (int t1, int t2, const double *x);
   79 
   80 int gretl_isstoch (int t1, int t2, const double *x);
   81 
   82 int gretl_isunits (int t1, int t2, const double *x);
   83 
   84 int gretl_iscount (int t1, int t2, const double *x);
   85 
   86 int gretl_isdiscrete (int t1, int t2, const double *x);
   87 
   88 int gretl_ispositive (int t1, int t2, const double *x, int strict);
   89 
   90 int gretl_is_oprobit_ok (int t1, int t2, const double *x);
   91 
   92 int true_const (int v, const DATASET *dset);
   93 
   94 /* setting observations */
   95 
   96 char *format_obs (char *obs, int maj, int min, int pd);
   97 
   98 int set_obs (const char *parm1, const char *parm2,
   99          DATASET *dset, gretlopt opt);
  100 
  101 int simple_set_obs (DATASET *dset, int pd, const char *stobs, 
  102             gretlopt opt);
  103 
  104 /* sorting and comparison */
  105 
  106 int gretl_compare_doubles (const void *a, const void *b);
  107 
  108 int gretl_inverse_compare_doubles (const void *a, const void *b);
  109 
  110 int count_distinct_values (const double *x, int n);
  111 
  112 int count_distinct_int_values (const int *x, int n);
  113 
  114 int rearrange_id_array (double *x, int m, int n);
  115 
  116 int gretl_compare_ints (const void *a, const void *b);
  117 
  118 /* miscellaneous */
  119 
  120 int gretl_version_number (const char *version);
  121 
  122 char *gretl_version_string (char *targ, int vnum);
  123 
  124 void printlist (const int *list, const char *msg);
  125 
  126 double gretl_double_from_string (const char *s, int *err);
  127 
  128 int gretl_int_from_string (const char *s, int *err);
  129 
  130 int positive_int_from_string (const char *s);
  131 
  132 int varnum_from_string (const char *str, DATASET *dset);
  133 
  134 int gretl_int_from_double (double x, int *err);
  135 
  136 GretlType gretl_type_from_name (const char *s, const DATASET *dset);
  137 
  138 double *copyvec (const double *src, int n);
  139 
  140 void doubles_array_free (double **X, int m);
  141 
  142 double **doubles_array_new (int m, int n);
  143 
  144 double **doubles_array_new0 (int m, int n);
  145 
  146 int doubles_array_adjust_length (double **X, int m, int new_n);
  147 
  148 double **data_array_from_model (const MODEL *pmod, double **Z, 
  149                 int missv);
  150 
  151 int ijton (int i, int j, int nrows);
  152 
  153 int transcribe_array (double *targ, const double *src, 
  154               const DATASET *dset); 
  155 
  156 int gretl_copy_file (const char *src, const char *dest);
  157 
  158 int gretl_delete_var_by_name (const char *s, PRN *prn);
  159 
  160 #ifndef WIN32
  161 int gretl_spawn (char *cmdline);
  162 #endif
  163 
  164 /* model selection criteria */
  165 
  166 int gretl_calculate_criteria (double ess, int n, int k,
  167                   double *ll, double *aic, double *bic, 
  168                   double *hqc);
  169 
  170 int ls_criteria (MODEL *pmod);
  171 
  172 /* hypothesis tests mechanism */
  173 
  174 int get_last_test_type (void);
  175 
  176 void record_test_result (double teststat, double pval);
  177 
  178 void record_matrix_test_result (gretl_matrix *tests, 
  179                 gretl_matrix *pvals);
  180 
  181 void record_LR_test_result (double teststat, double pval, double lnl);
  182 
  183 void record_QLR_test_result (double teststat, double pval, double brk);
  184 
  185 double get_last_test_statistic (void);
  186 
  187 double get_last_pvalue (void);
  188 
  189 double get_last_lnl (void);
  190 
  191 double get_last_break (void);
  192 
  193 gretl_matrix *get_last_test_matrix (int *err);
  194 
  195 gretl_matrix *get_last_pvals_matrix (int *err);
  196 
  197 /* timer */
  198 
  199 double gretl_stopwatch (void);
  200 
  201 #if 0 /* see comments in gretl_utils.c */
  202 
  203 /* aligned allocation */
  204 
  205 void *gretl_aligned_malloc (size_t size, size_t alignment);
  206 
  207 void gretl_aligned_free (void *mem);
  208 
  209 #endif
  210 
  211 /* search in path, etc. */
  212 
  213 int check_for_program (const char *prog);
  214 
  215 const char *blas_variant_string (void);
  216 
  217 int get_openblas_details (char **s1, char **s2);
  218 
  219 gint64 gretl_monotonic_time (void);
  220 
  221 /* gzip, gunzip */
  222 
  223 int gretl_gzip (char *fname, char *zname);
  224 
  225 int gretl_gunzip (char *zname, char *fname);
  226 
  227 #endif /* GRETL_UTILS_H */