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 <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     slong m, n, rep;
24     FLINT_TEST_INIT(state);
25 
26     flint_printf("add/sub/neg....");
27     fflush(stdout);
28 
29 
30 
31     for (rep = 0; rep < 1000 * flint_test_multiplier(); rep++)
32     {
33         fmpz_mat_t A;
34         fmpz_mat_t B;
35         fmpz_mat_t C;
36 
37         m = n_randint(state, 20);
38         n = n_randint(state, 20);
39 
40         fmpz_mat_init(A, m, n);
41         fmpz_mat_init(B, m, n);
42         fmpz_mat_init(C, m, n);
43 
44         fmpz_mat_randtest(A, state, 100);
45         fmpz_mat_randtest(B, state, 100);
46 
47         fmpz_mat_neg(C, A);
48         fmpz_mat_add(A, A, B);
49         fmpz_mat_sub(A, A, B);
50         fmpz_mat_neg(A, A);
51 
52         if (!fmpz_mat_equal(A, C))
53         {
54             flint_printf("FAIL: matrices not equal!\n");
55             abort();
56         }
57 
58         fmpz_mat_clear(A);
59         fmpz_mat_clear(B);
60         fmpz_mat_clear(C);
61     }
62 
63     FLINT_TEST_CLEANUP(state);
64 
65     flint_printf("PASS\n");
66     return 0;
67 }
68