1 /*
2 Copyright (C) 2010 William Hart
3 Copyright (C) 2014 Abhinav Baid
4 Copyright (C) 2015 Elena Sergeicheva
5
6 This file is part of FLINT.
7
8 FLINT is free software: you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License (LGPL) as published
10 by the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version. See <http://www.gnu.org/licenses/>.
12 */
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <gmp.h>
17 #include "flint.h"
18 #include "fmpz_poly.h"
19 #include "fmpz_poly_mat.h"
20 #include "ulong_extras.h"
21
22 int
main(void)23 main(void)
24 {
25 int i;
26 FLINT_TEST_INIT(state);
27
28
29 flint_printf("window_init/clear....");
30 fflush(stdout);
31
32 for (i = 0; i < 100 * flint_test_multiplier(); i++)
33 {
34 fmpz_poly_mat_t a, w;
35 slong j, k, r1, r2, c1, c2, bits;
36 slong rows = n_randint(state, 10);
37 slong cols = n_randint(state, 10);
38 bits = 1 + n_randint(state, 10);
39
40 fmpz_poly_mat_init(a, rows, cols);
41 fmpz_poly_mat_randtest(a, state, n_randint(state, 10) + 1, bits);
42
43 r2 = n_randint(state, rows + 1);
44 c2 = n_randint(state, cols + 1);
45 if (r2)
46 r1 = n_randint(state, r2);
47 else
48 r1 = 0;
49 if (c2)
50 c1 = n_randint(state, c2);
51 else
52 c1 = 0;
53
54 fmpz_poly_mat_window_init(w, a, r1, c1, r2, c2);
55
56 for (j = 0; j < r2 - r1; j++)
57 for (k = 0; k < c2 - c1; k++)
58 fmpz_poly_zero(fmpz_poly_mat_entry(w, j, k));
59
60 fmpz_poly_mat_window_clear(w);
61 fmpz_poly_mat_clear(a);
62 }
63
64 FLINT_TEST_CLEANUP(state);
65 flint_printf("PASS\n");
66 return 0;
67 }
68