1/* init_parameters -- Allocate memory for function parameters. 2 3Copyright (C) 2012, 2014 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 <stdio.h> 22#include "mpc-tests.h" 23 24static void 25init_param (mpc_operand_t* p, mpc_param_t t) 26{ 27 switch (t) 28 { 29 case NATIVE_INT: 30 case NATIVE_UL: 31 case NATIVE_L: 32 case NATIVE_D: 33 break; 34 35 case GMP_Z: 36 mpz_init (p->mpz); 37 break; 38 case GMP_Q: 39 mpq_init (p->mpq); 40 break; 41 case GMP_F: 42 mpf_init (p->mpf); 43 break; 44 45 case MPFR_INEX: 46 break; 47 case MPFR: 48 mpfr_init2 (p->mpfr, 512); 49 break; 50 51 case MPC_INEX: 52 case MPCC_INEX: 53 break; 54 case MPC: 55 mpc_init2 (p->mpc, 512); 56 break; 57 58 case MPFR_RND: 59 case MPC_RND: 60 break; 61 62 default: 63 fprintf (stderr, "init_parameters: unsupported type.\n"); 64 exit (1); 65 } 66} 67 68void 69init_parameters (mpc_fun_param_t *params) 70{ 71 int in, out; 72 int total = params->nbout + params->nbin; 73 74 for (out = 0; out < params->nbout; out++) 75 { 76 init_param (&(params->P[out]), params->T[out]); 77 init_param (&(params->P[total + out]), params->T[total + out]); 78 } 79 80 for (in = params->nbout; in < total; in++) 81 { 82 init_param (&(params->P[in]), params->T[in]); 83 } 84} 85