1/* setprec_parameters.c -- Functions changing the precision of i/o parameters.
2
3Copyright (C) 2013 INRIA
4
5This file is part of GNU MPC.
6
7GNU MPC is free software; you can redistribute it and/or modify it under
8the terms of the GNU Lesser General Public License as published by the
9Free Software Foundation; either version 3 of the License, or (at your
10option) any later version.
11
12GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15more details.
16
17You should have received a copy of the GNU Lesser General Public License
18along with this program. If not, see http://www.gnu.org/licenses/ .
19*/
20
21#include "mpc-tests.h"
22
23void
24set_output_precision (mpc_fun_param_t *params, mpfr_prec_t prec)
25{
26  int out;
27  const int start = 0;
28  const int end = params->nbout;
29  for (out = start; out < end; out++)
30    {
31      if (params->T[out] == MPFR)
32        mpfr_set_prec (params->P[out].mpfr, prec);
33      else if (params->T[out] == MPC)
34        mpc_set_prec (params->P[out].mpc, prec);
35    }
36}
37
38void
39set_input_precision  (mpc_fun_param_t *params, mpfr_prec_t prec)
40{
41  int i;
42  const int start = params->nbout;
43  const int end = start + params->nbin;
44  for (i = start; i < end; i++)
45    {
46      if (params->T[i] == MPFR)
47        mpfr_set_prec (params->P[i].mpfr, prec);
48      else if (params->T[i] == MPC)
49        mpc_set_prec (params->P[i].mpc, prec);
50    }
51}
52
53void
54set_reference_precision (mpc_fun_param_t *params, mpfr_prec_t prec)
55{
56  int i;
57  const int start = params->nbout + params->nbin;
58  const int end = start + params->nbout;
59  for (i = start; i < end; i++)
60    {
61      if (params->T[i] == MPFR)
62        mpfr_set_prec (params->P[i].mpfr_data.mpfr, prec);
63      else if (params->T[i] == MPC)
64        mpc_set_prec (params->P[i].mpc_data.mpc, prec);
65    }
66}
67