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