Rename procedure.[ch] to dataset.[ch].
[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/data-out.h"
17 #include "data/dataset.h"
18 #include "data/dictionary.h"
19 #include "data/settings.h"
20 #include "data/value.h"
21 #include "data/variable.h"
22 #include "data/vector.h"
23 #include "language/expressions/public.h"
24 #include "libpspp/compiler.h"
25 #include "libpspp/i18n.h"
26 #include "libpspp/message.h"
27 #include "libpspp/misc.h"
28 #include "libpspp/str.h"
29 #include "math/moments.h"
30 #include "math/random.h"
31
32 #include "gettext.h"
33 #define _(msgid) gettext (msgid)
34
35 static inline double check_errno (double x)
36 {
37   return errno == 0 ? x : SYSMIS;
38 }
39
40 #define check_errno(EXPRESSION) (errno = 0, check_errno (EXPRESSION))
41
42 #define DAY_S (60. * 60. * 24.)         /* Seconds per day. */
43 #define DAY_H 24.                       /* Hours per day. */
44 #define H_S (60 * 60.)                  /* Seconds per hour. */
45 #define H_MIN 60.                       /* Minutes per hour. */
46 #define MIN_S 60.                       /* Seconds per minute. */
47 #define WEEK_DAY 7.                     /* Days per week. */
48 #define WEEK_S (WEEK_DAY * DAY_S)       /* Seconds per week. */
49
50 extern const struct substring empty_string;
51
52 int compare_string_3way (const struct substring *, const struct substring *);
53
54 double expr_ymd_to_date (double year, double month, double day);
55 double expr_ymd_to_ofs (double year, double month, double day);
56 double expr_wkyr_to_date (double wk, double yr);
57 double expr_yrday_to_date (double yr, double day);
58 double expr_yrmoda (double year, double month, double day);
59 double expr_date_difference (double date1, double date2,
60                              struct substring unit);
61 double expr_date_sum (double date, double quantity, struct substring unit_name,
62                       struct substring method_name);
63
64 struct substring alloc_string (struct expression *, size_t length);
65 struct substring copy_string (struct expression *,
66                               const char *, size_t length);
67
68 static inline bool
69 is_valid (double d)
70 {
71   return isfinite (d) && d != SYSMIS;
72 }
73
74 size_t count_valid (double *, size_t);
75
76 double idf_beta (double P, double a, double b);
77 double ncdf_beta (double x, double a, double b, double lambda);
78 double npdf_beta (double x, double a, double b, double lambda);
79
80 double cdf_bvnor (double x0, double x1, double r);
81
82 double idf_fdist (double P, double a, double b);
83
84 #endif /* expressions/helpers.h */