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 <http://www.gnu.org/licenses/>.
10 */
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include "flint.h"
15 #include "fmpz_poly.h"
16 #include "fmpz_poly_mat.h"
17 
18 
19 int
main(void)20 main(void)
21 {
22     slong i;
23 
24     FLINT_TEST_INIT(state);
25 
26     flint_printf("det_interpolate....");
27     fflush(stdout);
28 
29     for (i = 0; i < 100 * flint_test_multiplier(); i++)
30     {
31         fmpz_poly_mat_t A;
32         fmpz_poly_t a, b;
33         slong n, bits, deg;
34 
35         n = n_randint(state, 10);
36         deg = 1 + n_randint(state, 5);
37         bits = 1 + n_randint(state, 100);
38 
39         fmpz_poly_mat_init(A, n, n);
40 
41         fmpz_poly_init(a);
42         fmpz_poly_init(b);
43 
44         fmpz_poly_mat_randtest(A, state, deg, bits);
45 
46         fmpz_poly_mat_det(a, A);
47         fmpz_poly_mat_det_interpolate(b, A);
48 
49         if (!fmpz_poly_equal(a, b))
50         {
51             flint_printf("FAIL:\n");
52             flint_printf("determinants don't agree!\n");
53             flint_printf("A:\n");
54             fmpz_poly_mat_print(A, "x");
55             flint_printf("det(A):\n");
56             fmpz_poly_print_pretty(a, "x");
57             flint_printf("\ndet_interpolate(A):\n");
58             fmpz_poly_print_pretty(b, "x");
59             flint_printf("\n");
60             abort();
61         }
62 
63         fmpz_poly_clear(a);
64         fmpz_poly_clear(b);
65 
66         fmpz_poly_mat_clear(A);
67     }
68 
69     FLINT_TEST_CLEANUP(state);
70 
71     flint_printf("PASS\n");
72     return 0;
73 }
74