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) 2023 Mathieu Gouttenoire
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 "fmpzi.h"
int
fmpzi_is_probabprime(const fmpzi_t n)
{
fmpz_t t;
const fmpz *a, *b;
int res = 0;
fmpz_init(t);
a = fmpzi_realref(n);
b = fmpzi_imagref(n);
if (fmpz_is_zero(b)) {
if (fmpz_tdiv_ui(a, 4) == 3)
fmpz_abs(t, a);
} else if (fmpz_is_zero(a)) {
if (fmpz_tdiv_ui(b, 4) == 3)
fmpz_abs(t, b);
} else {
fmpzi_norm(t, n);
}
res = fmpz_is_probabprime(t);
fmpz_clear(t);
return res;
}