1 /*
2     Copyright (C) 2011 Sebastian Pancratz
3 
4     This file is part of FLINT.
5 
6     FLINT 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 "flint.h"
13 #include "fmpz_poly.h"
14 
fmpz_poly_factor_set(fmpz_poly_factor_t res,const fmpz_poly_factor_t fac)15 void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac)
16 {
17     if (res != fac)
18     {
19         if (fac->num == 0)
20         {
21             fmpz_poly_factor_clear(res);
22             fmpz_poly_factor_init(res);
23         }
24         else
25         {
26             slong i;
27 
28             fmpz_poly_factor_fit_length(res, fac->num);
29             fmpz_set(&(res->c), &(fac->c));
30             for (i = 0; i < fac->num; i++)
31             {
32                 fmpz_poly_set(res->p + i, fac->p + i);
33                 res->exp[i] = fac->exp[i];
34             }
35             for ( ; i < res->num; i++)
36             {
37                 fmpz_poly_zero(res->p + i);
38                 res->exp[i] = 0;
39             }
40             res->num = fac->num;
41         }
42     }
43 }
44 
45