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 "nmod_mat.h"
19 #include "ulong_extras.h"
20 
21 int
main(void)22 main(void)
23 {
24     int i;
25     FLINT_TEST_INIT(state);
26 
27 
28     flint_printf("get/set_nmod_mat....");
29     fflush(stdout);
30 
31     for (i = 0; i < 1000 * flint_test_multiplier(); i++)
32     {
33         fmpz_mat_t A;
34         nmod_mat_t M, M2;
35         slong rows, cols;
36         mp_limb_t mod;
37 
38         rows = n_randint(state, 50);
39         cols = n_randint(state, 50);
40 
41         mod = n_randtest_prime(state, 0);
42 
43         nmod_mat_init(M, rows, cols, mod);
44         nmod_mat_init(M2, rows, cols, mod);
45         fmpz_mat_init(A, rows, cols);
46 
47         nmod_mat_randtest(M, state);
48 
49         if (i % 2 == 0)
50             fmpz_mat_set_nmod_mat(A, M);
51         else
52             fmpz_mat_set_nmod_mat_unsigned(A, M);
53 
54         fmpz_mat_scalar_mul_ui(A, A, UWORD(2));
55         nmod_mat_add(M, M, M);
56         fmpz_mat_get_nmod_mat(M2, A);
57 
58         if (!nmod_mat_equal(M, M2))
59         {
60             flint_printf("FAIL!\n");
61             abort();
62         }
63 
64         fmpz_mat_clear(A);
65         nmod_mat_clear(M);
66         nmod_mat_clear(M2);
67     }
68 
69     FLINT_TEST_CLEANUP(state);
70 
71     flint_printf("PASS\n");
72     return 0;
73 }
74