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 #include "acb_poly.h"
13 
14 void
acb_poly_set_arb_poly(acb_poly_t poly,const arb_poly_t re)15 acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re)
16 {
17     slong i, len;
18 
19     len = arb_poly_length(re);
20 
21     acb_poly_fit_length(poly, len);
22 
23     for (i = 0; i < len; i++)
24     {
25         arb_set(acb_realref(poly->coeffs + i), re->coeffs + i);
26         arb_zero(acb_imagref(poly->coeffs + i));
27     }
28 
29     _acb_poly_set_length(poly, len);
30 }
31 
32 void
acb_poly_set2_arb_poly(acb_poly_t poly,const arb_poly_t re,const arb_poly_t im)33 acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im)
34 {
35     slong i, rlen, ilen, len;
36 
37     rlen = arb_poly_length(re);
38     ilen = arb_poly_length(im);
39     len = FLINT_MAX(rlen, ilen);
40 
41     acb_poly_fit_length(poly, len);
42 
43     for (i = 0; i < rlen; i++)
44         arb_set(acb_realref(poly->coeffs + i), re->coeffs + i);
45     for (i = rlen; i < len; i++)
46         arb_zero(acb_realref(poly->coeffs + i));
47 
48     for (i = 0; i < ilen; i++)
49         arb_set(acb_imagref(poly->coeffs + i), im->coeffs + i);
50     for (i = ilen; i < len; i++)
51         arb_zero(acb_imagref(poly->coeffs + i));
52 
53     _acb_poly_set_length(poly, len);
54 }
55