1 /*
2 Copyright (C) 2018 Fredrik Johansson
3
4 This file is part of Arb.
5
6 Arb 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 "acb.h"
13
14 void
acb_dot_simple(acb_t res,const acb_t initial,int subtract,acb_srcptr x,slong xstep,acb_srcptr y,slong ystep,slong len,slong prec)15 acb_dot_simple(acb_t res, const acb_t initial, int subtract,
16 acb_srcptr x, slong xstep, acb_srcptr y, slong ystep, slong len, slong prec)
17 {
18 slong i;
19
20 if (len <= 0)
21 {
22 if (initial == NULL)
23 acb_zero(res);
24 else
25 acb_set_round(res, initial, prec);
26 return;
27 }
28
29 if (initial == NULL)
30 {
31 acb_mul(res, x, y, prec);
32 }
33 else
34 {
35 if (subtract)
36 acb_neg(res, initial);
37 else
38 acb_set(res, initial);
39 acb_addmul(res, x, y, prec);
40 }
41
42 for (i = 1; i < len; i++)
43 acb_addmul(res, x + i * xstep, y + i * ystep, prec);
44
45 if (subtract)
46 acb_neg(res, res);
47 }
48