xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/tdigamma.c (revision 4d5abbe83f525258eb479e5fca29f25cb943f379)
1 /* test file for digamma function
2 
3 Copyright 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramel 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 http://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 <stdio.h>
24 #include <stdlib.h>
25 
26 #include "mpfr-test.h"
27 
28 #define TEST_FUNCTION mpfr_digamma
29 #include "tgeneric.c"
30 
31 static void
32 special (void)
33 {
34   mpfr_t x, y;
35 
36   mpfr_init (x);
37   mpfr_init (y);
38 
39   mpfr_set_inf (y, -1);
40   mpfr_set_inf (x, 1);
41   mpfr_digamma (y, x, MPFR_RNDN);
42   if (mpfr_inf_p (y) == 0 || mpfr_sgn (y) < 0)
43     {
44       printf ("error for Psi(+Inf)\n");
45       printf ("expected +Inf\n");
46       printf ("got      ");
47       mpfr_dump (y);
48       exit (1);
49     }
50 
51   mpfr_clear (x);
52   mpfr_clear (y);
53 }
54 
55 int
56 main (int argc, char *argv[])
57 {
58   tests_start_mpfr ();
59 
60   special ();
61 
62   test_generic (2, 100, 2);
63 
64   data_check ("data/digamma", mpfr_digamma, "mpfr_digamma");
65 
66   tests_end_mpfr ();
67   return 0;
68 }
69