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("scalar_mul/divexact_ui....");
29     fflush(stdout);
30 
31     for (i = 0; i < 100 * flint_test_multiplier(); i++)
32     {
33         fmpz_mat_t C, B, A;
34         slong rows, cols;
35         ulong c;
36 
37         rows = n_randint(state, 10);
38         cols = n_randint(state, 10);
39 
40         fmpz_mat_init(A, rows, cols);
41         fmpz_mat_init(B, rows, cols);
42         fmpz_mat_init(C, rows, cols);
43 
44         c = n_randtest(state);
45         fmpz_mat_randtest(A, state, 100);
46 
47         fmpz_mat_scalar_mul_ui(B, A, c);
48 
49         if (c == 0)
50         {
51             if (!fmpz_mat_is_zero(B))
52             {
53                 flint_printf("FAIL!\n");
54                 abort();
55             }
56         }
57         else
58         {
59             fmpz_mat_scalar_divexact_ui(C, B, c);
60 
61             if (!fmpz_mat_equal(C, A))
62             {
63                 flint_printf("FAIL!\n");
64                 abort();
65             }
66         }
67 
68         fmpz_mat_clear(A);
69         fmpz_mat_clear(B);
70         fmpz_mat_clear(C);
71     }
72 
73 
74 
75     FLINT_TEST_CLEANUP(state);
76     flint_printf("PASS\n");
77     return 0;
78 }
79