1 /* test file for mpc_cosh.
3 Copyright (C) 2008, 2009 Philippe Th\'eveny, Paul Zimmermann, Andreas Enge
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. */
24 #include "mpc-tests.h"
27 test_failed (mpc_t op, mpc_t get, mpc_t expected)
29 printf ("mpc_cosh(op) failed\n with ");
38 pure_real_argument (void)
40 /* cosh(x -i*0) = cosh(x) +i*0 if x<0 */
41 /* cosh(x -i*0) = cosh(x) -i*0 if x>0 */
42 /* cosh(x +i*0) = cosh(x) -i*0 if x<0 */
43 /* cosh(x -i*0) = cosh(x) +i*0 if x>0 */
50 mpc_init2 (cosh_z, 100);
52 /* cosh(1 +i*0) = cosh(1) +i*0 */
53 mpc_set_ui_ui (z, 1, 0, MPC_RNDNN);
54 mpfr_cosh (MPC_RE (u), MPC_RE (z), GMP_RNDN);
55 mpfr_set_ui (MPC_IM (u), 0, GMP_RNDN);
56 mpc_cosh (cosh_z, z, MPC_RNDNN);
57 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z)))
58 test_failed (z, cosh_z, u);
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_IM (cosh_z)))
65 test_failed (z, cosh_z, u);
67 /* cosh(-1 +i*0) = cosh(1) -i*0 */
68 mpc_neg (z, z, MPC_RNDNN);
69 mpc_cosh (cosh_z, z, MPC_RNDNN);
70 if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (MPC_IM (cosh_z)))
71 test_failed (z, cosh_z, u);
73 /* cosh(-1 -i*0) = cosh(1) +i*0 */
74 mpc_conj (z, z, MPC_RNDNN);
75 mpc_conj (u, u, MPC_RNDNN);
76 mpc_cosh (cosh_z, z, MPC_RNDNN);
77 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z)))
78 test_failed (z, cosh_z, u);
86 pure_imaginary_argument (void)
88 /* cosh(+0 +i*y) = cos y +i*0*sin y */
89 /* cosh(-0 +i*y) = cos y -i*0*sin y */
96 mpc_init2 (cosh_z, 100);
98 /* cosh(+0 +i) = cos(1) +i*0 */
99 mpc_set_ui_ui (z, 0, 1, MPC_RNDNN);
100 mpfr_cos (MPC_RE (u), MPC_IM (z), GMP_RNDN);
101 mpfr_set_ui (MPC_IM (u), 0, GMP_RNDN);
102 mpc_cosh (cosh_z, z, MPC_RNDNN);
103 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z)))
104 test_failed (z, cosh_z, u);
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_IM (cosh_z)))
111 test_failed (z, cosh_z, u);
113 /* cosh(-0 +i) = cos(1) -i*0 */
114 mpc_neg (z, z, MPC_RNDNN);
115 mpc_cosh (cosh_z, z, MPC_RNDNN);
116 if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (MPC_IM (cosh_z)))
117 test_failed (z, cosh_z, u);
119 /* cosh(-0 -i) = cos(1) +i*0 */
120 mpc_conj (z, z, MPC_RNDNN);
121 mpc_conj (u, u, MPC_RNDNN);
122 mpc_cosh (cosh_z, z, MPC_RNDNN);
123 if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (MPC_IM (cosh_z)))
124 test_failed (z, cosh_z, u);
134 DECL_FUNC(CC, f,mpc_cosh);
138 data_check (f, "cosh.dat");
139 tgeneric (f, 2, 512, 7, 7);
141 pure_real_argument ();
142 pure_imaginary_argument ();