1 /*
2     Copyright (C) 2010 William Hart
3     Copyright (C) 2014 Abhinav Baid
4 
5     This file is part of FLINT.
6 
7     FLINT is free software: you can redistribute it and/or modify it under
8     the terms of the GNU Lesser General Public License (LGPL) as published
9     by the Free Software Foundation; either version 2.1 of the License, or
10     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
11 */
12 
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <gmp.h>
16 #include "flint.h"
17 #include "fmpz.h"
18 #include "fmpz_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("window_init/clear....");
29     fflush(stdout);
30 
31     for (i = 0; i < 1000 * flint_test_multiplier(); i++)
32     {
33         fmpz_mat_t a, w;
34         slong j, k, r1, r2, c1, c2;
35         slong rows = n_randint(state, 10);
36         slong cols = n_randint(state, 10);
37 
38         fmpz_mat_init(a, rows, cols);
39         fmpz_mat_randtest(a, state, n_randint(state, 200) + 1);
40 
41         r2 = n_randint(state, rows + 1);
42         c2 = n_randint(state, cols + 1);
43         if (r2)
44             r1 = n_randint(state, r2);
45         else
46             r1 = 0;
47         if (c2)
48             c1 = n_randint(state, c2);
49         else
50             c1 = 0;
51 
52         fmpz_mat_window_init(w, a, r1, c1, r2, c2);
53 
54         for (j = 0; j < r2 - r1; j++)
55             for (k = 0; k < c2 - c1; k++)
56                 fmpz_zero(fmpz_mat_entry(w, j, k));
57 
58         fmpz_mat_window_clear(w);
59         fmpz_mat_clear(a);
60     }
61 
62 
63 
64     FLINT_TEST_CLEANUP(state);
65     flint_printf("PASS\n");
66     return 0;
67 }
68