Continue reforming procedure execution. In this phase, remove PROCESS
[pspp-builds.git] / src / language / expressions / helpers.h
1 #ifndef EXPRESSIONS_HELPERS_H 
2 #define EXPRESSIONS_HELPERS_H
3
4 #include <ctype.h>
5 #include <float.h>
6 #include <gsl/gsl_cdf.h>
7 #include <gsl/gsl_randist.h>
8 #include <gsl/gsl_sf.h>
9 #include <limits.h>
10 #include <math.h>
11 #include <stdbool.h>
12
13 #include <data/calendar.h>
14 #include <data/case.h>
15 #include <data/data-in.h>
16 #include <data/dictionary.h>
17 #include <data/procedure.h>
18 #include <data/settings.h>
19 #include <data/value.h>
20 #include <data/variable.h>
21 #include <gsl-extras/gsl-extras.h>
22 #include <language/expressions/public.h>
23 #include <libpspp/compiler.h>
24 #include <libpspp/message.h>
25 #include <libpspp/misc.h>
26 #include <libpspp/str.h>
27 #include <math/moments.h>
28 #include <math/random.h>
29
30 #include "gettext.h"
31 #define _(msgid) gettext (msgid)
32
33 static inline double check_errno (double x) 
34 {
35   return errno == 0 ? x : SYSMIS;
36 }
37
38 #define check_errno(EXPRESSION) (errno = 0, check_errno (EXPRESSION))
39
40 #define DAY_S (60. * 60. * 24.)         /* Seconds per day. */
41 #define DAY_H 24.                       /* Hours per day. */
42 #define H_S (60 * 60.)                  /* Seconds per hour. */
43 #define H_MIN 60.                       /* Minutes per hour. */
44 #define MIN_S 60.                       /* Seconds per minute. */
45 #define WEEK_DAY 7.                     /* Days per week. */
46
47 extern const struct fixed_string empty_string;
48
49 int compare_string (const struct fixed_string *, const struct fixed_string *);
50
51 double expr_ymd_to_date (double year, double month, double day);
52 double expr_ymd_to_ofs (double year, double month, double day);
53 double expr_wkyr_to_date (double wk, double yr);
54 double expr_yrday_to_date (double yr, double day);
55 double expr_yrmoda (double year, double month, double day);
56
57 struct fixed_string alloc_string (struct expression *, size_t length);
58 struct fixed_string copy_string (struct expression *,
59                                  const char *, size_t length);
60
61 static inline bool
62 is_valid (double d) 
63 {
64   return finite (d) && d != SYSMIS;
65 }
66
67 size_t count_valid (double *, size_t);
68
69 double idf_beta (double P, double a, double b);
70 double ncdf_beta (double x, double a, double b, double lambda);
71 double npdf_beta (double x, double a, double b, double lambda);
72
73 double cdf_bvnor (double x0, double x1, double r);
74
75 double idf_fdist (double P, double a, double b);
76
77 #endif /* expressions/helpers.h */