1 /*=============================================================================
2 
3     This file is part of Antic.
4 
5     Antic is free software: you can redistribute it and/or modify it under
6     the terms of the GNU Lesser General Public License (LGPL) as published
7     by the Free Software Foundation; either version 2.1 of the License, or
8     (at your option) any later version. See <http://www.gnu.org/licenses/>.
9 
10 =============================================================================*/
11 /******************************************************************************
12 
13     Copyright (C) 2013 Fredrik Johansson
14     Copyright (C) 2014 William Hart
15 
16 ******************************************************************************/
17 
18 #include "nf_elem.h"
19 
nf_elem_clear(nf_elem_t a,const nf_t nf)20 void nf_elem_clear(nf_elem_t a, const nf_t nf)
21 {
22     if (nf->flag & NF_LINEAR)
23     {
24         fmpz_clear(LNF_ELEM_NUMREF(a));
25         fmpz_clear(LNF_ELEM_DENREF(a));
26     } else if (nf->flag & NF_QUADRATIC)
27     {
28         fmpz * const anum = QNF_ELEM_NUMREF(a);
29         fmpz * const aden = QNF_ELEM_DENREF(a);
30 
31         fmpz_clear(anum);
32         fmpz_clear(anum + 1);
33         fmpz_clear(anum + 2);
34         fmpz_clear(aden);
35     }
36     else
37     {
38         fmpq_poly_clear(NF_ELEM(a));
39     }
40 }
41