1 /*
2     Copyright (C) 2011 Sebastian Pancratz
3     Copyright (C) 2012 Lina Kulakova
4     Copyright (C) 2013 Mike Hansen
5 
6     This file is part of FLINT.
7 
8     FLINT is free software: you can redistribute it and/or modify it under
9     the terms of the GNU Lesser General Public License (LGPL) as published
10     by the Free Software Foundation; either version 2.1 of the License, or
11     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
12 */
13 
14 #ifdef T
15 
16 #include "templates.h"
17 
18 void
TEMPLATE(T,poly_factor_set)19 TEMPLATE(T, poly_factor_set) (TEMPLATE(T, poly_factor_t) res,
20                               const TEMPLATE(T, poly_factor_t) fac,
21                               const TEMPLATE(T, ctx_t) ctx)
22 {
23     if (res != fac)
24     {
25         if (fac->num == 0)
26         {
27             TEMPLATE(T, poly_factor_clear) (res, ctx);
28             TEMPLATE(T, poly_factor_init) (res, ctx);
29         }
30         else
31         {
32             slong i;
33 
34             TEMPLATE(T, poly_factor_fit_length) (res, fac->num, ctx);
35             for (i = 0; i < fac->num; i++)
36             {
37                 TEMPLATE(T, poly_set) (res->poly + i, fac->poly + i, ctx);
38                 res->exp[i] = fac->exp[i];
39             }
40             for (; i < res->num; i++)
41             {
42                 TEMPLATE(T, poly_zero) (res->poly + i, ctx);
43                 res->exp[i] = 0;
44             }
45             res->num = fac->num;
46         }
47     }
48 }
49 
50 
51 #endif
52