1/* Test file for mpfr_csc. 2 3Copyright 2005-2023 Free Software Foundation, Inc. 4Contributed by the AriC and Caramba 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 20https://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 "mpfr-test.h" 24 25#define TEST_FUNCTION mpfr_csc 26#define REDUCE_EMAX 262143 /* otherwise arg. reduction is too expensive */ 27#include "tgeneric.c" 28 29static void 30check_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_csc (y, x, MPFR_RNDN); 39 if (! mpfr_nan_p (y)) 40 { 41 printf ("Error: csc(NaN) != NaN\n"); 42 exit (1); 43 } 44 45 mpfr_set_inf (x, 1); 46 mpfr_csc (y, x, MPFR_RNDN); 47 if (! mpfr_nan_p (y)) 48 { 49 printf ("Error: csc(Inf) != NaN\n"); 50 exit (1); 51 } 52 53 mpfr_set_inf (x, -1); 54 mpfr_csc (y, x, MPFR_RNDN); 55 if (! mpfr_nan_p (y)) 56 { 57 printf ("Error: csc(-Inf) != NaN\n"); 58 exit (1); 59 } 60 61 /* csc(+/-0) = +/-Inf */ 62 mpfr_set_ui (x, 0, MPFR_RNDN); 63 mpfr_csc (y, x, MPFR_RNDN); 64 if (! (mpfr_inf_p (y) && mpfr_sgn (y) > 0)) 65 { 66 printf ("Error: csc(+0) != +Inf\n"); 67 exit (1); 68 } 69 mpfr_neg (x, x, MPFR_RNDN); 70 mpfr_csc (y, x, MPFR_RNDN); 71 if (! (mpfr_inf_p (y) && mpfr_sgn (y) < 0)) 72 { 73 printf ("Error: csc(-0) != -Inf\n"); 74 exit (1); 75 } 76 77 mpfr_clear (x); 78 mpfr_clear (y); 79} 80 81int 82main (int argc, char *argv[]) 83{ 84 tests_start_mpfr (); 85 86 check_specials (); 87 88 test_generic (MPFR_PREC_MIN, 100, 10); 89 90 tests_end_mpfr (); 91 return 0; 92} 93