summaryrefslogtreecommitdiff
path: root/tests/tpl_mpc.c
blob: 395d737cee5d3be0969e928c38f81a1d430fb05d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* tpl_mpc.c -- Helper functions for mpc data.

Copyright (C) 2012, 2013 INRIA

This file is part of GNU MPC.

GNU MPC is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see http://www.gnu.org/licenses/ .
*/

#include "mpc-tests.h"

void
tpl_read_mpc_rnd (mpc_datafile_context_t* datafile_context, mpc_rnd_t* rnd)
{
   mpfr_rnd_t re, im;
   tpl_read_mpfr_rnd (datafile_context, &re);
   tpl_read_mpfr_rnd (datafile_context, &im);
   *rnd = MPC_RND (re, im);
}

void
tpl_read_mpc (mpc_datafile_context_t* datafile_context, mpc_data_t* z)
{
  tpl_read_mpfr (datafile_context, mpc_realref (z->mpc), &z->known_sign_real);
  tpl_read_mpfr (datafile_context, mpc_imagref (z->mpc), &z->known_sign_imag);
}

void
tpl_read_mpc_inex (mpc_datafile_context_t* datafile_context,
                   mpc_inex_data_t *ternarypair)
{
  tpl_read_ternary(datafile_context, &ternarypair->real);
  tpl_read_ternary(datafile_context, &ternarypair->imag);
}


void
tpl_copy_mpc (mpc_ptr dest, mpc_srcptr src)
{
  /* source and destination are assumed to be of the same precision , so the
     copy is exact (no rounding) */
  mpc_set (dest, src, MPC_RNDNN);
}

int
tpl_check_mpc_data (mpc_ptr got, mpc_data_t expected)
{
  return tpl_same_mpfr_value (mpc_realref (got),
                              mpc_realref (expected.mpc),
                              expected.known_sign_real)
    && tpl_same_mpfr_value (mpc_imagref (got),
                            mpc_imagref (expected.mpc),
                            expected.known_sign_imag);
}