1 /* tmul_i -- test file for mpc_mul_i.
3 Copyright (C) 2008, 2009, 2010, 2011 INRIA
5 This file is part of GNU MPC.
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.
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
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/ .
21 #include "mpc-tests.h"
24 check_different_precisions(void)
26 /* check reuse when real and imaginary part have different precisions. */
27 mpc_t z, expected, got;
31 mpc_init2(expected, 128);
34 /* change precision of one part */
35 mpfr_set_prec (mpc_imagref (z), 32);
36 mpfr_set_prec (mpc_imagref (expected), 32);
37 mpfr_set_prec (mpc_imagref (got), 32);
39 mpfr_set_str (mpc_realref (z), "0x100000000fp-32", 16, GMP_RNDN);
40 mpfr_set_str (mpc_imagref (z), "-1", 2, GMP_RNDN);
41 mpfr_set_str (mpc_realref (expected), "+1", 2, GMP_RNDN);
42 mpfr_set_str (mpc_imagref (expected), "0x100000000fp-32", 16, GMP_RNDN);
44 mpc_set (got, z, MPC_RNDNN);
45 res = mpc_mul_i (got, got, +1, MPC_RNDNN);
46 if (MPC_INEX_RE(res) != 0 || MPC_INEX_IM(res) >=0)
48 printf("Wrong inexact flag for mpc_mul_i(z, z, n)\n"
49 " got (re=%2d, im=%2d)\nexpected (re= 0, im=-1)\n",
50 MPC_INEX_RE(res), MPC_INEX_IM(res));
53 if (mpc_cmp(got, expected) != 0)
55 printf ("Error for mpc_mul_i(z, z, n) for\n");
64 mpc_neg (expected, expected, MPC_RNDNN);
65 mpc_set (got, z, MPC_RNDNN);
66 mpc_mul_i (got, got, -1, MPC_RNDNN);
67 if (mpc_cmp(got, expected) != 0)
69 printf ("Error for mpc_mul_i(z, z, n) for\n");
86 DECL_FUNC (CCI, f, mpc_mul_i);
90 check_different_precisions ();
91 tgeneric (f, 2, 1024, 7, -1);