-
Notifications
You must be signed in to change notification settings - Fork 254
/
Copy pathvec_sort_pretty.c
42 lines (36 loc) · 1.06 KB
/
vec_sort_pretty.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Copyright (C) 2012 Fredrik Johansson
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "acb.h"
#ifndef __compar_fn_t
#if defined(_MSC_VER)
typedef int(*__compar_fn_t) (const void *, const void *);
#else
typedef int(*__compar_fn_t) (__const void *, __const void *);
#endif
#endif
int acb_cmp_pretty(const acb_t a, const acb_t b)
{
arb_t t, u, v;
int res;
arb_init(t);
arb_sub(t, acb_realref(a), acb_realref(b), MAG_BITS);
res = 0;
if (arb_contains_zero(t))
{
arb_sub(t, acb_imagref(a), acb_imagref(b), MAG_BITS);
}
res = arb_is_positive(t) ? 1 : -1;
arb_clear(t);
return res;
}
void _acb_vec_sort_pretty(acb_ptr vec, slong len)
{
qsort(vec, len, sizeof(acb_struct), (__compar_fn_t) acb_cmp_pretty);
}