1 /*
2     Copyright (C) 2010 William Hart
3     Copyright (C) 2011 Fredrik Johansson
4     Copyright (C) 2014 Abhinav Baid
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 <https://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.h"
19 #include "fmpz_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("get_mpf_mat....");
30     fflush(stdout);
31 
32     /* set entries of an fmpz_mat, convert to mpf_mat and then check that
33        the entries remain same */
34     for (i = 0; i < 1000 * flint_test_multiplier(); i++)
35     {
36         fmpz_mat_t A;
37         mpf_mat_t B;
38         slong j, k;
39         slong rows = n_randint(state, 10);
40         slong cols = n_randint(state, 10);
41 
42         fmpz_mat_init(A, rows, cols);
43         mpf_mat_init(B, rows, cols, mpf_get_default_prec());
44 
45         for (j = 0; j < rows; j++)
46         {
47             for (k = 0; k < cols; k++)
48             {
49                 fmpz_set_ui(fmpz_mat_entry(A, j, k), 3 * j + 7 * k);
50             }
51         }
52 
53         fmpz_mat_get_mpf_mat(B, A);
54 
55         for (j = 0; j < rows; j++)
56         {
57             for (k = 0; k < cols; k++)
58             {
59                 if (flint_mpf_cmp_ui(mpf_mat_entry(B, j, k), 3 * j + 7 * k) != 0)
60                 {
61                     flint_printf("FAIL: j = %wd, k = %wd\n", j, k);
62                     fmpz_mat_print_pretty(A);
63                     mpf_mat_print(B);
64                     abort();
65                 }
66             }
67         }
68 
69         fmpz_mat_clear(A);
70         mpf_mat_clear(B);
71     }
72 
73 
74 
75     FLINT_TEST_CLEANUP(state);
76     flint_printf("PASS\n");
77     return 0;
78 }
79