1 /*
2     Copyright (C) 2014 Abhinav Baid
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 "mpf_vec.h"
17 #include "ulong_extras.h"
18 
19 int
main(void)20 main(void)
21 {
22     int i, result;
23     FLINT_TEST_INIT(state);
24 
25     flint_printf("dot2....");
26     fflush(stdout);
27 
28 
29     for (i = 0; i < 10000 * flint_test_multiplier(); i++)
30     {
31         mpf *a, *b;
32         mpf_t res1, res2, res3;
33         slong len = n_randint(state, 100);
34         if (!len)
35             continue;
36 
37         a = _mpf_vec_init(len, 200);
38         b = _mpf_vec_init(len, 200);
39         _mpf_vec_randtest(a, state, len, 200);
40         _mpf_vec_randtest(b, state, len, 200);
41 
42         mpf_inits(res1, res2, res3, NULL);
43         _mpf_vec_dot2(res1, a, b, len - 1, 200);
44         _mpf_vec_dot2(res2, a + len - 1, b + len - 1, 1, 200);
45         _mpf_vec_dot2(res3, a, b, len, 200);
46 
47         mpf_add(res1, res1, res2);
48         result = mpf_cmp(res1, res3);
49         if (result)
50         {
51             flint_printf("FAIL:\n");
52             flint_printf("%d\n", len);
53             mpf_out_str(stdout, 10, 0, res1);
54             flint_printf("\n");
55             mpf_out_str(stdout, 10, 0, res3);
56             flint_printf("\n");
57             abort();
58         }
59 
60         _mpf_vec_clear(a, len);
61         _mpf_vec_clear(b, len);
62         mpf_clears(res1, res2, res3, NULL);
63     }
64 
65     FLINT_TEST_CLEANUP(state);
66 
67     flint_printf("PASS\n");
68     return 0;
69 }
70