1 /*
2     Copyright (C) 2012 Fredrik Johansson
3 
4     This file is part of Arb.
5 
6     Arb is free software: you can redistribute it and/or modify it under
7     the terms of the GNU Lesser General Public License (LGPL) as published
8     by the Free Software Foundation; either version 2.1 of the License, or
9     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
10 */
11 
12 #ifndef ACB_H
13 #define ACB_H
14 
15 #ifdef ACB_INLINES_C
16 #define ACB_INLINE
17 #else
18 #define ACB_INLINE static __inline__
19 #endif
20 
21 #include <stdio.h>
22 #include "arf.h"
23 #include "arb.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 typedef struct
30 {
31     arb_struct real;
32     arb_struct imag;
33 }
34 acb_struct;
35 
36 typedef acb_struct acb_t[1];
37 typedef acb_struct * acb_ptr;
38 typedef const acb_struct * acb_srcptr;
39 
40 #define acb_realref(x) (&(x)->real)
41 #define acb_imagref(x) (&(x)->imag)
42 
43 ACB_INLINE void
acb_init(acb_t x)44 acb_init(acb_t x)
45 {
46     arb_init(acb_realref(x));
47     arb_init(acb_imagref(x));
48 }
49 
50 void acb_clear(acb_t x);
51 
52 acb_ptr _acb_vec_init(slong n);
53 void _acb_vec_clear(acb_ptr v, slong n);
54 
acb_real_ptr(acb_t z)55 ACB_INLINE arb_ptr acb_real_ptr(acb_t z) { return acb_realref(z); }
acb_imag_ptr(acb_t z)56 ACB_INLINE arb_ptr acb_imag_ptr(acb_t z) { return acb_imagref(z); }
57 
58 ACB_INLINE void
acb_get_real(arb_t re,const acb_t z)59 acb_get_real(arb_t re, const acb_t z)
60 {
61     arb_set(re, acb_realref(z));
62 }
63 
64 ACB_INLINE void
acb_get_imag(arb_t im,const acb_t z)65 acb_get_imag(arb_t im, const acb_t z)
66 {
67     arb_set(im, acb_imagref(z));
68 }
69 
70 ACB_INLINE void
acb_get_mid(acb_t res,const acb_t x)71 acb_get_mid(acb_t res, const acb_t x)
72 {
73     arb_get_mid_arb(acb_realref(res), acb_realref(x));
74     arb_get_mid_arb(acb_imagref(res), acb_imagref(x));
75 }
76 
77 ACB_INLINE int
acb_is_zero(const acb_t z)78 acb_is_zero(const acb_t z)
79 {
80     return arb_is_zero(acb_realref(z)) && arb_is_zero(acb_imagref(z));
81 }
82 
83 ACB_INLINE int
acb_is_one(const acb_t z)84 acb_is_one(const acb_t z)
85 {
86     return arb_is_one(acb_realref(z)) && arb_is_zero(acb_imagref(z));
87 }
88 
89 ACB_INLINE int
acb_is_exact(const acb_t z)90 acb_is_exact(const acb_t z)
91 {
92     return arb_is_exact(acb_realref(z)) && arb_is_exact(acb_imagref(z));
93 }
94 
95 ACB_INLINE int
acb_is_int(const acb_t z)96 acb_is_int(const acb_t z)
97 {
98     return arb_is_zero(acb_imagref(z)) && arb_is_int(acb_realref(z));
99 }
100 
101 ACB_INLINE int
acb_is_int_2exp_si(const acb_t z,slong e)102 acb_is_int_2exp_si(const acb_t z, slong e)
103 {
104     return arb_is_zero(acb_imagref(z)) && arb_is_int_2exp_si(acb_realref(z), e);
105 }
106 
107 ACB_INLINE void
acb_zero(acb_t z)108 acb_zero(acb_t z)
109 {
110     arb_zero(acb_realref(z));
111     arb_zero(acb_imagref(z));
112 }
113 
114 ACB_INLINE void
acb_one(acb_t z)115 acb_one(acb_t z)
116 {
117     arb_one(acb_realref(z));
118     arb_zero(acb_imagref(z));
119 }
120 
121 ACB_INLINE void
acb_onei(acb_t z)122 acb_onei(acb_t z)
123 {
124     arb_zero(acb_realref(z));
125     arb_one(acb_imagref(z));
126 }
127 
128 ACB_INLINE void
acb_set(acb_t z,const acb_t x)129 acb_set(acb_t z, const acb_t x)
130 {
131     arb_set(acb_realref(z), acb_realref(x));
132     arb_set(acb_imagref(z), acb_imagref(x));
133 }
134 
135 ACB_INLINE void
acb_set_round(acb_t z,const acb_t x,slong prec)136 acb_set_round(acb_t z, const acb_t x, slong prec)
137 {
138     arb_set_round(acb_realref(z), acb_realref(x), prec);
139     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
140 }
141 
142 ACB_INLINE void
acb_neg_round(acb_t z,const acb_t x,slong prec)143 acb_neg_round(acb_t z, const acb_t x, slong prec)
144 {
145     arb_neg_round(acb_realref(z), acb_realref(x), prec);
146     arb_neg_round(acb_imagref(z), acb_imagref(x), prec);
147 }
148 
149 ACB_INLINE void
acb_swap(acb_t z,acb_t x)150 acb_swap(acb_t z, acb_t x)
151 {
152     arb_swap(acb_realref(z), acb_realref(x));
153     arb_swap(acb_imagref(z), acb_imagref(x));
154 }
155 
156 ACB_INLINE int
acb_equal(const acb_t x,const acb_t y)157 acb_equal(const acb_t x, const acb_t y)
158 {
159     return arb_equal(acb_realref(x), acb_realref(y)) &&
160            arb_equal(acb_imagref(x), acb_imagref(y));
161 }
162 
163 ACB_INLINE int
acb_equal_si(const acb_t x,slong y)164 acb_equal_si(const acb_t x, slong y)
165 {
166     return arb_equal_si(acb_realref(x), y) && arb_is_zero(acb_imagref(x));
167 }
168 
169 ACB_INLINE int
acb_eq(const acb_t x,const acb_t y)170 acb_eq(const acb_t x, const acb_t y)
171 {
172     return arb_eq(acb_realref(x), acb_realref(y)) &&
173            arb_eq(acb_imagref(x), acb_imagref(y));
174 }
175 
176 ACB_INLINE int
acb_ne(const acb_t x,const acb_t y)177 acb_ne(const acb_t x, const acb_t y)
178 {
179     return arb_ne(acb_realref(x), acb_realref(y)) ||
180            arb_ne(acb_imagref(x), acb_imagref(y));
181 }
182 
183 ACB_INLINE int
acb_overlaps(const acb_t x,const acb_t y)184 acb_overlaps(const acb_t x, const acb_t y)
185 {
186     return arb_overlaps(acb_realref(x), acb_realref(y)) &&
187             arb_overlaps(acb_imagref(x), acb_imagref(y));
188 }
189 
190 ACB_INLINE int
acb_contains_zero(const acb_t x)191 acb_contains_zero(const acb_t x)
192 {
193     return arb_contains_zero(acb_realref(x)) &&
194             arb_contains_zero(acb_imagref(x));
195 }
196 
197 ACB_INLINE int
acb_contains_fmpq(const acb_t x,const fmpq_t y)198 acb_contains_fmpq(const acb_t x, const fmpq_t y)
199 {
200     return arb_contains_fmpq(acb_realref(x), y) &&
201             arb_contains_zero(acb_imagref(x));
202 }
203 
204 ACB_INLINE int
acb_contains_fmpz(const acb_t x,const fmpz_t y)205 acb_contains_fmpz(const acb_t x, const fmpz_t y)
206 {
207     return arb_contains_fmpz(acb_realref(x), y) &&
208             arb_contains_zero(acb_imagref(x));
209 }
210 
211 ACB_INLINE int
acb_contains(const acb_t x,const acb_t y)212 acb_contains(const acb_t x, const acb_t y)
213 {
214     return arb_contains(acb_realref(x), acb_realref(y)) &&
215             arb_contains(acb_imagref(x), acb_imagref(y));
216 }
217 
218 ACB_INLINE int
acb_contains_interior(const acb_t x,const acb_t y)219 acb_contains_interior(const acb_t x, const acb_t y)
220 {
221     return arb_contains_interior(acb_realref(x), acb_realref(y)) &&
222             arb_contains_interior(acb_imagref(x), acb_imagref(y));
223 }
224 
225 ACB_INLINE void
acb_set_ui(acb_t z,ulong c)226 acb_set_ui(acb_t z, ulong c)
227 {
228     arb_set_ui(acb_realref(z), c);
229     arb_zero(acb_imagref(z));
230 }
231 
232 ACB_INLINE void
acb_set_d(acb_t z,double c)233 acb_set_d(acb_t z, double c)
234 {
235     arb_set_d(acb_realref(z), c);
236     arb_zero(acb_imagref(z));
237 }
238 
239 ACB_INLINE void
acb_set_si(acb_t z,slong c)240 acb_set_si(acb_t z, slong c)
241 {
242     arb_set_si(acb_realref(z), c);
243     arb_zero(acb_imagref(z));
244 }
245 
246 ACB_INLINE void
acb_set_si_si(acb_t z,slong x,slong y)247 acb_set_si_si(acb_t z, slong x, slong y)
248 {
249     arb_set_si(acb_realref(z), x);
250     arb_set_si(acb_imagref(z), y);
251 }
252 
253 ACB_INLINE void
acb_set_d_d(acb_t z,double x,double y)254 acb_set_d_d(acb_t z, double x, double y)
255 {
256     arb_set_d(acb_realref(z), x);
257     arb_set_d(acb_imagref(z), y);
258 }
259 
260 ACB_INLINE void
acb_set_fmpz(acb_t z,const fmpz_t c)261 acb_set_fmpz(acb_t z, const fmpz_t c)
262 {
263     arb_set_fmpz(acb_realref(z), c);
264     arb_zero(acb_imagref(z));
265 }
266 
267 ACB_INLINE void
acb_set_fmpz_fmpz(acb_t z,const fmpz_t x,const fmpz_t y)268 acb_set_fmpz_fmpz(acb_t z, const fmpz_t x, const fmpz_t y)
269 {
270     arb_set_fmpz(acb_realref(z), x);
271     arb_set_fmpz(acb_imagref(z), y);
272 }
273 
274 ACB_INLINE void
acb_set_round_fmpz(acb_t z,const fmpz_t y,slong prec)275 acb_set_round_fmpz(acb_t z, const fmpz_t y, slong prec)
276 {
277     arb_set_round_fmpz(acb_realref(z), y, prec);
278     arb_zero(acb_imagref(z));
279 }
280 
281 int acb_contains_int(const acb_t x);
282 
283 int acb_get_unique_fmpz(fmpz_t z, const acb_t x);
284 
285 ACB_INLINE void
acb_set_fmpq(acb_t z,const fmpq_t c,slong prec)286 acb_set_fmpq(acb_t z, const fmpq_t c, slong prec)
287 {
288     arb_set_fmpq(acb_realref(z), c, prec);
289     arb_zero(acb_imagref(z));
290 }
291 
292 ACB_INLINE void
acb_set_arb(acb_t z,const arb_t c)293 acb_set_arb(acb_t z, const arb_t c)
294 {
295     arb_set(acb_realref(z), c);
296     arb_zero(acb_imagref(z));
297 }
298 
299 ACB_INLINE void
acb_set_arb_arb(acb_t z,const arb_t x,const arb_t y)300 acb_set_arb_arb(acb_t z, const arb_t x, const arb_t y)
301 {
302     arb_set(acb_realref(z), x);
303     arb_set(acb_imagref(z), y);
304 }
305 
306 ACB_INLINE void
acb_set_round_arb(acb_t z,const arb_t x,slong prec)307 acb_set_round_arb(acb_t z, const arb_t x, slong prec)
308 {
309     arb_set_round(acb_realref(z), x, prec);
310     arb_zero(acb_imagref(z));
311 }
312 
313 ACB_INLINE void
acb_trim(acb_t z,const acb_t x)314 acb_trim(acb_t z, const acb_t x)
315 {
316     arb_trim(acb_realref(z), acb_realref(x));
317     arb_trim(acb_imagref(z), acb_imagref(x));
318 }
319 
320 ACB_INLINE void
acb_add_error_arf(acb_t x,const arf_t err)321 acb_add_error_arf(acb_t x, const arf_t err)
322 {
323     arb_add_error_arf(acb_realref(x), err);
324     arb_add_error_arf(acb_imagref(x), err);
325 }
326 
327 ACB_INLINE void
acb_add_error_mag(acb_t x,const mag_t err)328 acb_add_error_mag(acb_t x, const mag_t err)
329 {
330     arb_add_error_mag(acb_realref(x), err);
331     arb_add_error_mag(acb_imagref(x), err);
332 }
333 
334 ACB_INLINE void
acb_add_error_arb(acb_t x,const arb_t err)335 acb_add_error_arb(acb_t x, const arb_t err)
336 {
337     arb_add_error(acb_realref(x), err);
338     arb_add_error(acb_imagref(x), err);
339 }
340 
341 void acb_get_mag(mag_t z, const acb_t x);
342 
343 void acb_get_mag_lower(mag_t z, const acb_t x);
344 
345 void acb_get_abs_ubound_arf(arf_t u, const acb_t z, slong prec);
346 void acb_get_abs_lbound_arf(arf_t u, const acb_t z, slong prec);
347 void acb_get_rad_ubound_arf(arf_t u, const acb_t z, slong prec);
348 
349 ACB_INLINE void
acb_union(acb_t res,const acb_t x,const acb_t y,slong prec)350 acb_union(acb_t res, const acb_t x, const acb_t y, slong prec)
351 {
352     arb_union(acb_realref(res), acb_realref(x), acb_realref(y), prec);
353     arb_union(acb_imagref(res), acb_imagref(x), acb_imagref(y), prec);
354 }
355 
356 void acb_arg(arb_t r, const acb_t z, slong prec);
357 
358 void acb_sgn(acb_t res, const acb_t z, slong prec);
359 
360 void acb_csgn(arb_t res, const acb_t z);
361 
362 void acb_real_abs(acb_t res, const acb_t z, int analytic, slong prec);
363 void acb_real_sgn(acb_t res, const acb_t z, int analytic, slong prec);
364 void acb_real_heaviside(acb_t res, const acb_t z, int analytic, slong prec);
365 void acb_real_floor(acb_t res, const acb_t z, int analytic, slong prec);
366 void acb_real_ceil(acb_t res, const acb_t z, int analytic, slong prec);
367 void acb_real_max(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec);
368 void acb_real_min(acb_t res, const acb_t x, const acb_t y, int analytic, slong prec);
369 void acb_real_sqrtpos(acb_t res, const acb_t z, int analytic, slong prec);
370 
371 void acb_sqrt_analytic(acb_t res, const acb_t z, int analytic, slong prec);
372 void acb_rsqrt_analytic(acb_t res, const acb_t z, int analytic, slong prec);
373 void acb_log_analytic(acb_t res, const acb_t z, int analytic, slong prec);
374 void acb_pow_analytic(acb_t res, const acb_t z, const acb_t w, int analytic, slong prec);
375 
376 ACB_INLINE void
acb_add(acb_t z,const acb_t x,const acb_t y,slong prec)377 acb_add(acb_t z, const acb_t x, const acb_t y, slong prec)
378 {
379     arb_add(acb_realref(z), acb_realref(x), acb_realref(y), prec);
380     arb_add(acb_imagref(z), acb_imagref(x), acb_imagref(y), prec);
381 }
382 
383 ACB_INLINE void
acb_sub(acb_t z,const acb_t x,const acb_t y,slong prec)384 acb_sub(acb_t z, const acb_t x, const acb_t y, slong prec)
385 {
386     arb_sub(acb_realref(z), acb_realref(x), acb_realref(y), prec);
387     arb_sub(acb_imagref(z), acb_imagref(x), acb_imagref(y), prec);
388 }
389 
390 ACB_INLINE void
acb_add_si(acb_t z,const acb_t x,ulong c,slong prec)391 acb_add_si(acb_t z, const acb_t x, ulong c, slong prec)
392 {
393     arb_add_si(acb_realref(z), acb_realref(x), c, prec);
394     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
395 }
396 
397 ACB_INLINE void
acb_add_ui(acb_t z,const acb_t x,ulong c,slong prec)398 acb_add_ui(acb_t z, const acb_t x, ulong c, slong prec)
399 {
400     arb_add_ui(acb_realref(z), acb_realref(x), c, prec);
401     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
402 }
403 
404 ACB_INLINE void
acb_sub_si(acb_t z,const acb_t x,ulong c,slong prec)405 acb_sub_si(acb_t z, const acb_t x, ulong c, slong prec)
406 {
407     arb_sub_si(acb_realref(z), acb_realref(x), c, prec);
408     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
409 }
410 
411 ACB_INLINE void
acb_sub_ui(acb_t z,const acb_t x,ulong c,slong prec)412 acb_sub_ui(acb_t z, const acb_t x, ulong c, slong prec)
413 {
414     arb_sub_ui(acb_realref(z), acb_realref(x), c, prec);
415     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
416 }
417 
418 ACB_INLINE void
acb_add_fmpz(acb_t z,const acb_t x,const fmpz_t y,slong prec)419 acb_add_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec)
420 {
421     arb_add_fmpz(acb_realref(z), acb_realref(x), y, prec);
422     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
423 }
424 
425 ACB_INLINE void
acb_add_arb(acb_t z,const acb_t x,const arb_t y,slong prec)426 acb_add_arb(acb_t z, const acb_t x, const arb_t y, slong prec)
427 {
428     arb_add(acb_realref(z), acb_realref(x), y, prec);
429     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
430 }
431 
432 ACB_INLINE void
acb_sub_fmpz(acb_t z,const acb_t x,const fmpz_t y,slong prec)433 acb_sub_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec)
434 {
435     arb_sub_fmpz(acb_realref(z), acb_realref(x), y, prec);
436     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
437 }
438 
439 ACB_INLINE void
acb_sub_arb(acb_t z,const acb_t x,const arb_t y,slong prec)440 acb_sub_arb(acb_t z, const acb_t x, const arb_t y, slong prec)
441 {
442     arb_sub(acb_realref(z), acb_realref(x), y, prec);
443     arb_set_round(acb_imagref(z), acb_imagref(x), prec);
444 }
445 
446 ACB_INLINE void
acb_neg(acb_t z,const acb_t x)447 acb_neg(acb_t z, const acb_t x)
448 {
449     arb_neg(acb_realref(z), acb_realref(x));
450     arb_neg(acb_imagref(z), acb_imagref(x));
451 }
452 
453 ACB_INLINE void
acb_conj(acb_t z,const acb_t x)454 acb_conj(acb_t z, const acb_t x)
455 {
456     arb_set(acb_realref(z), acb_realref(x));
457     arb_neg(acb_imagref(z), acb_imagref(x));
458 }
459 
460 ACB_INLINE void
acb_abs(arb_t u,const acb_t z,slong prec)461 acb_abs(arb_t u, const acb_t z, slong prec)
462 {
463     arb_hypot(u, acb_realref(z), acb_imagref(z), prec);
464 }
465 
466 ACB_INLINE void
acb_mul_ui(acb_t z,const acb_t x,ulong y,slong prec)467 acb_mul_ui(acb_t z, const acb_t x, ulong y, slong prec)
468 {
469     arb_mul_ui(acb_realref(z), acb_realref(x), y, prec);
470     arb_mul_ui(acb_imagref(z), acb_imagref(x), y, prec);
471 }
472 
473 ACB_INLINE void
acb_mul_si(acb_t z,const acb_t x,slong y,slong prec)474 acb_mul_si(acb_t z, const acb_t x, slong y, slong prec)
475 {
476     arb_mul_si(acb_realref(z), acb_realref(x), y, prec);
477     arb_mul_si(acb_imagref(z), acb_imagref(x), y, prec);
478 }
479 
480 ACB_INLINE void
acb_mul_fmpz(acb_t z,const acb_t x,const fmpz_t y,slong prec)481 acb_mul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec)
482 {
483     arb_mul_fmpz(acb_realref(z), acb_realref(x), y, prec);
484     arb_mul_fmpz(acb_imagref(z), acb_imagref(x), y, prec);
485 }
486 
487 ACB_INLINE void
acb_mul_arb(acb_t z,const acb_t x,const arb_t y,slong prec)488 acb_mul_arb(acb_t z, const acb_t x, const arb_t y, slong prec)
489 {
490     arb_mul(acb_realref(z), acb_realref(x), y, prec);
491     arb_mul(acb_imagref(z), acb_imagref(x), y, prec);
492 }
493 
494 ACB_INLINE void
acb_mul_onei(acb_t z,const acb_t x)495 acb_mul_onei(acb_t z, const acb_t x)
496 {
497     if (z == x)
498     {
499         arb_swap(acb_realref(z), acb_imagref(z));
500         arb_neg(acb_realref(z), acb_realref(z));
501     }
502     else
503     {
504         arb_neg(acb_realref(z), acb_imagref(x));
505         arb_set(acb_imagref(z), acb_realref(x));
506     }
507 }
508 
509 ACB_INLINE void
acb_div_onei(acb_t z,const acb_t x)510 acb_div_onei(acb_t z, const acb_t x)
511 {
512     if (z == x)
513     {
514         arb_swap(acb_realref(z), acb_imagref(z));
515         arb_neg(acb_imagref(z), acb_imagref(z));
516     }
517     else
518     {
519         arb_set(acb_realref(z), acb_imagref(x));
520         arb_neg(acb_imagref(z), acb_realref(x));
521     }
522 }
523 
524 void acb_mul(acb_t z, const acb_t x, const acb_t y, slong prec);
525 
526 void acb_mul_naive(acb_t z, const acb_t x, const acb_t y, slong prec);
527 
528 ACB_INLINE void
acb_mul_2exp_si(acb_t z,const acb_t x,slong e)529 acb_mul_2exp_si(acb_t z, const acb_t x, slong e)
530 {
531     arb_mul_2exp_si(acb_realref(z), acb_realref(x), e);
532     arb_mul_2exp_si(acb_imagref(z), acb_imagref(x), e);
533 }
534 
535 ACB_INLINE void
acb_mul_2exp_fmpz(acb_t z,const acb_t x,const fmpz_t c)536 acb_mul_2exp_fmpz(acb_t z, const acb_t x, const fmpz_t c)
537 {
538     arb_mul_2exp_fmpz(acb_realref(z), acb_realref(x), c);
539     arb_mul_2exp_fmpz(acb_imagref(z), acb_imagref(x), c);
540 }
541 
542 void acb_addmul(acb_t z, const acb_t x, const acb_t y, slong prec);
543 
544 void acb_submul(acb_t z, const acb_t x, const acb_t y, slong prec);
545 
546 ACB_INLINE void
acb_addmul_ui(acb_t z,const acb_t x,ulong y,slong prec)547 acb_addmul_ui(acb_t z, const acb_t x, ulong y, slong prec)
548 {
549     arb_addmul_ui(acb_realref(z), acb_realref(x), y, prec);
550     arb_addmul_ui(acb_imagref(z), acb_imagref(x), y, prec);
551 }
552 
553 ACB_INLINE void
acb_addmul_si(acb_t z,const acb_t x,slong y,slong prec)554 acb_addmul_si(acb_t z, const acb_t x, slong y, slong prec)
555 {
556     arb_addmul_si(acb_realref(z), acb_realref(x), y, prec);
557     arb_addmul_si(acb_imagref(z), acb_imagref(x), y, prec);
558 }
559 
560 ACB_INLINE void
acb_submul_ui(acb_t z,const acb_t x,ulong y,slong prec)561 acb_submul_ui(acb_t z, const acb_t x, ulong y, slong prec)
562 {
563     arb_submul_ui(acb_realref(z), acb_realref(x), y, prec);
564     arb_submul_ui(acb_imagref(z), acb_imagref(x), y, prec);
565 }
566 
567 ACB_INLINE void
acb_submul_si(acb_t z,const acb_t x,slong y,slong prec)568 acb_submul_si(acb_t z, const acb_t x, slong y, slong prec)
569 {
570     arb_submul_si(acb_realref(z), acb_realref(x), y, prec);
571     arb_submul_si(acb_imagref(z), acb_imagref(x), y, prec);
572 }
573 
574 ACB_INLINE void
acb_addmul_fmpz(acb_t z,const acb_t x,const fmpz_t y,slong prec)575 acb_addmul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec)
576 {
577     arb_addmul_fmpz(acb_realref(z), acb_realref(x), y, prec);
578     arb_addmul_fmpz(acb_imagref(z), acb_imagref(x), y, prec);
579 }
580 
581 ACB_INLINE void
acb_submul_fmpz(acb_t z,const acb_t x,const fmpz_t y,slong prec)582 acb_submul_fmpz(acb_t z, const acb_t x, const fmpz_t y, slong prec)
583 {
584     arb_submul_fmpz(acb_realref(z), acb_realref(x), y, prec);
585     arb_submul_fmpz(acb_imagref(z), acb_imagref(x), y, prec);
586 }
587 
588 ACB_INLINE void
acb_addmul_arb(acb_t z,const acb_t x,const arb_t y,slong prec)589 acb_addmul_arb(acb_t z, const acb_t x, const arb_t y, slong prec)
590 {
591     arb_addmul(acb_realref(z), acb_realref(x), y, prec);
592     arb_addmul(acb_imagref(z), acb_imagref(x), y, prec);
593 }
594 
595 ACB_INLINE void
acb_submul_arb(acb_t z,const acb_t x,const arb_t y,slong prec)596 acb_submul_arb(acb_t z, const acb_t x, const arb_t y, slong prec)
597 {
598     arb_submul(acb_realref(z), acb_realref(x), y, prec);
599     arb_submul(acb_imagref(z), acb_imagref(x), y, prec);
600 }
601 
602 void acb_dot_simple(acb_t res, const acb_t initial, int subtract,
603     acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec);
604 void acb_dot_precise(acb_t res, const acb_t initial, int subtract,
605     acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec);
606 void acb_dot(acb_t res, const acb_t initial, int subtract,
607     acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec);
608 
609 void acb_approx_dot(acb_t res, const acb_t initial, int subtract,
610     acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec);
611 
612 void acb_dot_ui(acb_t res, const acb_t initial, int subtract,
613     acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec);
614 void acb_dot_si(acb_t res, const acb_t initial, int subtract,
615     acb_srcptr x, slong xstep, const slong * y, slong ystep, slong len, slong prec);
616 void acb_dot_uiui(acb_t res, const acb_t initial, int subtract,
617     acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec);
618 void acb_dot_siui(acb_t res, const acb_t initial, int subtract,
619     acb_srcptr x, slong xstep, const ulong * y, slong ystep, slong len, slong prec);
620 void acb_dot_fmpz(acb_t res, const acb_t initial, int subtract,
621     acb_srcptr x, slong xstep, const fmpz * y, slong ystep, slong len, slong prec);
622 
623 void acb_inv(acb_t z, const acb_t x, slong prec);
624 
625 void acb_div(acb_t z, const acb_t x, const acb_t y, slong prec);
626 
627 ACB_INLINE void
acb_div_ui(acb_t z,const acb_t x,ulong c,slong prec)628 acb_div_ui(acb_t z, const acb_t x, ulong c, slong prec)
629 {
630     arb_div_ui(acb_realref(z), acb_realref(x), c, prec);
631     arb_div_ui(acb_imagref(z), acb_imagref(x), c, prec);
632 }
633 
634 ACB_INLINE void
acb_div_si(acb_t z,const acb_t x,slong c,slong prec)635 acb_div_si(acb_t z, const acb_t x, slong c, slong prec)
636 {
637     arb_div_si(acb_realref(z), acb_realref(x), c, prec);
638     arb_div_si(acb_imagref(z), acb_imagref(x), c, prec);
639 }
640 
641 ACB_INLINE void
acb_div_arb(acb_t z,const acb_t x,const arb_t c,slong prec)642 acb_div_arb(acb_t z, const acb_t x, const arb_t c, slong prec)
643 {
644     arb_div(acb_realref(z), acb_realref(x), c, prec);
645     arb_div(acb_imagref(z), acb_imagref(x), c, prec);
646 }
647 
648 ACB_INLINE void
acb_div_fmpz(acb_t z,const acb_t x,const fmpz_t c,slong prec)649 acb_div_fmpz(acb_t z, const acb_t x, const fmpz_t c, slong prec)
650 {
651     arb_div_fmpz(acb_realref(z), acb_realref(x), c, prec);
652     arb_div_fmpz(acb_imagref(z), acb_imagref(x), c, prec);
653 }
654 
655 void acb_cube(acb_t y, const acb_t x, slong prec);
656 void acb_pow_fmpz(acb_t y, const acb_t b, const fmpz_t e, slong prec);
657 void acb_pow_ui(acb_t y, const acb_t b, ulong e, slong prec);
658 void acb_pow_si(acb_t y, const acb_t b, slong e, slong prec);
659 
660 ACB_INLINE void
acb_const_pi(acb_t x,slong prec)661 acb_const_pi(acb_t x, slong prec)
662 {
663     arb_const_pi(acb_realref(x), prec);
664     arb_zero(acb_imagref(x));
665 }
666 
667 void acb_log(acb_t r, const acb_t z, slong prec);
668 void acb_log1p(acb_t r, const acb_t z, slong prec);
669 
670 void acb_exp(acb_t r, const acb_t z, slong prec);
671 void acb_exp_pi_i(acb_t r, const acb_t z, slong prec);
672 void acb_exp_invexp(acb_t r, acb_t s, const acb_t z, slong prec);
673 void acb_expm1(acb_t r, const acb_t z, slong prec);
674 
675 void acb_sin(acb_t r, const acb_t z, slong prec);
676 void acb_cos(acb_t r, const acb_t z, slong prec);
677 void acb_sin_cos(acb_t s, acb_t c, const acb_t z, slong prec);
678 void acb_tan(acb_t r, const acb_t z, slong prec);
679 void acb_cot(acb_t r, const acb_t z, slong prec);
680 
681 void acb_asin(acb_t r, const acb_t z, slong prec);
682 void acb_acos(acb_t r, const acb_t z, slong prec);
683 void acb_atan(acb_t r, const acb_t z, slong prec);
684 void acb_asinh(acb_t r, const acb_t z, slong prec);
685 void acb_acosh(acb_t r, const acb_t z, slong prec);
686 void acb_atanh(acb_t r, const acb_t z, slong prec);
687 
688 ACB_INLINE void
acb_sinh(acb_t y,const acb_t x,slong prec)689 acb_sinh(acb_t y, const acb_t x, slong prec)
690 {
691     acb_mul_onei(y, x);
692     acb_sin(y, y, prec);
693     acb_div_onei(y, y);
694 }
695 
696 ACB_INLINE void
acb_cosh(acb_t y,const acb_t x,slong prec)697 acb_cosh(acb_t y, const acb_t x, slong prec)
698 {
699     acb_mul_onei(y, x);
700     acb_cos(y, y, prec);
701 }
702 
703 ACB_INLINE void
acb_sinh_cosh(acb_t y,acb_t z,const acb_t x,slong prec)704 acb_sinh_cosh(acb_t y, acb_t z, const acb_t x, slong prec)
705 {
706     acb_mul_onei(y, x);
707     acb_sin_cos(y, z, y, prec);
708     acb_div_onei(y, y);
709 }
710 
711 ACB_INLINE void
acb_tanh(acb_t y,const acb_t x,slong prec)712 acb_tanh(acb_t y, const acb_t x, slong prec)
713 {
714     acb_mul_onei(y, x);
715     acb_tan(y, y, prec);
716     acb_div_onei(y, y);
717 }
718 
719 ACB_INLINE void
acb_coth(acb_t y,const acb_t x,slong prec)720 acb_coth(acb_t y, const acb_t x, slong prec)
721 {
722     acb_mul_onei(y, x);
723     acb_cot(y, y, prec);
724     acb_mul_onei(y, y);
725 }
726 
727 void acb_sech(acb_t r, const acb_t z, slong prec);
728 void acb_csch(acb_t r, const acb_t z, slong prec);
729 
730 ACB_INLINE void
acb_sec(acb_t y,const acb_t x,slong prec)731 acb_sec(acb_t y, const acb_t x, slong prec)
732 {
733     acb_mul_onei(y, x);
734     acb_sech(y, y, prec);
735 }
736 
737 ACB_INLINE void
acb_csc(acb_t y,const acb_t x,slong prec)738 acb_csc(acb_t y, const acb_t x, slong prec)
739 {
740     acb_mul_onei(y, x);
741     acb_csch(y, y, prec);
742     acb_mul_onei(y, y);
743 }
744 
745 void acb_sin_pi(acb_t r, const acb_t z, slong prec);
746 void acb_cos_pi(acb_t r, const acb_t z, slong prec);
747 void acb_sin_cos_pi(acb_t s, acb_t c, const acb_t z, slong prec);
748 void acb_tan_pi(acb_t r, const acb_t z, slong prec);
749 void acb_cot_pi(acb_t r, const acb_t z, slong prec);
750 void acb_csc_pi(acb_t y, const acb_t x, slong prec);
751 
752 void acb_sinc(acb_t res, const acb_t z, slong prec);
753 void acb_sinc_pi(acb_t res, const acb_t z, slong prec);
754 
755 void acb_pow_arb(acb_t z, const acb_t x, const arb_t y, slong prec);
756 void acb_pow(acb_t r, const acb_t x, const acb_t y, slong prec);
757 
758 void acb_sqrt(acb_t y, const acb_t x, slong prec);
759 void acb_rsqrt(acb_t y, const acb_t x, slong prec);
760 
761 void acb_root_ui(acb_t y, const acb_t x, ulong k, slong prec);
762 
763 void acb_quadratic_roots_fmpz(acb_t r1, acb_t r2,
764     const fmpz_t a, const fmpz_t b, const fmpz_t c, slong prec);
765 
766 void acb_chebyshev_t_ui(acb_t a, ulong n, const acb_t x, slong prec);
767 void acb_chebyshev_t2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec);
768 void acb_chebyshev_u_ui(acb_t a, ulong n, const acb_t x, slong prec);
769 void acb_chebyshev_u2_ui(acb_t a, acb_t b, ulong n, const acb_t x, slong prec);
770 
771 void acb_rising_ui(acb_t z, const acb_t x, ulong n, slong prec);
772 void acb_rising(acb_t z, const acb_t x, const acb_t n, slong prec);
773 void acb_rising2_ui(acb_t u, acb_t v, const acb_t x, ulong n, slong prec);
774 
775 void acb_rising_ui_get_mag(mag_t bound, const acb_t s, ulong n);
776 
777 void acb_gamma(acb_t y, const acb_t x, slong prec);
778 void acb_rgamma(acb_t y, const acb_t x, slong prec);
779 void acb_lgamma(acb_t y, const acb_t x, slong prec);
780 void acb_log_sin_pi(acb_t res, const acb_t z, slong prec);
781 void acb_digamma(acb_t y, const acb_t x, slong prec);
782 void acb_zeta(acb_t z, const acb_t s, slong prec);
783 void acb_hurwitz_zeta(acb_t z, const acb_t s, const acb_t a, slong prec);
784 void acb_polygamma(acb_t res, const acb_t s, const acb_t z, slong prec);
785 
786 void acb_bernoulli_poly_ui(acb_t res, ulong n, const acb_t x, slong prec);
787 
788 void acb_log_barnes_g(acb_t res, const acb_t z, slong prec);
789 void acb_barnes_g(acb_t res, const acb_t z, slong prec);
790 
791 void acb_polylog(acb_t w, const acb_t s, const acb_t z, slong prec);
792 void acb_polylog_si(acb_t w, slong s, const acb_t z, slong prec);
793 
794 void acb_agm1(acb_t m, const acb_t z, slong prec);
795 void acb_agm1_cpx(acb_ptr m, const acb_t z, slong len, slong prec);
796 void acb_agm(acb_t res, const acb_t a, const acb_t b, slong prec);
797 
798 #define ACB_LAMBERTW_LEFT 2
799 #define ACB_LAMBERTW_MIDDLE 4
800 
801 void acb_lambertw_asymp(acb_t res, const acb_t z, const fmpz_t k, slong L, slong M, slong prec);
802 int acb_lambertw_check_branch(const acb_t w, const fmpz_t k, slong prec);
803 void acb_lambertw_bound_deriv(mag_t res, const acb_t z, const acb_t ez1, const fmpz_t k);
804 void acb_lambertw(acb_t res, const acb_t z, const fmpz_t k, int flags, slong prec);
805 
806 ACB_INLINE void
acb_sqr(acb_t res,const acb_t val,slong prec)807 acb_sqr(acb_t res, const acb_t val, slong prec)
808 {
809     acb_mul(res, val, val, prec);
810 }
811 
812 ACB_INLINE int
acb_is_finite(const acb_t x)813 acb_is_finite(const acb_t x)
814 {
815     return arb_is_finite(acb_realref(x)) && arb_is_finite(acb_imagref(x));
816 }
817 
818 ACB_INLINE void
acb_indeterminate(acb_t x)819 acb_indeterminate(acb_t x)
820 {
821     arb_indeterminate(acb_realref(x));
822     arb_indeterminate(acb_imagref(x));
823 }
824 
825 ACB_INLINE acb_ptr
_acb_vec_entry_ptr(acb_ptr vec,slong i)826 _acb_vec_entry_ptr(acb_ptr vec, slong i)
827 {
828     return vec + i;
829 }
830 
831 ACB_INLINE void
_acb_vec_zero(acb_ptr A,slong n)832 _acb_vec_zero(acb_ptr A, slong n)
833 {
834     slong i;
835     for (i = 0; i < n; i++)
836         acb_zero(A + i);
837 }
838 
839 ACB_INLINE int
_acb_vec_is_zero(acb_srcptr vec,slong len)840 _acb_vec_is_zero(acb_srcptr vec, slong len)
841 {
842     slong i;
843     for (i = 0; i < len; i++)
844         if (!acb_is_zero(vec + i))
845             return 0;
846     return 1;
847 }
848 
849 ACB_INLINE void
_acb_vec_set(acb_ptr res,acb_srcptr vec,slong len)850 _acb_vec_set(acb_ptr res, acb_srcptr vec, slong len)
851 {
852     slong i;
853     for (i = 0; i < len; i++)
854         acb_set(res + i, vec + i);
855 }
856 
857 ACB_INLINE void
_acb_vec_set_round(acb_ptr res,acb_srcptr vec,slong len,slong prec)858 _acb_vec_set_round(acb_ptr res, acb_srcptr vec, slong len, slong prec)
859 {
860     slong i;
861     for (i = 0; i < len; i++)
862         acb_set_round(res + i, vec + i, prec);
863 }
864 
865 ACB_INLINE void
_acb_vec_swap(acb_ptr res,acb_ptr vec,slong len)866 _acb_vec_swap(acb_ptr res, acb_ptr vec, slong len)
867 {
868     slong i;
869     for (i = 0; i < len; i++)
870         acb_swap(res + i, vec + i);
871 }
872 
873 ACB_INLINE void
_acb_vec_neg(acb_ptr res,acb_srcptr vec,slong len)874 _acb_vec_neg(acb_ptr res, acb_srcptr vec, slong len)
875 {
876     slong i;
877     for (i = 0; i < len; i++)
878         acb_neg(res + i, vec + i);
879 }
880 
881 ACB_INLINE void
_acb_vec_add(acb_ptr res,acb_srcptr vec1,acb_srcptr vec2,slong len,slong prec)882 _acb_vec_add(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec)
883 {
884     slong i;
885     for (i = 0; i < len; i++)
886         acb_add(res + i, vec1 + i, vec2 + i, prec);
887 }
888 
889 ACB_INLINE void
_acb_vec_sub(acb_ptr res,acb_srcptr vec1,acb_srcptr vec2,slong len,slong prec)890 _acb_vec_sub(acb_ptr res, acb_srcptr vec1, acb_srcptr vec2, slong len, slong prec)
891 {
892     slong i;
893     for (i = 0; i < len; i++)
894         acb_sub(res + i, vec1 + i, vec2 + i, prec);
895 }
896 
897 ACB_INLINE void
_acb_vec_scalar_submul(acb_ptr res,acb_srcptr vec,slong len,const acb_t c,slong prec)898 _acb_vec_scalar_submul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec)
899 {
900     slong i;
901     for (i = 0; i < len; i++)
902         acb_submul(res + i, vec + i, c, prec);
903 }
904 
905 ACB_INLINE void
_acb_vec_scalar_addmul(acb_ptr res,acb_srcptr vec,slong len,const acb_t c,slong prec)906 _acb_vec_scalar_addmul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec)
907 {
908     slong i;
909     for (i = 0; i < len; i++)
910         acb_addmul(res + i, vec + i, c, prec);
911 }
912 
913 ACB_INLINE void
_acb_vec_scalar_mul(acb_ptr res,acb_srcptr vec,slong len,const acb_t c,slong prec)914 _acb_vec_scalar_mul(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec)
915 {
916     slong i;
917     for (i = 0; i < len; i++)
918         acb_mul(res + i, vec + i, c, prec);
919 }
920 
921 ACB_INLINE void
_acb_vec_scalar_mul_ui(acb_ptr res,acb_srcptr vec,slong len,ulong c,slong prec)922 _acb_vec_scalar_mul_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec)
923 {
924     slong i;
925     for (i = 0; i < len; i++)
926         acb_mul_ui(res + i, vec + i, c, prec);
927 }
928 
929 ACB_INLINE void
_acb_vec_scalar_mul_2exp_si(acb_ptr res,acb_srcptr vec,slong len,slong c)930 _acb_vec_scalar_mul_2exp_si(acb_ptr res, acb_srcptr vec, slong len, slong c)
931 {
932     slong i;
933     for (i = 0; i < len; i++)
934         acb_mul_2exp_si(res + i, vec + i, c);
935 }
936 
937 ACB_INLINE void
_acb_vec_scalar_mul_onei(acb_ptr res,acb_srcptr vec,slong len)938 _acb_vec_scalar_mul_onei(acb_ptr res, acb_srcptr vec, slong len)
939 {
940     slong i;
941     for (i = 0; i < len; i++)
942         acb_mul_onei(res + i, vec + i);
943 }
944 
945 ACB_INLINE void
_acb_vec_scalar_div_ui(acb_ptr res,acb_srcptr vec,slong len,ulong c,slong prec)946 _acb_vec_scalar_div_ui(acb_ptr res, acb_srcptr vec, slong len, ulong c, slong prec)
947 {
948     slong i;
949     for (i = 0; i < len; i++)
950         acb_div_ui(res + i, vec + i, c, prec);
951 }
952 
953 ACB_INLINE void
_acb_vec_scalar_div(acb_ptr res,acb_srcptr vec,slong len,const acb_t c,slong prec)954 _acb_vec_scalar_div(acb_ptr res, acb_srcptr vec, slong len, const acb_t c, slong prec)
955 {
956     slong i;
957     for (i = 0; i < len; i++)
958         acb_div(res + i, vec + i, c, prec);
959 }
960 
961 ACB_INLINE void
_acb_vec_scalar_mul_arb(acb_ptr res,acb_srcptr vec,slong len,const arb_t c,slong prec)962 _acb_vec_scalar_mul_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec)
963 {
964     slong i;
965     for (i = 0; i < len; i++)
966         acb_mul_arb(res + i, vec + i, c, prec);
967 }
968 
969 ACB_INLINE void
_acb_vec_scalar_div_arb(acb_ptr res,acb_srcptr vec,slong len,const arb_t c,slong prec)970 _acb_vec_scalar_div_arb(acb_ptr res, acb_srcptr vec, slong len, const arb_t c, slong prec)
971 {
972     slong i;
973     for (i = 0; i < len; i++)
974     {
975         arb_div(acb_realref(res + i), acb_realref(vec + i), c, prec);
976         arb_div(acb_imagref(res + i), acb_imagref(vec + i), c, prec);
977     }
978 }
979 
980 ACB_INLINE void
_acb_vec_scalar_mul_fmpz(acb_ptr res,acb_srcptr vec,slong len,const fmpz_t c,slong prec)981 _acb_vec_scalar_mul_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec)
982 {
983     slong i;
984     for (i = 0; i < len; i++)
985         acb_mul_fmpz(res + i, vec + i, c, prec);
986 }
987 
988 ACB_INLINE void
_acb_vec_scalar_div_fmpz(acb_ptr res,acb_srcptr vec,slong len,const fmpz_t c,slong prec)989 _acb_vec_scalar_div_fmpz(acb_ptr res, acb_srcptr vec, slong len, const fmpz_t c, slong prec)
990 {
991     slong i;
992     for (i = 0; i < len; i++)
993         acb_div_fmpz(res + i, vec + i, c, prec);
994 }
995 
996 ACB_INLINE void
acb_fprint(FILE * file,const acb_t x)997 acb_fprint(FILE * file, const acb_t x)
998 {
999     flint_fprintf(file, "(");
1000     arb_fprint(file, acb_realref(x));
1001     flint_fprintf(file, ", ");
1002     arb_fprint(file, acb_imagref(x));
1003     flint_fprintf(file, ")");
1004 }
1005 
1006 ACB_INLINE void
acb_print(const acb_t x)1007 acb_print(const acb_t x)
1008 {
1009     acb_fprint(stdout, x);
1010 }
1011 
1012 void acb_fprintd(FILE * file, const acb_t z, slong digits);
1013 
1014 ACB_INLINE void
acb_printd(const acb_t z,slong digits)1015 acb_printd(const acb_t z, slong digits)
1016 {
1017     acb_fprintd(stdout, z, digits);
1018 }
1019 
1020 void acb_fprintn(FILE * fp, const acb_t z, slong digits, ulong flags);
1021 
1022 ACB_INLINE void
acb_printn(const acb_t x,slong digits,ulong flags)1023 acb_printn(const acb_t x, slong digits, ulong flags)
1024 {
1025     acb_fprintn(stdout, x, digits, flags);
1026 }
1027 
1028 ACB_INLINE void
_acb_vec_printn(acb_srcptr vec,slong len,slong ndigits,ulong flags)1029 _acb_vec_printn(acb_srcptr vec, slong len, slong ndigits, ulong flags)
1030 {
1031     slong i;
1032     for (i = 0; i < len; i++)
1033     {
1034         acb_printn(vec + i, ndigits, flags);
1035         if (i < len - 1)
1036             flint_printf(", ");
1037     }
1038 }
1039 
1040 void acb_randtest(acb_t z, flint_rand_t state, slong prec, slong mag_bits);
1041 
1042 void acb_randtest_special(acb_t z, flint_rand_t state, slong prec, slong mag_bits);
1043 
1044 void acb_randtest_precise(acb_t z, flint_rand_t state, slong prec, slong mag_bits);
1045 
1046 void acb_randtest_param(acb_t z, flint_rand_t state, slong prec, slong mag_bits);
1047 
1048 slong acb_rel_error_bits(const acb_t x);
1049 
1050 ACB_INLINE slong
acb_rel_accuracy_bits(const acb_t x)1051 acb_rel_accuracy_bits(const acb_t x)
1052 {
1053     return -acb_rel_error_bits(x);
1054 }
1055 
1056 slong acb_rel_one_accuracy_bits(const acb_t x);
1057 
1058 ACB_INLINE slong
acb_bits(const acb_t x)1059 acb_bits(const acb_t x)
1060 {
1061     slong b1, b2;
1062     b1 = arb_bits(acb_realref(x));
1063     b2 = arb_bits(acb_imagref(x));
1064     return FLINT_MAX(b1, b2);
1065 }
1066 
1067 ACB_INLINE int
acb_is_real(const acb_t x)1068 acb_is_real(const acb_t x)
1069 {
1070     return arb_is_zero(acb_imagref(x));
1071 }
1072 
1073 ACB_INLINE int
_acb_vec_is_real(acb_srcptr v,slong len)1074 _acb_vec_is_real(acb_srcptr v, slong len)
1075 {
1076     slong i;
1077 
1078     for (i = 0; i < len; i++)
1079     {
1080         if (!acb_is_real(v + i))
1081             return 0;
1082     }
1083 
1084     return 1;
1085 }
1086 
1087 ACB_INLINE slong
_acb_vec_bits(acb_srcptr vec,slong len)1088 _acb_vec_bits(acb_srcptr vec, slong len)
1089 {
1090     return _arb_vec_bits((arb_srcptr) vec, 2 * len);
1091 }
1092 
1093 void _acb_vec_set_powers(acb_ptr xs, const acb_t x, slong len, slong prec);
1094 
1095 ACB_INLINE void
_acb_vec_add_error_arf_vec(acb_ptr res,arf_srcptr err,slong len)1096 _acb_vec_add_error_arf_vec(acb_ptr res, arf_srcptr err, slong len)
1097 {
1098     slong i;
1099     for (i = 0; i < len; i++)
1100         acb_add_error_arf(res + i, err + i);
1101 }
1102 
1103 ACB_INLINE void
_acb_vec_add_error_mag_vec(acb_ptr res,mag_srcptr err,slong len)1104 _acb_vec_add_error_mag_vec(acb_ptr res, mag_srcptr err, slong len)
1105 {
1106     slong i;
1107     for (i = 0; i < len; i++)
1108     {
1109         mag_add(arb_radref(acb_realref(res + i)),
1110             arb_radref(acb_realref(res + i)), err + i);
1111         mag_add(arb_radref(acb_imagref(res + i)),
1112             arb_radref(acb_imagref(res + i)), err + i);
1113     }
1114 }
1115 
1116 ACB_INLINE void
_acb_vec_indeterminate(acb_ptr vec,slong len)1117 _acb_vec_indeterminate(acb_ptr vec, slong len)
1118 {
1119     _arb_vec_indeterminate((arb_ptr) vec, 2 * len);
1120 }
1121 
1122 ACB_INLINE void
_acb_vec_trim(acb_ptr res,acb_srcptr vec,slong len)1123 _acb_vec_trim(acb_ptr res, acb_srcptr vec, slong len)
1124 {
1125     slong i;
1126     for (i = 0; i < len; i++)
1127         acb_trim(res + i, vec + i);
1128 }
1129 
1130 ACB_INLINE int
_acb_vec_get_unique_fmpz_vec(fmpz * res,acb_srcptr vec,slong len)1131 _acb_vec_get_unique_fmpz_vec(fmpz * res,  acb_srcptr vec, slong len)
1132 {
1133     slong i;
1134     for (i = 0; i < len; i++)
1135         if (!acb_get_unique_fmpz(res + i, vec + i))
1136             return 0;
1137     return 1;
1138 }
1139 
1140 /* sort complex numbers in a nice-to-display order */
1141 void _acb_vec_sort_pretty(acb_ptr vec, slong len);
1142 
1143 /* roots of unity */
1144 void acb_unit_root(acb_t res, ulong order, slong prec);
1145 void _acb_vec_unit_roots(acb_ptr z, slong order, slong len, slong prec);
1146 
1147 ACB_INLINE slong
acb_allocated_bytes(const acb_t x)1148 acb_allocated_bytes(const acb_t x)
1149 {
1150     return arb_allocated_bytes(acb_realref(x)) + arb_allocated_bytes(acb_imagref(x));
1151 }
1152 
1153 ACB_INLINE slong
_acb_vec_allocated_bytes(acb_srcptr vec,slong len)1154 _acb_vec_allocated_bytes(acb_srcptr vec, slong len)
1155 {
1156     return _arb_vec_allocated_bytes((arb_srcptr) vec, 2 * len);
1157 }
1158 
1159 ACB_INLINE double
_acb_vec_estimate_allocated_bytes(slong len,slong prec)1160 _acb_vec_estimate_allocated_bytes(slong len, slong prec)
1161 {
1162     return 2 * _arb_vec_estimate_allocated_bytes(len, prec);
1163 }
1164 
1165 #ifdef __cplusplus
1166 }
1167 #endif
1168 
1169 #endif
1170