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) 2012 William Hart
14 
15 ******************************************************************************/
16 
17 #include <stdlib.h>
18 #include <gmp.h>
19 #include "flint/flint.h"
20 #include "flint/ulong_extras.h"
21 #include "flint/fmpz.h"
22 #include "qfb.h"
23 
qfb_is_reduced(qfb_t r)24 int qfb_is_reduced(qfb_t r)
25 {
26    if (fmpz_cmp(r->c, r->a) < 0)
27       return 0;
28 
29    if (fmpz_cmpabs(r->b, r->a) > 0)
30       return 0;
31 
32    if (fmpz_cmpabs(r->a, r->b) == 0 || fmpz_cmp(r->a, r->c) == 0)
33       if (fmpz_sgn(r->b) < 0)
34          return 0;
35 
36    return 1;
37 }
38