|
1 | | -/*============================================================================ |
| 1 | +/*============================================================================= |
2 | 2 |
|
3 | 3 | This file is part of FLINT. |
4 | 4 |
|
|
16 | 16 | along with FLINT; if not, write to the Free Software |
17 | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | 18 |
|
19 | | -===============================================================================*/ |
20 | | -/**************************************************************************** |
| 19 | +=============================================================================*/ |
| 20 | +/****************************************************************************** |
21 | 21 |
|
22 | | - Copyright (C) 2010 William Hart |
23 | | - |
24 | | -*****************************************************************************/ |
| 22 | + Copyright (C) 2010 William Hart |
| 23 | +
|
| 24 | +******************************************************************************/ |
25 | 25 |
|
26 | 26 | #include <stdlib.h> |
27 | 27 | #include <mpir.h> |
28 | 28 | #include <mpfr.h> |
29 | 29 | #include "flint.h" |
30 | 30 | #include "mpfr_vec.h" |
31 | 31 |
|
32 | | -void * _mpfr_vec_scalar_product(mpfr_t res, __mpfr_struct * vec1, __mpfr_struct * vec2, long length) |
| 32 | +void _mpfr_vec_scalar_product(mpfr_t res, __mpfr_struct * vec1, __mpfr_struct * vec2, long length) |
33 | 33 | { |
34 | | - long i; |
35 | | - |
36 | | - mpfr_t tmp; |
37 | | - mpfr_init(tmp); |
38 | | - |
39 | | - mpfr_mul(res, vec1, vec2, GMP_RNDN); |
40 | | - for (i = 1; i < length; i++) |
41 | | - { |
42 | | - mpfr_mul(tmp, vec1 + i, vec2 + i, GMP_RNDN); |
43 | | - mpfr_add(res, res, tmp, GMP_RNDN); |
44 | | - } |
| 34 | + long i; |
| 35 | + mpfr_t tmp; |
| 36 | + mpfr_init(tmp); |
| 37 | + |
| 38 | + mpfr_mul(res, vec1, vec2, GMP_RNDN); |
| 39 | + for (i = 1; i < length; i++) |
| 40 | + { |
| 41 | + mpfr_mul(tmp, vec1 + i, vec2 + i, GMP_RNDN); |
| 42 | + mpfr_add(res, res, tmp, GMP_RNDN); |
| 43 | + } |
45 | 44 |
|
46 | 45 | mpfr_clear(tmp); |
47 | 46 | } |
|
0 commit comments