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