1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Copyright (C) 2025 Fredrik Johansson
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include "arf.h"
int
arf_dot(arf_t res, const arf_t initial, int subtract,
arf_srcptr x, slong xstep, arf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd)
{
arf_ptr A;
slong i;
int inexact;
if (len <= 0)
{
if (initial == NULL)
{
arf_zero(res);
return 0;
}
return arf_set_round(res, initial, prec, rnd);
}
A = _arf_vec_init(len + (initial != NULL));
for (i = 0; i < len; i++)
{
arf_mul(A + i, x + i * xstep, y + i * ystep, ARF_PREC_EXACT, ARF_RND_DOWN);
if (subtract)
arf_neg(A + i, A + i);
}
if (initial != NULL)
arf_set(A + len, initial);
inexact = arf_sum(res, A, len + (initial != NULL), prec, rnd);
_arf_vec_clear(A, len + (initial != NULL));
return inexact;
}