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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Copyright (C) 2018 Daniel Schultz
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 "test_helpers.h"
#include "fmpq_mpoly.h"
TEST_FUNCTION_START(fmpq_mpoly_content, state)
{
slong i, j, k;
/* Check content is gcd of coefficients */
for (i = 0; i < 50 * flint_test_multiplier(); i++)
{
fmpq_mpoly_ctx_t ctx;
fmpq_mpoly_t f;
fmpq_t g1, g2, t;
slong len;
flint_bitcnt_t coeff_bits, exp_bits;
fmpq_mpoly_ctx_init_rand(ctx, state, 20);
fmpq_mpoly_init(f, ctx);
fmpq_init(g1);
fmpq_init(g2);
fmpq_init(t);
len = n_randint(state, 50);
exp_bits = n_randint(state, 200) + 2;
coeff_bits = n_randint(state, 100);
for (j = 0; j < 10; j++)
{
fmpq_mpoly_randtest_bits(f, state, len, coeff_bits, exp_bits, ctx);
fmpq_zero(g1);
for (k = 0; k < fmpq_mpoly_length(f, ctx); k++)
{
fmpq_mpoly_get_term_coeff_fmpq(t, f, k, ctx);
fmpq_gcd(g1, g1, t);
}
fmpq_mpoly_content(g2, f, ctx);
if (!fmpq_equal(g1, g2))
{
printf("FAIL\n");
flint_printf("Check content\ni = %wd, j = %wd\n", i, j);
fflush(stdout);
flint_abort();
}
}
fmpq_clear(g1);
fmpq_clear(g2);
fmpq_clear(t);
fmpq_mpoly_clear(f, ctx);
fmpq_mpoly_ctx_clear(ctx);
}
TEST_FUNCTION_END(state);
}