1 /*
2 Copyright (C) 2011 Fredrik Johansson
3
4 This file is part of FLINT.
5
6 FLINT is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License (LGPL) as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version. See <https://www.gnu.org/licenses/>.
10 */
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include "flint.h"
15 #include "fmpz.h"
16 #include "fmpz_mat.h"
17 #include "fmpz_poly.h"
18 #include "fmpz_poly_mat.h"
19
20 int
main(void)21 main(void)
22 {
23 int iter;
24
25 FLINT_TEST_INIT(state);
26
27 flint_printf("one/is_one....");
28 fflush(stdout);
29
30 for (iter = 0; iter < 100 * flint_test_multiplier(); iter++)
31 {
32 fmpz_poly_mat_t A;
33 slong m, n;
34
35 m = n_randint(state, 10);
36 n = n_randint(state, 10);
37
38 fmpz_poly_mat_init(A, m, n);
39 fmpz_poly_mat_randtest(A, state, n_randint(state, 5),
40 n_randint(state, 100));
41 fmpz_poly_mat_one(A);
42
43 if (!fmpz_poly_mat_is_one(A))
44 {
45 flint_printf("FAIL: expected matrix to be one\n");
46 abort();
47 }
48
49 if (m > 0 && n > 0)
50 {
51 m = n_randint(state, m);
52 n = n_randint(state, n);
53
54 if (m != n)
55 fmpz_poly_randtest_not_zero(fmpz_poly_mat_entry(A, m, n),
56 state, 5, 5);
57 else
58 do { fmpz_poly_randtest_not_zero(fmpz_poly_mat_entry(A, m, n),
59 state, 5, 5); }
60 while (fmpz_poly_is_one(fmpz_poly_mat_entry(A, m, n)));
61
62 if (fmpz_poly_mat_is_one(A))
63 {
64 flint_printf("FAIL: expected matrix not to be one\n");
65 abort();
66 }
67 }
68
69 fmpz_poly_mat_clear(A);
70 }
71
72 FLINT_TEST_CLEANUP(state);
73
74 flint_printf("PASS\n");
75 return 0;
76 }
77