1 /* tpl_mpc.c -- Helper functions for mpc data. 2 3 Copyright (C) 2012, 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 tpl_read_mpc_rnd (mpc_datafile_context_t* datafile_context, mpc_rnd_t* rnd) 25 { 26 mpfr_rnd_t re, im; 27 tpl_read_mpfr_rnd (datafile_context, &re); 28 tpl_read_mpfr_rnd (datafile_context, &im); 29 *rnd = MPC_RND (re, im); 30 } 31 32 void 33 tpl_read_mpc (mpc_datafile_context_t* datafile_context, mpc_data_t* z) 34 { 35 tpl_read_mpfr (datafile_context, mpc_realref (z->mpc), &z->known_sign_real); 36 tpl_read_mpfr (datafile_context, mpc_imagref (z->mpc), &z->known_sign_imag); 37 } 38 39 void 40 tpl_read_mpc_inex (mpc_datafile_context_t* datafile_context, 41 mpc_inex_data_t *ternarypair) 42 { 43 tpl_read_ternary(datafile_context, &ternarypair->real); 44 tpl_read_ternary(datafile_context, &ternarypair->imag); 45 } 46 47 48 void 49 tpl_copy_mpc (mpc_ptr dest, mpc_srcptr src) 50 { 51 /* source and destination are assumed to be of the same precision , so the 52 copy is exact (no rounding) */ 53 mpc_set (dest, src, MPC_RNDNN); 54 } 55 56 int 57 tpl_check_mpc_data (mpc_ptr got, mpc_data_t expected) 58 { 59 return tpl_same_mpfr_value (mpc_realref (got), 60 mpc_realref (expected.mpc), 61 expected.known_sign_real) 62 && tpl_same_mpfr_value (mpc_imagref (got), 63 mpc_imagref (expected.mpc), 64 expected.known_sign_imag); 65 } 66