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) 2015 William Hart
14
15 ******************************************************************************/
16
17 #include "nf_elem.h"
18
nf_elem_scalar_div_si(nf_elem_t a,const nf_elem_t b,slong c,const nf_t nf)19 void nf_elem_scalar_div_si(nf_elem_t a, const nf_elem_t b,
20 slong c, const nf_t nf)
21 {
22 if (nf->flag & NF_LINEAR)
23 {
24 fmpz * den = LNF_ELEM_DENREF(a);
25 fmpz * num = LNF_ELEM_NUMREF(a);
26 const fmpz * const den2 = LNF_ELEM_DENREF(b);
27 const fmpz * const num2 = LNF_ELEM_NUMREF(b);
28
29 fmpz_mul_si(den, den2, c);
30 fmpz_set(num, num2);
31 _fmpq_canonicalise(num, den);
32 }
33 else if (nf->flag & NF_QUADRATIC)
34 {
35 fmpz * den = QNF_ELEM_DENREF(a);
36 fmpz * num = QNF_ELEM_NUMREF(a);
37 const fmpz * const den2 = QNF_ELEM_DENREF(b);
38 const fmpz * const num2 = QNF_ELEM_NUMREF(b);
39
40 fmpz_mul_si(den, den2, c);
41 _fmpz_vec_set(num, num2, 2);
42 _fmpq_poly_canonicalise(num, den, 2);
43
44 } else
45 {
46 fmpq_poly_scalar_div_si(NF_ELEM(a), NF_ELEM(b), c);
47 }
48
49 }
50