1 /*
2     Copyright (C) 2011 Fredrik Johansson
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 <math.h>
14 #include "fmpz_vec.h"
15 
16 slong
_fmpz_vec_get_d_vec_2exp(double * appv,const fmpz * vec,slong len)17 _fmpz_vec_get_d_vec_2exp(double *appv, const fmpz * vec, slong len)
18 {
19     slong *exp, i, maxexp = 0L;
20     exp = (slong *) flint_malloc(len * sizeof(slong));
21 
22     for (i = 0; i < len; i++)
23     {
24         appv[i] = fmpz_get_d_2exp(&exp[i], vec + i);
25         if (exp[i] > maxexp)
26             maxexp = exp[i];
27     }
28 
29     for (i = 0; i < len; i++)
30         appv[i] = ldexp(appv[i], exp[i] - maxexp);
31 
32     flint_free(exp);
33     return maxexp;
34 }
35