1 /* test file for mpc_cosh.
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/ .
22 #include "mpc-tests.h"
25 pure_real_argument (void)
27 /* cosh(x -i*0) = cosh(x) +i*0 if x<0 */
28 /* cosh(x -i*0) = cosh(x) -i*0 if x>0 */
29 /* cosh(x +i*0) = cosh(x) -i*0 if x<0 */
30 /* cosh(x -i*0) = cosh(x) +i*0 if x>0 */
37 mpc_init2 (cosh_z, 100);
39 /* cosh(1 +i*0) = cosh(1) +i*0 */
40 mpc_set_ui_ui (z, 1, 0, MPC_RNDNN);
41 mpfr_cosh (mpc_realref (u), mpc_realref (z), GMP_RNDN);
42 mpfr_set_ui (mpc_imagref (u), 0, GMP_RNDN);
43 mpc_cosh (cosh_z, z, MPC_RNDNN);
44 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z)))
45 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
47 /* cosh(1 -i*0) = cosh(1) -i*0 */
48 mpc_conj (z, z, MPC_RNDNN);
49 mpc_conj (u, u, MPC_RNDNN);
50 mpc_cosh (cosh_z, z, MPC_RNDNN);
51 if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z)))
52 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
54 /* cosh(-1 +i*0) = cosh(1) -i*0 */
55 mpc_neg (z, z, MPC_RNDNN);
56 mpc_cosh (cosh_z, z, MPC_RNDNN);
57 if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z)))
58 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
60 /* cosh(-1 -i*0) = cosh(1) +i*0 */
61 mpc_conj (z, z, MPC_RNDNN);
62 mpc_conj (u, u, MPC_RNDNN);
63 mpc_cosh (cosh_z, z, MPC_RNDNN);
64 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z)))
65 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
73 pure_imaginary_argument (void)
75 /* cosh(+0 +i*y) = cos y +i*0*sin y */
76 /* cosh(-0 +i*y) = cos y -i*0*sin y */
83 mpc_init2 (cosh_z, 100);
85 /* cosh(+0 +i) = cos(1) + i*0 */
86 mpc_set_ui_ui (z, 0, 1, MPC_RNDNN);
87 mpfr_cos (mpc_realref (u), mpc_imagref (z), GMP_RNDN);
88 mpfr_set_ui (mpc_imagref (u), 0, GMP_RNDN);
89 mpc_cosh (cosh_z, z, MPC_RNDNN);
90 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z)))
91 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
93 /* cosh(+0 -i) = cos(1) - i*0 */
94 mpc_conj (z, z, MPC_RNDNN);
95 mpc_conj (u, u, MPC_RNDNN);
96 mpc_cosh (cosh_z, z, MPC_RNDNN);
97 if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z)))
98 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
100 /* cosh(-0 +i) = cos(1) - i*0 */
101 mpc_neg (z, z, MPC_RNDNN);
102 mpc_cosh (cosh_z, z, MPC_RNDNN);
103 if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z)))
104 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
106 /* cosh(-0 -i) = cos(1) + i*0 */
107 mpc_conj (z, z, MPC_RNDNN);
108 mpc_conj (u, u, MPC_RNDNN);
109 mpc_cosh (cosh_z, z, MPC_RNDNN);
110 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z)))
111 TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN);
121 DECL_FUNC(CC, f,mpc_cosh);
125 data_check (f, "cosh.dat");
126 tgeneric (f, 2, 512, 7, 7);
128 pure_real_argument ();
129 pure_imaginary_argument ();