1 #ifndef EXPRESSIONS_HELPERS_H
2 #define EXPRESSIONS_HELPERS_H
6 #include <gsl/gsl_cdf.h>
7 #include <gsl/gsl_randist.h>
8 #include <gsl/gsl_sf.h>
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/dictionary.h"
18 #include "data/procedure.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"
33 #define _(msgid) gettext (msgid)
35 static inline double check_errno (double x)
37 return errno == 0 ? x : SYSMIS;
40 #define check_errno(EXPRESSION) (errno = 0, check_errno (EXPRESSION))
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. */
50 extern const struct substring empty_string;
52 int compare_string_3way (const struct substring *, const struct substring *);
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);
64 struct substring alloc_string (struct expression *, size_t length);
65 struct substring copy_string (struct expression *,
66 const char *, size_t length);
71 return isfinite (d) && d != SYSMIS;
74 size_t count_valid (double *, size_t);
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);
80 double cdf_bvnor (double x0, double x1, double r);
82 double idf_fdist (double P, double a, double b);
84 #endif /* expressions/helpers.h */