1/* Test file for mpfr_csch.
2
3Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4Contributed by the Arenaire and Cacao projects, INRIA.
5
6This file is part of the GNU MPFR Library.
7
8The GNU MPFR Library is free software; you can redistribute it and/or modify
9it under the terms of the GNU Lesser General Public License as published by
10the Free Software Foundation; either version 3 of the License, or (at your
11option) any later version.
12
13The GNU MPFR Library is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16License for more details.
17
18You should have received a copy of the GNU Lesser General Public License
19along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
20http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
2151 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22
23#include <stdio.h>
24#include <stdlib.h>
25
26#include "mpfr-test.h"
27
28#define TEST_FUNCTION mpfr_csch
29#define TEST_RANDOM_EMAX 63
30#include "tgeneric.c"
31
32static void
33check_specials (void)
34{
35  mpfr_t  x, y;
36
37  mpfr_init2 (x, 123L);
38  mpfr_init2 (y, 123L);
39
40  mpfr_set_nan (x);
41  mpfr_csch (y, x, MPFR_RNDN);
42  if (! mpfr_nan_p (y))
43    {
44      printf ("Error: csch(NaN) != NaN\n");
45      exit (1);
46    }
47
48  mpfr_set_inf (x, 1);
49  mpfr_csch (y, x, MPFR_RNDN);
50  if (! (mpfr_zero_p (y) && MPFR_SIGN (y) >0))
51    {
52      printf ("Error: csch(+Inf) != +0\n");
53      exit (1);
54    }
55
56  mpfr_set_inf (x, -1);
57  mpfr_csch (y, x, MPFR_RNDN);
58  if (! (mpfr_zero_p (y) && MPFR_SIGN (y) <0))
59    {
60      printf ("Error: csch(-0) != -0\n");
61      exit (1);
62    }
63
64  /* csc(+/-0) = +/-Inf */
65  mpfr_set_ui (x, 0, MPFR_RNDN);
66  mpfr_csch (y, x, MPFR_RNDN);
67  if (! (mpfr_inf_p (y) && mpfr_sgn (y) > 0))
68    {
69      printf ("Error: csch(+0) != +Inf\n");
70      exit (1);
71    }
72  mpfr_neg (x, x, MPFR_RNDN);
73  mpfr_csch (y, x, MPFR_RNDN);
74  if (! (mpfr_inf_p (y) && mpfr_sgn (y) < 0))
75    {
76      printf ("Error: csch(-0) != -Inf\n");
77      exit (1);
78    }
79
80  /* check huge x */
81  mpfr_set_str (x, "8e8", 10, MPFR_RNDN);
82  mpfr_csch (y, x, MPFR_RNDN);
83  if (! (mpfr_zero_p (y) && MPFR_SIGN (y) > 0))
84    {
85      printf ("Error: csch(8e8) != +0\n");
86      exit (1);
87    }
88  mpfr_set_str (x, "-8e8", 10, MPFR_RNDN);
89  mpfr_csch (y, x, MPFR_RNDN);
90  if (! (mpfr_zero_p (y) && MPFR_SIGN (y) < 0))
91    {
92      printf ("Error: csch(-8e8) != -0\n");
93      exit (1);
94    }
95
96  mpfr_clear (x);
97  mpfr_clear (y);
98}
99
100int
101main (int argc, char *argv[])
102{
103  tests_start_mpfr ();
104
105  check_specials ();
106  test_generic (2, 200, 10);
107
108  tests_end_mpfr ();
109  return 0;
110}
111