number 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/bounds.c +116 -0
- data/ext/compare.c +706 -0
- data/ext/complex.c +674 -0
- data/ext/decompose.c +231 -0
- data/ext/extconf.rb +7 -0
- data/ext/interval.c +394 -0
- data/ext/number.c +1651 -0
- data/ext/number.h +92 -0
- data/ext/real.c +877 -0
- data/ext/real_bounds.c +57 -0
- data/ext/round.c +46 -0
- metadata +69 -0
data/ext/bounds.c
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
#include "number.h"
|
2
|
+
|
3
|
+
void bounds_free (Bounds* bounds)
|
4
|
+
{
|
5
|
+
if (bounds)
|
6
|
+
{
|
7
|
+
if (bounds->re_min)
|
8
|
+
{
|
9
|
+
mpfr_clear(bounds->re_min);
|
10
|
+
}
|
11
|
+
|
12
|
+
if (bounds->re_max)
|
13
|
+
{
|
14
|
+
mpfr_clear(bounds->re_max);
|
15
|
+
}
|
16
|
+
|
17
|
+
if (bounds->im_min)
|
18
|
+
{
|
19
|
+
mpfr_clear(bounds->im_min);
|
20
|
+
}
|
21
|
+
|
22
|
+
if (bounds->im_max)
|
23
|
+
{
|
24
|
+
mpfr_clear(bounds->im_max);
|
25
|
+
}
|
26
|
+
|
27
|
+
free(bounds);
|
28
|
+
bounds = NULL;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
// add flag for EXACT calculation of mpfr, e.g. mpc_abs returns 0
|
33
|
+
void bounds_update_re (Bounds* bounds, mpfr_t num, int re_closed)
|
34
|
+
{
|
35
|
+
int min_cmp;
|
36
|
+
int max_cmp;
|
37
|
+
|
38
|
+
min_cmp = mpfr_cmp(bounds->re_min, num);
|
39
|
+
max_cmp = mpfr_cmp(bounds->re_max, num);
|
40
|
+
|
41
|
+
if (min_cmp != -1)
|
42
|
+
{
|
43
|
+
mpfr_set(bounds->re_min, num, MPFR_RNDN);
|
44
|
+
bounds->re_min_closed = (min_cmp) ? re_closed : bounds->re_min_closed || re_closed;
|
45
|
+
}
|
46
|
+
|
47
|
+
if (max_cmp != 1)
|
48
|
+
{
|
49
|
+
mpfr_set(bounds->re_max, num, MPFR_RNDN);
|
50
|
+
bounds->re_max_closed = (max_cmp) ? re_closed : bounds->re_max_closed || re_closed;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
void bounds_update_im (Bounds* bounds, mpfr_t num, int im_closed)
|
55
|
+
{
|
56
|
+
int min_cmp;
|
57
|
+
int max_cmp;
|
58
|
+
|
59
|
+
min_cmp = mpfr_cmp(bounds->im_min, num);
|
60
|
+
max_cmp = mpfr_cmp(bounds->im_max, num);
|
61
|
+
|
62
|
+
if (min_cmp != -1)
|
63
|
+
{
|
64
|
+
mpfr_set(bounds->im_min, num, MPFR_RNDN);
|
65
|
+
bounds->im_min_closed = (min_cmp) ? im_closed : bounds->im_min_closed || im_closed;
|
66
|
+
}
|
67
|
+
|
68
|
+
if (max_cmp != 1)
|
69
|
+
{
|
70
|
+
mpfr_set(bounds->im_max, num, MPFR_RNDN);
|
71
|
+
bounds->im_max_closed = (max_cmp) ? im_closed : bounds->im_max_closed || im_closed;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
void bounds_update (Bounds* bounds, mpc_t num, int re_closed, int im_closed)
|
76
|
+
{
|
77
|
+
mpfr_t re;
|
78
|
+
mpfr_t im;
|
79
|
+
|
80
|
+
mpfr_init2(re, PREC);
|
81
|
+
mpfr_init2(im, PREC);
|
82
|
+
|
83
|
+
mpc_real(re, num, MPFR_RNDN);
|
84
|
+
mpc_imag(im, num, MPFR_RNDN);
|
85
|
+
|
86
|
+
bounds_update_re(bounds, re, re_closed);
|
87
|
+
bounds_update_im(bounds, im, im_closed);
|
88
|
+
|
89
|
+
mpfr_clear(re);
|
90
|
+
mpfr_clear(im);
|
91
|
+
}
|
92
|
+
|
93
|
+
Bounds* bounds_new ()
|
94
|
+
{
|
95
|
+
Bounds* bounds;
|
96
|
+
bounds = malloc(sizeof(Bounds));
|
97
|
+
|
98
|
+
if (bounds == NULL)
|
99
|
+
{
|
100
|
+
return NULL;
|
101
|
+
}
|
102
|
+
|
103
|
+
memset(bounds, 0, sizeof(Bounds));
|
104
|
+
|
105
|
+
mpfr_init2(bounds->re_min, PREC);
|
106
|
+
mpfr_init2(bounds->re_max, PREC);
|
107
|
+
mpfr_init2(bounds->im_min, PREC);
|
108
|
+
mpfr_init2(bounds->im_max, PREC);
|
109
|
+
|
110
|
+
mpfr_set_inf(bounds->re_min, 1);
|
111
|
+
mpfr_set_inf(bounds->re_max, -1);
|
112
|
+
mpfr_set_inf(bounds->im_min, 1);
|
113
|
+
mpfr_set_inf(bounds->im_max, -1);
|
114
|
+
|
115
|
+
return bounds;
|
116
|
+
}
|
data/ext/compare.c
ADDED
@@ -0,0 +1,706 @@
|
|
1
|
+
#include "number.h"
|
2
|
+
|
3
|
+
int complex_re_contain_p (Complex* a, Complex* b)
|
4
|
+
{
|
5
|
+
return interval_span_p(a->re, b->re->l) && interval_span_p(a->re, b->re->u);
|
6
|
+
}
|
7
|
+
|
8
|
+
int complex_re_contain_l_p (Complex* a, Complex* b)
|
9
|
+
{
|
10
|
+
return interval_span_p(a->re, b->re->l);
|
11
|
+
}
|
12
|
+
|
13
|
+
int complex_re_contain_n_p (Complex* a, Complex* b)
|
14
|
+
{
|
15
|
+
return interval_span_p(a->re, b->re->n);
|
16
|
+
}
|
17
|
+
|
18
|
+
int complex_re_contain_u_p (Complex* a, Complex* b)
|
19
|
+
{
|
20
|
+
return interval_span_p(a->re, b->re->u);
|
21
|
+
}
|
22
|
+
|
23
|
+
int complex_re_contain_zero_p (Complex* complex)
|
24
|
+
{
|
25
|
+
return interval_span_zero_p(complex->re);
|
26
|
+
}
|
27
|
+
|
28
|
+
int complex_re_intersect_p (Complex* a, Complex* b)
|
29
|
+
{
|
30
|
+
return interval_span_p(a->re, b->re->l) || interval_span_p(a->re, b->re->u) || interval_span_p(b->re, a->re->n);
|
31
|
+
}
|
32
|
+
|
33
|
+
int complex_re_disjoint_p (Complex* a, Complex* b)
|
34
|
+
{
|
35
|
+
return !complex_re_intersect_p(a, b);
|
36
|
+
}
|
37
|
+
|
38
|
+
int complex_re_unbounded_p (Complex* complex)
|
39
|
+
{
|
40
|
+
return NEG_INF(complex->re->l) && POS_INF(complex->re->u);
|
41
|
+
}
|
42
|
+
|
43
|
+
int complex_re_left_unbounded_p (Complex* complex)
|
44
|
+
{
|
45
|
+
return NEG_INF(complex->re->l);
|
46
|
+
}
|
47
|
+
|
48
|
+
int complex_re_right_unbounded_p (Complex* complex)
|
49
|
+
{
|
50
|
+
return POS_INF(complex->re->u);
|
51
|
+
}
|
52
|
+
|
53
|
+
int complex_re_nan_p (Complex* complex)
|
54
|
+
{
|
55
|
+
return NaN(complex->re->n);
|
56
|
+
}
|
57
|
+
|
58
|
+
int complex_re_pos_inf_p (Complex* complex)
|
59
|
+
{
|
60
|
+
return POS_INF(complex->re->n);
|
61
|
+
}
|
62
|
+
|
63
|
+
int complex_re_neg_inf_p (Complex* complex)
|
64
|
+
{
|
65
|
+
return POS_INF(complex->re->n);
|
66
|
+
}
|
67
|
+
|
68
|
+
int complex_re_normal_p (Complex* complex)
|
69
|
+
{
|
70
|
+
return REAL(complex->re->n);
|
71
|
+
}
|
72
|
+
|
73
|
+
int complex_re_zero_p (Complex* complex)
|
74
|
+
{
|
75
|
+
return ZERO(complex->re->n);
|
76
|
+
}
|
77
|
+
|
78
|
+
int complex_re_eq_p (Complex* a, Complex* b)
|
79
|
+
{
|
80
|
+
return real_eq_p(a->re->l, b->re->l) && real_eq_p(a->re->n, b->re->n) && real_eq_p(a->re->u, b->re->u) && (a->re->L == b->re->L) && (a->re->R == b->re->R);
|
81
|
+
}
|
82
|
+
|
83
|
+
int complex_re_bounds_eq_p (Complex* a, Complex* b)
|
84
|
+
{
|
85
|
+
return real_eq_p(a->re->l, b->re->l) && real_eq_p(a->re->u, b->re->u) && (a->re->L == b->re->L) && (a->re->R == b->re->R);
|
86
|
+
}
|
87
|
+
|
88
|
+
int complex_re_l_eq_l_p (Complex* a, Complex* b)
|
89
|
+
{
|
90
|
+
return real_eq_p(a->re->l, b->re->l);
|
91
|
+
}
|
92
|
+
|
93
|
+
int complex_re_l_eq_n_p (Complex* a, Complex* b)
|
94
|
+
{
|
95
|
+
return real_eq_p(a->re->l, b->re->n);
|
96
|
+
}
|
97
|
+
|
98
|
+
int complex_re_l_eq_u_p (Complex* a, Complex* b)
|
99
|
+
{
|
100
|
+
return real_eq_p(a->re->l, b->re->u);
|
101
|
+
}
|
102
|
+
|
103
|
+
int complex_re_n_eq_l_p (Complex* a, Complex* b)
|
104
|
+
{
|
105
|
+
return real_eq_p(a->re->n, b->re->l);
|
106
|
+
}
|
107
|
+
|
108
|
+
int complex_re_n_eq_n_p (Complex* a, Complex* b)
|
109
|
+
{
|
110
|
+
return real_eq_p(a->re->n, b->re->n);
|
111
|
+
}
|
112
|
+
|
113
|
+
int complex_re_n_eq_u_p (Complex* a, Complex* b)
|
114
|
+
{
|
115
|
+
return real_eq_p(a->re->n, b->re->u);
|
116
|
+
}
|
117
|
+
|
118
|
+
int complex_re_u_eq_l_p (Complex* a, Complex* b)
|
119
|
+
{
|
120
|
+
return real_eq_p(a->re->u, b->re->l);
|
121
|
+
}
|
122
|
+
|
123
|
+
int complex_re_u_eq_n_p (Complex* a, Complex* b)
|
124
|
+
{
|
125
|
+
return real_eq_p(a->re->u, b->re->n);
|
126
|
+
}
|
127
|
+
|
128
|
+
int complex_re_u_eq_u_p (Complex* a, Complex* b)
|
129
|
+
{
|
130
|
+
return real_eq_p(a->re->u, b->re->u);
|
131
|
+
}
|
132
|
+
|
133
|
+
int complex_re_l_gt_l_p (Complex* a, Complex* b)
|
134
|
+
{
|
135
|
+
return real_gt_p(a->re->l, b->re->l);
|
136
|
+
}
|
137
|
+
|
138
|
+
int complex_re_l_gt_n_p (Complex* a, Complex* b)
|
139
|
+
{
|
140
|
+
return real_gt_p(a->re->l, b->re->n);
|
141
|
+
}
|
142
|
+
|
143
|
+
int complex_re_l_gt_u_p (Complex* a, Complex* b)
|
144
|
+
{
|
145
|
+
return real_gt_p(a->re->l, b->re->u);
|
146
|
+
}
|
147
|
+
|
148
|
+
int complex_re_n_gt_l_p (Complex* a, Complex* b)
|
149
|
+
{
|
150
|
+
return real_gt_p(a->re->n, b->re->l);
|
151
|
+
}
|
152
|
+
|
153
|
+
int complex_re_n_gt_n_p (Complex* a, Complex* b)
|
154
|
+
{
|
155
|
+
return real_gt_p(a->re->n, b->re->n);
|
156
|
+
}
|
157
|
+
|
158
|
+
int complex_re_n_gt_u_p (Complex* a, Complex* b)
|
159
|
+
{
|
160
|
+
return real_gt_p(a->re->n, b->re->u);
|
161
|
+
}
|
162
|
+
|
163
|
+
int complex_re_u_gt_l_p (Complex* a, Complex* b)
|
164
|
+
{
|
165
|
+
return real_gt_p(a->re->u, b->re->l);
|
166
|
+
}
|
167
|
+
|
168
|
+
int complex_re_u_gt_n_p (Complex* a, Complex* b)
|
169
|
+
{
|
170
|
+
return real_gt_p(a->re->u, b->re->n);
|
171
|
+
}
|
172
|
+
|
173
|
+
int complex_re_u_gt_u_p (Complex* a, Complex* b)
|
174
|
+
{
|
175
|
+
return real_gt_p(a->re->u, b->re->u);
|
176
|
+
}
|
177
|
+
|
178
|
+
int complex_re_l_ge_l_p (Complex* a, Complex* b)
|
179
|
+
{
|
180
|
+
return real_ge_p(a->re->l, b->re->l);
|
181
|
+
}
|
182
|
+
|
183
|
+
int complex_re_l_ge_n_p (Complex* a, Complex* b)
|
184
|
+
{
|
185
|
+
return real_ge_p(a->re->l, b->re->n);
|
186
|
+
}
|
187
|
+
|
188
|
+
int complex_re_l_ge_u_p (Complex* a, Complex* b)
|
189
|
+
{
|
190
|
+
return real_ge_p(a->re->l, b->re->u);
|
191
|
+
}
|
192
|
+
|
193
|
+
int complex_re_n_ge_l_p (Complex* a, Complex* b)
|
194
|
+
{
|
195
|
+
return real_ge_p(a->re->n, b->re->l);
|
196
|
+
}
|
197
|
+
|
198
|
+
int complex_re_n_ge_n_p (Complex* a, Complex* b)
|
199
|
+
{
|
200
|
+
return real_ge_p(a->re->n, b->re->n);
|
201
|
+
}
|
202
|
+
|
203
|
+
int complex_re_n_ge_u_p (Complex* a, Complex* b)
|
204
|
+
{
|
205
|
+
return real_ge_p(a->re->n, b->re->u);
|
206
|
+
}
|
207
|
+
|
208
|
+
int complex_re_u_ge_l_p (Complex* a, Complex* b)
|
209
|
+
{
|
210
|
+
return real_ge_p(a->re->u, b->re->l);
|
211
|
+
}
|
212
|
+
|
213
|
+
int complex_re_u_ge_n_p (Complex* a, Complex* b)
|
214
|
+
{
|
215
|
+
return real_ge_p(a->re->u, b->re->n);
|
216
|
+
}
|
217
|
+
|
218
|
+
int complex_re_u_ge_u_p (Complex* a, Complex* b)
|
219
|
+
{
|
220
|
+
return real_ge_p(a->re->u, b->re->u);
|
221
|
+
}
|
222
|
+
|
223
|
+
int complex_re_l_lt_l_p (Complex* a, Complex* b)
|
224
|
+
{
|
225
|
+
return real_lt_p(a->re->l, b->re->l);
|
226
|
+
}
|
227
|
+
|
228
|
+
int complex_re_l_lt_n_p (Complex* a, Complex* b)
|
229
|
+
{
|
230
|
+
return real_lt_p(a->re->l, b->re->n);
|
231
|
+
}
|
232
|
+
|
233
|
+
int complex_re_l_lt_u_p (Complex* a, Complex* b)
|
234
|
+
{
|
235
|
+
return real_lt_p(a->re->l, b->re->u);
|
236
|
+
}
|
237
|
+
|
238
|
+
int complex_re_n_lt_l_p (Complex* a, Complex* b)
|
239
|
+
{
|
240
|
+
return real_lt_p(a->re->n, b->re->l);
|
241
|
+
}
|
242
|
+
|
243
|
+
int complex_re_n_lt_n_p (Complex* a, Complex* b)
|
244
|
+
{
|
245
|
+
return real_lt_p(a->re->n, b->re->n);
|
246
|
+
}
|
247
|
+
|
248
|
+
int complex_re_n_lt_u_p (Complex* a, Complex* b)
|
249
|
+
{
|
250
|
+
return real_lt_p(a->re->n, b->re->u);
|
251
|
+
}
|
252
|
+
|
253
|
+
int complex_re_u_lt_l_p (Complex* a, Complex* b)
|
254
|
+
{
|
255
|
+
return real_lt_p(a->re->u, b->re->l);
|
256
|
+
}
|
257
|
+
|
258
|
+
int complex_re_u_lt_n_p (Complex* a, Complex* b)
|
259
|
+
{
|
260
|
+
return real_lt_p(a->re->u, b->re->n);
|
261
|
+
}
|
262
|
+
|
263
|
+
int complex_re_u_lt_u_p (Complex* a, Complex* b)
|
264
|
+
{
|
265
|
+
return real_lt_p(a->re->u, b->re->u);
|
266
|
+
}
|
267
|
+
|
268
|
+
int complex_re_l_le_l_p (Complex* a, Complex* b)
|
269
|
+
{
|
270
|
+
return real_le_p(a->re->l, b->re->l);
|
271
|
+
}
|
272
|
+
|
273
|
+
int complex_re_l_le_n_p (Complex* a, Complex* b)
|
274
|
+
{
|
275
|
+
return real_le_p(a->re->l, b->re->n);
|
276
|
+
}
|
277
|
+
|
278
|
+
int complex_re_l_le_u_p (Complex* a, Complex* b)
|
279
|
+
{
|
280
|
+
return real_le_p(a->re->l, b->re->u);
|
281
|
+
}
|
282
|
+
|
283
|
+
int complex_re_n_le_l_p (Complex* a, Complex* b)
|
284
|
+
{
|
285
|
+
return real_le_p(a->re->n, b->re->l);
|
286
|
+
}
|
287
|
+
|
288
|
+
int complex_re_n_le_n_p (Complex* a, Complex* b)
|
289
|
+
{
|
290
|
+
return real_le_p(a->re->n, b->re->n);
|
291
|
+
}
|
292
|
+
|
293
|
+
int complex_re_n_le_u_p (Complex* a, Complex* b)
|
294
|
+
{
|
295
|
+
return real_le_p(a->re->n, b->re->u);
|
296
|
+
}
|
297
|
+
|
298
|
+
int complex_re_u_le_l_p (Complex* a, Complex* b)
|
299
|
+
{
|
300
|
+
return real_le_p(a->re->u, b->re->l);
|
301
|
+
}
|
302
|
+
|
303
|
+
int complex_re_u_le_n_p (Complex* a, Complex* b)
|
304
|
+
{
|
305
|
+
return real_le_p(a->re->u, b->re->n);
|
306
|
+
}
|
307
|
+
|
308
|
+
int complex_re_u_le_u_p (Complex* a, Complex* b)
|
309
|
+
{
|
310
|
+
return real_le_p(a->re->u, b->re->u);
|
311
|
+
}
|
312
|
+
|
313
|
+
int complex_im_unbounded_p (Complex* complex)
|
314
|
+
{
|
315
|
+
return NEG_INF(complex->im->l) && POS_INF(complex->im->u);
|
316
|
+
}
|
317
|
+
|
318
|
+
int complex_im_left_unbounded_p (Complex* complex)
|
319
|
+
{
|
320
|
+
return NEG_INF(complex->im->l);
|
321
|
+
}
|
322
|
+
|
323
|
+
int complex_im_right_unbounded_p (Complex* complex)
|
324
|
+
{
|
325
|
+
return POS_INF(complex->im->u);
|
326
|
+
}
|
327
|
+
|
328
|
+
int complex_im_nan_p (Complex* complex)
|
329
|
+
{
|
330
|
+
return NaN(complex->im->n);
|
331
|
+
}
|
332
|
+
|
333
|
+
int complex_im_pos_inf_p (Complex* complex)
|
334
|
+
{
|
335
|
+
return POS_INF(complex->im->n);
|
336
|
+
}
|
337
|
+
|
338
|
+
int complex_im_neg_inf_p (Complex* complex)
|
339
|
+
{
|
340
|
+
return POS_INF(complex->im->n);
|
341
|
+
}
|
342
|
+
|
343
|
+
int complex_im_normal_p (Complex* complex)
|
344
|
+
{
|
345
|
+
return REAL(complex->im->n);
|
346
|
+
}
|
347
|
+
|
348
|
+
int complex_im_zero_p (Complex* complex)
|
349
|
+
{
|
350
|
+
return ZERO(complex->im->n);
|
351
|
+
}
|
352
|
+
|
353
|
+
int complex_im_contain_zero_p (Complex* complex)
|
354
|
+
{
|
355
|
+
return interval_span_zero_p(complex->im);
|
356
|
+
}
|
357
|
+
|
358
|
+
int complex_im_contain_p (Complex* a, Complex* b)
|
359
|
+
{
|
360
|
+
return interval_span_p(a->im, b->im->l) && interval_span_p(a->im, b->im->u);
|
361
|
+
}
|
362
|
+
|
363
|
+
int complex_im_contain_l_p (Complex* a, Complex* b)
|
364
|
+
{
|
365
|
+
return interval_span_p(a->im, b->im->l);
|
366
|
+
}
|
367
|
+
|
368
|
+
int complex_im_contain_n_p (Complex* a, Complex* b)
|
369
|
+
{
|
370
|
+
return interval_span_p(a->im, b->im->n);
|
371
|
+
}
|
372
|
+
|
373
|
+
int complex_im_contain_u_p (Complex* a, Complex* b)
|
374
|
+
{
|
375
|
+
return interval_span_p(a->im, b->im->u);
|
376
|
+
}
|
377
|
+
|
378
|
+
int complex_im_intersect_p (Complex* a, Complex* b)
|
379
|
+
{
|
380
|
+
return interval_span_p(a->im, b->im->l) || interval_span_p(a->im, b->im->u) || interval_span_p(b->im, a->im->n);
|
381
|
+
}
|
382
|
+
|
383
|
+
int complex_im_disjoint_p (Complex* a, Complex* b)
|
384
|
+
{
|
385
|
+
return !complex_im_intersect_p(a, b);
|
386
|
+
}
|
387
|
+
|
388
|
+
int complex_im_eq_p (Complex* a, Complex* b)
|
389
|
+
{
|
390
|
+
return real_eq_p(a->im->l, b->im->l) && real_eq_p(a->im->n, b->im->n) && real_eq_p(a->im->u, b->im->u) && (a->im->L == b->im->L) && (a->im->R == b->im->R);
|
391
|
+
}
|
392
|
+
|
393
|
+
int complex_im_bounds_eq_p (Complex* a, Complex* b)
|
394
|
+
{
|
395
|
+
return real_eq_p(a->im->l, b->im->l) && real_eq_p(a->im->u, b->im->u) && (a->im->L == b->im->L) && (a->im->R == b->im->R);
|
396
|
+
}
|
397
|
+
|
398
|
+
int complex_im_l_eq_l_p (Complex* a, Complex* b)
|
399
|
+
{
|
400
|
+
return real_eq_p(a->im->l, b->im->l);
|
401
|
+
}
|
402
|
+
|
403
|
+
int complex_im_l_eq_n_p (Complex* a, Complex* b)
|
404
|
+
{
|
405
|
+
return real_eq_p(a->im->l, b->im->n);
|
406
|
+
}
|
407
|
+
|
408
|
+
int complex_im_l_eq_u_p (Complex* a, Complex* b)
|
409
|
+
{
|
410
|
+
return real_eq_p(a->im->l, b->im->u);
|
411
|
+
}
|
412
|
+
|
413
|
+
int complex_im_n_eq_l_p (Complex* a, Complex* b)
|
414
|
+
{
|
415
|
+
return real_eq_p(a->im->n, b->im->l);
|
416
|
+
}
|
417
|
+
|
418
|
+
int complex_im_n_eq_n_p (Complex* a, Complex* b)
|
419
|
+
{
|
420
|
+
return real_eq_p(a->im->n, b->im->n);
|
421
|
+
}
|
422
|
+
|
423
|
+
int complex_im_n_eq_u_p (Complex* a, Complex* b)
|
424
|
+
{
|
425
|
+
return real_eq_p(a->im->n, b->im->u);
|
426
|
+
}
|
427
|
+
|
428
|
+
int complex_im_u_eq_l_p (Complex* a, Complex* b)
|
429
|
+
{
|
430
|
+
return real_eq_p(a->im->u, b->im->l);
|
431
|
+
}
|
432
|
+
|
433
|
+
int complex_im_u_eq_n_p (Complex* a, Complex* b)
|
434
|
+
{
|
435
|
+
return real_eq_p(a->im->u, b->im->n);
|
436
|
+
}
|
437
|
+
|
438
|
+
int complex_im_u_eq_u_p (Complex* a, Complex* b)
|
439
|
+
{
|
440
|
+
return real_eq_p(a->im->u, b->im->u);
|
441
|
+
}
|
442
|
+
|
443
|
+
int complex_im_l_gt_l_p (Complex* a, Complex* b)
|
444
|
+
{
|
445
|
+
return real_gt_p(a->im->l, b->im->l);
|
446
|
+
}
|
447
|
+
|
448
|
+
int complex_im_l_gt_n_p (Complex* a, Complex* b)
|
449
|
+
{
|
450
|
+
return real_gt_p(a->im->l, b->im->n);
|
451
|
+
}
|
452
|
+
|
453
|
+
int complex_im_l_gt_u_p (Complex* a, Complex* b)
|
454
|
+
{
|
455
|
+
return real_gt_p(a->im->l, b->im->u);
|
456
|
+
}
|
457
|
+
|
458
|
+
int complex_im_n_gt_l_p (Complex* a, Complex* b)
|
459
|
+
{
|
460
|
+
return real_gt_p(a->im->n, b->im->l);
|
461
|
+
}
|
462
|
+
|
463
|
+
int complex_im_n_gt_n_p (Complex* a, Complex* b)
|
464
|
+
{
|
465
|
+
return real_gt_p(a->im->n, b->im->n);
|
466
|
+
}
|
467
|
+
|
468
|
+
int complex_im_n_gt_u_p (Complex* a, Complex* b)
|
469
|
+
{
|
470
|
+
return real_gt_p(a->im->n, b->im->u);
|
471
|
+
}
|
472
|
+
|
473
|
+
int complex_im_u_gt_l_p (Complex* a, Complex* b)
|
474
|
+
{
|
475
|
+
return real_gt_p(a->im->u, b->im->l);
|
476
|
+
}
|
477
|
+
|
478
|
+
int complex_im_u_gt_n_p (Complex* a, Complex* b)
|
479
|
+
{
|
480
|
+
return real_gt_p(a->im->u, b->im->n);
|
481
|
+
}
|
482
|
+
|
483
|
+
int complex_im_u_gt_u_p (Complex* a, Complex* b)
|
484
|
+
{
|
485
|
+
return real_gt_p(a->im->u, b->im->u);
|
486
|
+
}
|
487
|
+
|
488
|
+
int complex_im_l_ge_l_p (Complex* a, Complex* b)
|
489
|
+
{
|
490
|
+
return real_ge_p(a->im->l, b->im->l);
|
491
|
+
}
|
492
|
+
|
493
|
+
int complex_im_l_ge_n_p (Complex* a, Complex* b)
|
494
|
+
{
|
495
|
+
return real_ge_p(a->im->l, b->im->n);
|
496
|
+
}
|
497
|
+
|
498
|
+
int complex_im_l_ge_u_p (Complex* a, Complex* b)
|
499
|
+
{
|
500
|
+
return real_ge_p(a->im->l, b->im->u);
|
501
|
+
}
|
502
|
+
|
503
|
+
int complex_im_n_ge_l_p (Complex* a, Complex* b)
|
504
|
+
{
|
505
|
+
return real_ge_p(a->im->n, b->im->l);
|
506
|
+
}
|
507
|
+
|
508
|
+
int complex_im_n_ge_n_p (Complex* a, Complex* b)
|
509
|
+
{
|
510
|
+
return real_ge_p(a->im->n, b->im->n);
|
511
|
+
}
|
512
|
+
|
513
|
+
int complex_im_n_ge_u_p (Complex* a, Complex* b)
|
514
|
+
{
|
515
|
+
return real_ge_p(a->im->n, b->im->u);
|
516
|
+
}
|
517
|
+
|
518
|
+
int complex_im_u_ge_l_p (Complex* a, Complex* b)
|
519
|
+
{
|
520
|
+
return real_ge_p(a->im->u, b->im->l);
|
521
|
+
}
|
522
|
+
|
523
|
+
int complex_im_u_ge_n_p (Complex* a, Complex* b)
|
524
|
+
{
|
525
|
+
return real_ge_p(a->im->u, b->im->n);
|
526
|
+
}
|
527
|
+
|
528
|
+
int complex_im_u_ge_u_p (Complex* a, Complex* b)
|
529
|
+
{
|
530
|
+
return real_ge_p(a->im->u, b->im->u);
|
531
|
+
}
|
532
|
+
|
533
|
+
int complex_im_l_lt_l_p (Complex* a, Complex* b)
|
534
|
+
{
|
535
|
+
return real_lt_p(a->im->l, b->im->l);
|
536
|
+
}
|
537
|
+
|
538
|
+
int complex_im_l_lt_n_p (Complex* a, Complex* b)
|
539
|
+
{
|
540
|
+
return real_lt_p(a->im->l, b->im->n);
|
541
|
+
}
|
542
|
+
|
543
|
+
int complex_im_l_lt_u_p (Complex* a, Complex* b)
|
544
|
+
{
|
545
|
+
return real_lt_p(a->im->l, b->im->u);
|
546
|
+
}
|
547
|
+
|
548
|
+
int complex_im_n_lt_l_p (Complex* a, Complex* b)
|
549
|
+
{
|
550
|
+
return real_lt_p(a->im->n, b->im->l);
|
551
|
+
}
|
552
|
+
|
553
|
+
int complex_im_n_lt_n_p (Complex* a, Complex* b)
|
554
|
+
{
|
555
|
+
return real_lt_p(a->im->n, b->im->n);
|
556
|
+
}
|
557
|
+
|
558
|
+
int complex_im_n_lt_u_p (Complex* a, Complex* b)
|
559
|
+
{
|
560
|
+
return real_lt_p(a->im->n, b->im->u);
|
561
|
+
}
|
562
|
+
|
563
|
+
int complex_im_u_lt_l_p (Complex* a, Complex* b)
|
564
|
+
{
|
565
|
+
return real_lt_p(a->im->u, b->im->l);
|
566
|
+
}
|
567
|
+
|
568
|
+
int complex_im_u_lt_n_p (Complex* a, Complex* b)
|
569
|
+
{
|
570
|
+
return real_lt_p(a->im->u, b->im->n);
|
571
|
+
}
|
572
|
+
|
573
|
+
int complex_im_u_lt_u_p (Complex* a, Complex* b)
|
574
|
+
{
|
575
|
+
return real_lt_p(a->im->u, b->im->u);
|
576
|
+
}
|
577
|
+
|
578
|
+
int complex_im_l_le_l_p (Complex* a, Complex* b)
|
579
|
+
{
|
580
|
+
return real_le_p(a->im->l, b->im->l);
|
581
|
+
}
|
582
|
+
|
583
|
+
int complex_im_l_le_n_p (Complex* a, Complex* b)
|
584
|
+
{
|
585
|
+
return real_le_p(a->im->l, b->im->n);
|
586
|
+
}
|
587
|
+
|
588
|
+
int complex_im_l_le_u_p (Complex* a, Complex* b)
|
589
|
+
{
|
590
|
+
return real_le_p(a->im->l, b->im->u);
|
591
|
+
}
|
592
|
+
|
593
|
+
int complex_im_n_le_l_p (Complex* a, Complex* b)
|
594
|
+
{
|
595
|
+
return real_le_p(a->im->n, b->im->l);
|
596
|
+
}
|
597
|
+
|
598
|
+
int complex_im_n_le_n_p (Complex* a, Complex* b)
|
599
|
+
{
|
600
|
+
return real_le_p(a->im->n, b->im->n);
|
601
|
+
}
|
602
|
+
|
603
|
+
int complex_im_n_le_u_p (Complex* a, Complex* b)
|
604
|
+
{
|
605
|
+
return real_le_p(a->im->n, b->im->u);
|
606
|
+
}
|
607
|
+
|
608
|
+
int complex_im_u_le_l_p (Complex* a, Complex* b)
|
609
|
+
{
|
610
|
+
return real_le_p(a->im->u, b->im->l);
|
611
|
+
}
|
612
|
+
|
613
|
+
int complex_im_u_le_n_p (Complex* a, Complex* b)
|
614
|
+
{
|
615
|
+
return real_le_p(a->im->u, b->im->n);
|
616
|
+
}
|
617
|
+
|
618
|
+
int complex_im_u_le_u_p (Complex* a, Complex* b)
|
619
|
+
{
|
620
|
+
return real_le_p(a->im->u, b->im->u);
|
621
|
+
}
|
622
|
+
|
623
|
+
int complex_contain_p (Complex* a, Complex* b)
|
624
|
+
{
|
625
|
+
return complex_re_contain_p(a, b) && complex_im_contain_p(a, b);
|
626
|
+
}
|
627
|
+
|
628
|
+
int complex_contain_ll_p (Complex* a, Complex* b)
|
629
|
+
{
|
630
|
+
return complex_re_contain_l_p(a, b) && complex_im_contain_l_p(a, b);
|
631
|
+
}
|
632
|
+
|
633
|
+
int complex_contain_lu_p (Complex* a, Complex* b)
|
634
|
+
{
|
635
|
+
return complex_re_contain_l_p(a, b) && complex_im_contain_u_p(a, b);
|
636
|
+
}
|
637
|
+
|
638
|
+
int complex_contain_n_p (Complex* a, Complex* b)
|
639
|
+
{
|
640
|
+
return complex_re_contain_n_p(a, b) && complex_im_contain_n_p(a, b);
|
641
|
+
}
|
642
|
+
|
643
|
+
int complex_contain_ul_p (Complex* a, Complex* b)
|
644
|
+
{
|
645
|
+
return complex_re_contain_u_p(a, b) && complex_im_contain_l_p(a, b);
|
646
|
+
}
|
647
|
+
|
648
|
+
int complex_contain_uu_p (Complex* a, Complex* b)
|
649
|
+
{
|
650
|
+
return complex_re_contain_u_p(a, b) && complex_im_contain_u_p(a, b);
|
651
|
+
}
|
652
|
+
|
653
|
+
int complex_contain_zero_p (Complex* complex)
|
654
|
+
{
|
655
|
+
return interval_span_zero_p(complex->re) && interval_span_zero_p(complex->im);
|
656
|
+
}
|
657
|
+
|
658
|
+
int complex_intersect_p (Complex* a, Complex* b)
|
659
|
+
{
|
660
|
+
return (complex_re_intersect_p(a, b) && complex_im_intersect_p(a, b)) || complex_contain_ll_p(a, b) || complex_contain_lu_p(a, b) || complex_contain_ul_p(a, b) || complex_contain_uu_p(a, b) || (complex_re_contain_p(a, b) && complex_im_contain_p(b, a) || (complex_im_contain_p(a, b) && complex_re_contain_p(b, a)));
|
661
|
+
}
|
662
|
+
|
663
|
+
int complex_disjoint_p (Complex* a, Complex* b)
|
664
|
+
{
|
665
|
+
return !complex_intersect_p(a, b);
|
666
|
+
}
|
667
|
+
|
668
|
+
int complex_unbounded_p (Complex* complex)
|
669
|
+
{
|
670
|
+
return complex_re_unbounded_p(complex) && complex_im_unbounded_p(complex);
|
671
|
+
}
|
672
|
+
|
673
|
+
int complex_nan_p (Complex* complex)
|
674
|
+
{
|
675
|
+
return complex_re_nan_p(complex) && complex_im_nan_p(complex);
|
676
|
+
}
|
677
|
+
|
678
|
+
int complex_normal_p (Complex* complex)
|
679
|
+
{
|
680
|
+
return complex_re_normal_p(complex) && complex_im_normal_p(complex);
|
681
|
+
}
|
682
|
+
|
683
|
+
int complex_zero_p (Complex* complex)
|
684
|
+
{
|
685
|
+
return complex_re_zero_p(complex) && complex_im_zero_p(complex);
|
686
|
+
}
|
687
|
+
|
688
|
+
int complex_complex_p (Complex* complex)
|
689
|
+
{
|
690
|
+
return !complex_im_zero_p(complex);
|
691
|
+
}
|
692
|
+
|
693
|
+
int complex_real_p (Complex* complex)
|
694
|
+
{
|
695
|
+
return complex_re_normal_p(complex) && complex_im_zero_p(complex);
|
696
|
+
}
|
697
|
+
|
698
|
+
int complex_eq_p (Complex* a, Complex* b)
|
699
|
+
{
|
700
|
+
return complex_re_eq_p(a, b) && complex_im_eq_p(a, b);
|
701
|
+
}
|
702
|
+
|
703
|
+
int complex_bounds_eq_p (Complex* a, Complex* b)
|
704
|
+
{
|
705
|
+
return complex_re_bounds_eq_p(a, b) && complex_im_bounds_eq_p(a, b);
|
706
|
+
}
|