xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/tdigamma.c (revision b45fa494daa2ba02187711d31a4144faf0993066)
1 /* test file for digamma function
2 
3 Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Cacao projects, INRIA.
5 
6 The GNU MPFR Library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or (at your
9 option) any later version.
10 
11 The GNU MPFR Library is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14 License for more details.
15 
16 You should have received a copy of the GNU Lesser General Public License
17 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
18 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
19 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #include "mpfr-test.h"
25 
26 #define TEST_FUNCTION mpfr_digamma
27 #include "tgeneric.c"
28 
29 static void
30 special (void)
31 {
32   mpfr_t x, y;
33 
34   mpfr_init (x);
35   mpfr_init (y);
36 
37   mpfr_set_inf (y, -1);
38   mpfr_set_inf (x, 1);
39   mpfr_digamma (y, x, MPFR_RNDN);
40   if (mpfr_inf_p (y) == 0 || mpfr_sgn (y) < 0)
41     {
42       printf ("error for Psi(+Inf)\n");
43       printf ("expected +Inf\n");
44       printf ("got      ");
45       mpfr_dump (y);
46       exit (1);
47     }
48 
49   mpfr_clear (x);
50   mpfr_clear (y);
51 }
52 
53 int
54 main (int argc, char *argv[])
55 {
56   tests_start_mpfr ();
57 
58   special ();
59 
60   test_generic (2, 100, 2);
61 
62   data_check ("data/digamma", mpfr_digamma, "mpfr_digamma");
63 
64   tests_end_mpfr ();
65   return 0;
66 }
67