Home | History | Annotate | Line # | Download | only in tests
      1 /* setprec_parameters.c -- Functions changing the precision of i/o parameters.
      2 
      3 Copyright (C) 2013 INRIA
      4 
      5 This file is part of GNU MPC.
      6 
      7 GNU MPC is free software; you can redistribute it and/or modify it under
      8 the terms of the GNU Lesser General Public License as published by the
      9 Free Software Foundation; either version 3 of the License, or (at your
     10 option) any later version.
     11 
     12 GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
     13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
     15 more details.
     16 
     17 You should have received a copy of the GNU Lesser General Public License
     18 along with this program. If not, see http://www.gnu.org/licenses/ .
     19 */
     20 
     21 #include "mpc-tests.h"
     22 
     23 void
     24 set_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 
     38 void
     39 set_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 
     53 void
     54 set_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