1 /* tdiv -- test file for mpc_div.
3 Copyright (C) 2002, 2008, 2009 Andreas Enge, Paul Zimmermann, Philippe Th\'eveny
5 This file is part of the MPC Library.
7 The MPC Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or (at your
10 option) any later version.
12 The MPC Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the MPC Library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
23 #include "mpc-tests.h"
36 mpc_set_ui_ui (b, 973, 964, MPC_RNDNN);
37 mpc_set_ui_ui (c, 725, 745, MPC_RNDNN);
38 inex = mpc_div (q, b, c, MPC_RNDZZ);
39 mpc_set_si_si (b, 43136, -787, MPC_RNDNN);
40 mpc_div_2exp (b, b, 15, MPC_RNDNN);
41 if (mpc_cmp (q, b) || MPC_INEX_RE (inex) == 0 || MPC_INEX_IM (inex) == 0)
43 printf ("mpc_div failed for (973+I*964)/(725+I*745)\n");
48 mpc_set_si_si (b, -837, 637, MPC_RNDNN);
49 mpc_set_si_si (c, 63, -5, MPC_RNDNN);
50 inex = mpc_div (q, b, c, MPC_RNDZN);
51 mpc_set_si_si (b, -14, 9, MPC_RNDNN);
52 if (mpc_cmp (q, b) || inex != 0)
54 printf ("mpc_div failed for (-837+I*637)/(63-I*5)\n");
63 mpc_set_ui_ui (b, 4, 3, MPC_RNDNN);
64 mpc_set_ui_ui (c, 1, 2, MPC_RNDNN);
65 inex = mpc_div (q, b, c, MPC_RNDNN);
66 mpc_set_si_si (b, 2, -1, MPC_RNDNN);
67 if (mpc_cmp (q, b) || inex != 0)
69 printf ("mpc_div failed for (4+I*3)/(1+I*2)\n");
73 /* pure real dividend BUG-20080923 */
78 mpc_set_si_si (b, -3, 0, MPC_RNDNN);
79 mpc_div_2exp (b, b, 206, MPC_RNDNN);
80 mpc_set_si_si (c, -1, -5, MPC_RNDNN);
81 mpfr_div_2ui (MPC_RE (c), MPC_RE (c), 733, GMP_RNDN);
82 mpfr_div_2ui (MPC_IM (c), MPC_IM (c), 1750, GMP_RNDN);
83 inex = mpc_div (q, b, c, MPC_RNDNZ);
84 mpc_set_si_si (b, 3, -7, MPC_RNDNN);
85 mpfr_mul_2ui (MPC_RE (b), MPC_RE (b), 527, GMP_RNDN);
86 mpfr_div_2ui (MPC_IM (b), MPC_IM (b), 489, GMP_RNDN);
90 printf ("mpc_div failed for -3p-206/(-1p-733 -I* 5p-1750)\n");
94 /* pure real divisor */
98 mpc_set_si_si (b, 15, 14, MPC_RNDNN);
99 mpc_set_si_si (c, 11, 0, MPC_RNDNN);
100 inex = mpc_div (q, b, c, MPC_RNDNN); /* should be 11/8 + 5/4*I */
101 mpc_set_si_si (b, 11, 10, MPC_RNDNN);
102 mpc_div_ui (b, b, 8, MPC_RNDNN);
103 if (mpc_cmp (q, b) || inex != MPC_INEX(1, -1))
105 printf ("mpc_div failed for (15+14*I)/11\n");
117 DECL_FUNC (CCC, f, mpc_div);
123 data_check (f, "div.dat");
124 tgeneric (f, 2, 1024, 7, 4096);