Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a more reasonable sorting of complex numbers #2033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
a more reasonable sorting of complex numbers
edgarcosta committed Jul 10, 2024
commit 2d95a8aa87b0133e84511ddb81543861f403b7f8
16 changes: 3 additions & 13 deletions src/acb/vec_sort_pretty.c
Original file line number Diff line number Diff line change
@@ -25,24 +25,14 @@ int acb_cmp_pretty(const acb_t a, const acb_t b)
arb_t t, u, v;
int res;
arb_init(t);
arb_init(u);
arb_init(v);
arb_abs(u, acb_imagref(a));
arb_abs(v, acb_imagref(b));
arb_sub(t, u, v, MAG_BITS);
arb_sub(t, acb_realref(a), acb_realref(b), MAG_BITS);
res = 0;
if (arb_contains_zero(t))
{
arb_sub(t, acb_realref(a), acb_realref(b), MAG_BITS);
res = arb_is_positive(t) ? 1 : -1;
}
else
{
res = arb_is_positive(t) ? 1 : -1;
arb_sub(t, acb_imagref(a), acb_imagref(b), MAG_BITS);
}
res = arb_is_positive(t) ? 1 : -1;
arb_clear(t);
arb_clear(u);
arb_clear(v);
return res;
}