1 /*
2     Copyright (C) 2015 Anubhav Srivastava
3     Copyright (C) 2015 Elena Sergeicheva
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 <http://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_poly.h"
18 #include "fmpz_poly_mat.h"
19 #include "ulong_extras.h"
20 
main(void)21 int main(void)
22 {
23     fmpz_poly_mat_t A, B, C;
24     fmpz_poly_mat_t window1, window2;
25     slong i;
26     FLINT_TEST_INIT(state);
27 
28     flint_printf("concat_vertical....");
29     fflush(stdout);
30 
31 
32 
33     for (i = 0; i < 100 * flint_test_multiplier(); i++)
34     {
35         slong r1, r2, c1, bits;
36 
37         r1 = n_randint(state, 10);
38         r2 = n_randint(state, 10);
39         c1 = n_randint(state, 10);
40         bits = 1 + n_randint(state, 20);
41 
42         fmpz_poly_mat_init(A, r1, c1);
43         fmpz_poly_mat_init(B, r2, c1);
44         fmpz_poly_mat_init(C, (r1 + r2), c1);
45 
46         fmpz_poly_mat_randtest(A, state, n_randint(state, 10) + 1, bits);
47         fmpz_poly_mat_randtest(B, state, n_randint(state, 10) + 1, bits);
48 
49         fmpz_poly_mat_randtest(C, state, n_randint(state, 10) + 1, bits);
50 
51         fmpz_poly_mat_concat_vertical(C, A, B);
52 
53         fmpz_poly_mat_window_init(window1, C, 0, 0, r1, c1);
54         fmpz_poly_mat_window_init(window2, C, r1, 0, (r1 + r2), c1);
55 
56 
57         if (!(fmpz_poly_mat_equal(window1, A) && fmpz_poly_mat_equal(window2, B)))
58         {
59             flint_printf("FAIL: results not equal\n");
60             abort();
61         }
62 
63         fmpz_poly_mat_clear(A);
64         fmpz_poly_mat_clear(B);
65         fmpz_poly_mat_clear(C);
66 
67         fmpz_poly_mat_window_clear(window1);
68         fmpz_poly_mat_window_clear(window2);
69     }
70 
71     FLINT_TEST_CLEANUP(state);
72 
73     flint_printf("PASS\n");
74     return 0;
75 }
76