1 #ifndef EXPRESSIONS_HELPERS_H
2 #define EXPRESSIONS_HELPERS_H
6 #include <gsl/gsl_cdf.h>
7 #include <gsl/gsl_math.h>
8 #include <gsl/gsl_randist.h>
9 #include <gsl/gsl_sf.h>
14 #include <data/calendar.h>
15 #include <data/case.h>
16 #include <data/data-in.h>
17 #include <data/data-out.h>
18 #include <data/dictionary.h>
19 #include <data/procedure.h>
20 #include <data/settings.h>
21 #include <data/value.h>
22 #include <data/variable.h>
23 #include <data/vector.h>
24 #include <gsl-extras/gsl-extras.h>
25 #include <language/expressions/public.h>
26 #include <libpspp/compiler.h>
27 #include <libpspp/message.h>
28 #include <libpspp/misc.h>
29 #include <libpspp/str.h>
30 #include <math/moments.h>
31 #include <math/random.h>
34 #define _(msgid) gettext (msgid)
36 static inline double check_errno (double x)
38 return errno == 0 ? x : SYSMIS;
41 #define check_errno(EXPRESSION) (errno = 0, check_errno (EXPRESSION))
43 #define DAY_S (60. * 60. * 24.) /* Seconds per day. */
44 #define DAY_H 24. /* Hours per day. */
45 #define H_S (60 * 60.) /* Seconds per hour. */
46 #define H_MIN 60. /* Minutes per hour. */
47 #define MIN_S 60. /* Seconds per minute. */
48 #define WEEK_DAY 7. /* Days per week. */
49 #define WEEK_S (WEEK_DAY * DAY_S) /* Seconds per week. */
51 extern const struct substring empty_string;
53 int compare_string (const struct substring *, const struct substring *);
55 double expr_ymd_to_date (double year, double month, double day);
56 double expr_ymd_to_ofs (double year, double month, double day);
57 double expr_wkyr_to_date (double wk, double yr);
58 double expr_yrday_to_date (double yr, double day);
59 double expr_yrmoda (double year, double month, double day);
60 double expr_date_difference (double date1, double date2,
61 struct substring unit);
62 double expr_date_sum (double date, double quantity, struct substring unit_name,
63 struct substring method_name);
65 struct substring alloc_string (struct expression *, size_t length);
66 struct substring copy_string (struct expression *,
67 const char *, size_t length);
72 return gsl_finite (d) && d != SYSMIS;
75 size_t count_valid (double *, size_t);
77 double idf_beta (double P, double a, double b);
78 double ncdf_beta (double x, double a, double b, double lambda);
79 double npdf_beta (double x, double a, double b, double lambda);
81 double cdf_bvnor (double x0, double x1, double r);
83 double idf_fdist (double P, double a, double b);
85 #endif /* expressions/helpers.h */