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 #include "long_extras.h"
21 
22 int
main(void)23 main(void)
24 {
25     int i;
26     FLINT_TEST_INIT(state);
27 
28 
29     flint_printf("scalar_add/submul_nmod_mat_ui....");
30     fflush(stdout);
31 
32     for (i = 0; i < 100 * flint_test_multiplier(); i++)
33     {
34         fmpz_mat_t A, B, C;
35         nmod_mat_t M;
36         slong rows, cols;
37         ulong c;
38         ulong mod;
39 
40         rows = n_randint(state, 10);
41         cols = n_randint(state, 10);
42         mod = n_randtest_prime(state, 0);
43 
44         fmpz_mat_init(A, rows, cols);
45         fmpz_mat_init(B, rows, cols);
46         fmpz_mat_init(C, rows, cols);
47         nmod_mat_init(M, rows, cols, mod);
48         c = n_randtest(state);
49 
50         nmod_mat_randtest(M, state);
51         fmpz_mat_set_nmod_mat_unsigned(A, M);
52 
53         fmpz_mat_randtest(B, state, 100);
54         fmpz_mat_set(C, B);
55 
56         fmpz_mat_scalar_addmul_nmod_mat_ui(B, M, c);
57         fmpz_mat_scalar_addmul_ui(C, A, c);
58 
59         if (!fmpz_mat_equal(B, C))
60         {
61             flint_printf("FAIL!\n");
62             abort();
63         }
64 
65         fmpz_mat_clear(A);
66         fmpz_mat_clear(B);
67         fmpz_mat_clear(C);
68         nmod_mat_clear(M);
69     }
70 
71 
72 
73     FLINT_TEST_CLEANUP(state);
74     flint_printf("PASS\n");
75     return 0;
76 }
77