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