1 /*
2     Copyright (C) 2010 William Hart
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 <gmp.h>
15 #include "flint.h"
16 #include "fmpz.h"
17 #include "fmpz_mat.h"
18 #include "ulong_extras.h"
19 
20 int
main(void)21 main(void)
22 {
23     int i;
24     FLINT_TEST_INIT(state);
25 
26     flint_printf("equal....");
27     fflush(stdout);
28 
29 
30 
31     for (i = 0; i < 1000 * flint_test_multiplier(); i++)
32     {
33         fmpz_mat_t A, B, C, D, E;
34         slong m, n, j;
35 
36         m = n_randint(state, 20);
37         n = n_randint(state, 20);
38 
39         fmpz_mat_init(A, m, n);
40         fmpz_mat_init(B, m, n);
41         fmpz_mat_init(C, m, n);
42         fmpz_mat_init(D, m+1, n);
43         fmpz_mat_init(E, m, n+1);
44 
45         if (fmpz_mat_equal(A, D) || fmpz_mat_equal(A, E))
46         {
47             flint_printf("FAIL: different dimensions should not be equal\n");
48             abort();
49         }
50 
51         fmpz_mat_randtest(A, state, 1 + n_randint(state, 100));
52         fmpz_mat_set(B, A);
53 
54         if (!fmpz_mat_equal(A, B))
55         {
56             flint_printf("FAIL: copied matrices should be equal\n");
57             abort();
58         }
59 
60         if (m && n)
61         {
62             j = n_randint(state, m*n);
63             fmpz_add_ui(A->entries + j, A->entries + j, 1);
64 
65             if (fmpz_mat_equal(A, B))
66             {
67                 flint_printf("FAIL: modified matrices should not be equal\n");
68                 abort();
69             }
70         }
71 
72         fmpz_mat_clear(A);
73         fmpz_mat_clear(B);
74         fmpz_mat_clear(C);
75         fmpz_mat_clear(D);
76         fmpz_mat_clear(E);
77     }
78 
79     FLINT_TEST_CLEANUP(state);
80 
81     flint_printf("PASS\n");
82     return 0;
83 }
84