1243730Srwatson/* tpow_z -- test file for mpc_pow_z.
2243730Srwatson
3243730SrwatsonCopyright (C) 2009, 2011 INRIA
4243730Srwatson
5243730SrwatsonThis file is part of GNU MPC.
6243730Srwatson
7243730SrwatsonGNU MPC is free software; you can redistribute it and/or modify it under
8243730Srwatsonthe terms of the GNU Lesser General Public License as published by the
9243730SrwatsonFree Software Foundation; either version 3 of the License, or (at your
10243730Srwatsonoption) any later version.
11243730Srwatson
12243730SrwatsonGNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13243730SrwatsonWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14243730SrwatsonFOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15243730Srwatsonmore details.
16243730Srwatson
17243730SrwatsonYou should have received a copy of the GNU Lesser General Public License
18243730Srwatsonalong with this program. If not, see http://www.gnu.org/licenses/ .
19243730Srwatson*/
20243730Srwatson
21243730Srwatson#include <limits.h> /* for CHAR_BIT */
22243730Srwatson#include "mpc-tests.h"
23243730Srwatson
24243730Srwatsonint
25243730Srwatsonmain (void)
26243730Srwatson{
27243730Srwatson   mpc_t z;
28243730Srwatson   mpz_t t;
29243730Srwatson
30243730Srwatson   test_start ();
31243730Srwatson
32243730Srwatson   mpc_init2 (z, 5);
33243730Srwatson   mpz_init_set_ui (t, 1ul);
34243730Srwatson   mpc_set_ui_ui (z, 17ul, 42ul, MPC_RNDNN);
35243730Srwatson   mpc_pow_z (z, z, t, MPC_RNDNN);
36243730Srwatson   if (mpc_cmp_si_si (z, 17l, 42l) != 0) {
37243730Srwatson         printf ("Error for mpc_pow_z (1)\n");
38243730Srwatson         exit (1);
39243730Srwatson   }
40243730Srwatson   mpz_set_si (t, -1l);
41243730Srwatson   mpc_set_ui_ui (z, 1ul, 1ul, MPC_RNDNN);
42243730Srwatson   mpc_pow_z (z, z, t, MPC_RNDNN);
43243730Srwatson   mpc_mul_ui (z, z, 2ul, MPC_RNDNN);
44243730Srwatson   if (mpc_cmp_si_si (z, 1l, -1l) != 0) {
45243730Srwatson         printf ("Error for mpc_pow_z (-1)\n");
46243730Srwatson         exit (1);
47243730Srwatson   }
48243730Srwatson   mpz_set_ui (t, 1ul);
49243730Srwatson   mpz_mul_2exp (t, t, sizeof (long) * CHAR_BIT);
50243730Srwatson   mpc_set_ui_ui (z, 0ul, 1ul, MPC_RNDNN);
51243730Srwatson   mpc_pow_z (z, z, t, MPC_RNDNN);
52243730Srwatson   if (mpc_cmp_si_si (z, 1l, 0l) != 0) {
53243730Srwatson         printf ("Error for mpc_pow_z (4*large)\n");
54243730Srwatson         exit (1);
55243730Srwatson   }
56243730Srwatson   mpc_clear (z);
57243730Srwatson   mpz_clear (t);
58243730Srwatson
59243730Srwatson   test_end ();
60243730Srwatson
61243730Srwatson   return 0;
62243730Srwatson}
63243730Srwatson