1 /*
2     Copyright (C) 2010 William Hart
3     Copyright (C) 2010 Fredrik Johansson
4     Copyright (C) 2014 Abhinav Baid
5 
6     This file is part of FLINT.
7 
8     FLINT is free software: you can redistribute it and/or modify it under
9     the terms of the GNU Lesser General Public License (LGPL) as published
10     by the Free Software Foundation; either version 2.1 of the License, or
11     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
12 */
13 
14 #include "mpf_vec.h"
15 
16 void
_mpf_vec_norm2(mpf_t res,const mpf * vec,slong len,flint_bitcnt_t prec)17 _mpf_vec_norm2(mpf_t res, const mpf * vec, slong len, flint_bitcnt_t prec)
18 {
19     slong i;
20     mpf_t tmp;
21     mpf_init2(tmp, prec);
22 
23     flint_mpf_set_ui(res, 0);
24     for (i = 0; i < len; i++)
25     {
26         mpf_mul(tmp, vec + i, vec + i);
27         mpf_add(res, res, tmp);
28     }
29 
30     mpf_clear(tmp);
31 }
32