(root)/
mpfr-4.2.1/
tests/
tcsc.c
       1  /* Test file for mpfr_csc.
       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_csc
      26  #define REDUCE_EMAX 262143 /* otherwise arg. reduction is too expensive */
      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_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  
      81  int
      82  main (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  }