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