1 /*
2     Copyright (C) 2009, 2011 William Hart
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 <https://www.gnu.org/licenses/>.
10 */
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <gmp.h>
15 #include "flint.h"
16 #include "ulong_extras.h"
17 #include "fft.h"
18 
19 int
main(void)20 main(void)
21 {
22     flint_bitcnt_t depth, w;
23     mp_size_t iters, j;
24     double truncation;
25 
26     FLINT_TEST_INIT(state);
27 
28     flint_printf("mul_truncate_sqrt2....");
29     fflush(stdout);
30 
31 
32     _flint_rand_init_gmp(state);
33 
34     depth = 13;
35     w = 1;
36     iters = 1;
37     truncation = 1.0;
38 
39     {
40        mp_size_t n = (UWORD(1)<<depth);
41        flint_bitcnt_t bits1 = (n*w - (depth + 1))/2;
42        flint_bitcnt_t bits = 2*n*bits1;
43        mp_size_t int_limbs = ((mp_size_t)(truncation*bits))/FLINT_BITS;
44        mp_size_t j;
45        mp_limb_t * i1, *i2, *r1, *r2;
46 
47        flint_printf("limbs = %wd\n", int_limbs);
48 
49        i1 = flint_malloc(6*int_limbs*sizeof(mp_limb_t));
50        i2 = i1 + int_limbs;
51        r1 = i2 + int_limbs;
52        r2 = r1 + 2*int_limbs;
53 
54        flint_mpn_urandomb(i1, state->gmp_state, int_limbs*FLINT_BITS);
55        flint_mpn_urandomb(i2, state->gmp_state, int_limbs*FLINT_BITS);
56 
57        //mpn_mul(r2, i1, int_limbs, i2, int_limbs);
58        for (j = 0; j < iters; j++)
59           mul_truncate_sqrt2(r1, i1, int_limbs, i2, int_limbs, depth, w);
60 
61        flint_free(i1);
62     }
63 
64     flint_randclear(state);
65 
66     flint_printf("done\n");
67     return 0;
68 }
69