~ubuntu-branches/debian/sid/genius/sid

« back to all changes in this revision

Viewing changes to mpfr/tests/tcoth.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-08-21 12:57:45 UTC
  • Revision ID: james.westby@ubuntu.com-20060821125745-sl9ks8v7fq324bdf
Tags: upstream-0.7.6.1
ImportĀ upstreamĀ versionĀ 0.7.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Test file for mpfr_coth.
 
2
 
 
3
Copyright 2005 Free Software Foundation, Inc.
 
4
 
 
5
This file is part of the MPFR Library.
 
6
 
 
7
The MPFR Library is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU Lesser General Public License as published by
 
9
the Free Software Foundation; either version 2.1 of the License, or (at your
 
10
option) any later version.
 
11
 
 
12
The MPFR Library is distributed in the hope that it will be useful, but
 
13
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
14
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
15
License for more details.
 
16
 
 
17
You should have received a copy of the GNU Lesser General Public License
 
18
along with the MPFR Library; see the file COPYING.LIB.  If not, write to
 
19
the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston,
 
20
MA 02110-1301, USA. */
 
21
 
 
22
#include <stdio.h>
 
23
#include <stdlib.h>
 
24
 
 
25
#include "mpfr-test.h"
 
26
 
 
27
#define TEST_FUNCTION mpfr_coth
 
28
#include "tgeneric.c"
 
29
 
 
30
static void
 
31
check_specials (void)
 
32
{
 
33
  mpfr_t  x, y;
 
34
 
 
35
  mpfr_init2 (x, 123L);
 
36
  mpfr_init2 (y, 123L);
 
37
 
 
38
  mpfr_set_nan (x);
 
39
  mpfr_coth (y, x, GMP_RNDN);
 
40
  if (! mpfr_nan_p (y))
 
41
    {
 
42
      printf ("Error: coth(NaN) != NaN\n");
 
43
      exit (1);
 
44
    }
 
45
 
 
46
  mpfr_set_inf (x, 1);
 
47
  mpfr_coth (y, x, GMP_RNDN);
 
48
  if (mpfr_cmp_ui (y, 1))
 
49
    {
 
50
      printf ("Error: coth(Inf) != 1\n");
 
51
      exit (1);
 
52
    }
 
53
 
 
54
  mpfr_set_inf (x, -1);
 
55
  mpfr_coth (y, x, GMP_RNDN);
 
56
  if (mpfr_cmp_si (y, -1))
 
57
    {
 
58
      printf ("Error: coth(-Inf) != -1\n");
 
59
      exit (1);
 
60
    }
 
61
 
 
62
  /* cot(+/-0) = +/-0 */
 
63
  mpfr_set_ui (x, 0, GMP_RNDN);
 
64
  mpfr_coth (y, x, GMP_RNDN);
 
65
  if (! (mpfr_zero_p (y) && MPFR_SIGN (y) > 0))
 
66
    {
 
67
      printf ("Error: coth(+0) != +0\n");
 
68
      exit (1);
 
69
    }
 
70
  mpfr_neg (x, x, GMP_RNDN);
 
71
  mpfr_coth (y, x, GMP_RNDN);
 
72
  if (! (mpfr_zero_p (y) && MPFR_SIGN (y) < 0))
 
73
    {
 
74
      printf ("Error: coth(-0) != -0\n");
 
75
      exit (1);
 
76
    }
 
77
 
 
78
  mpfr_clear (x);
 
79
  mpfr_clear (y);
 
80
}
 
81
 
 
82
static void
 
83
check_bugs (void)
 
84
{
 
85
  mpfr_t x, y;
 
86
 
 
87
  mpfr_init (x);
 
88
  mpfr_init (y);
 
89
 
 
90
  /* bug found by Rob (Sisyphus) on 16 Sep 2005 */
 
91
  mpfr_set_ui (x, 2, GMP_RNDN);
 
92
  mpfr_set_prec (y, 2);
 
93
  mpfr_coth (y, x, GMP_RNDN);
 
94
  if (mpfr_cmp_ui (y, 1))
 
95
    {
 
96
      printf ("Error for coth(2), expected 1, got ");
 
97
      mpfr_dump (y);
 
98
      exit (1);
 
99
    }
 
100
 
 
101
  mpfr_clear (x);
 
102
  mpfr_clear (y);
 
103
}
 
104
 
 
105
int
 
106
main (int argc, char *argv[])
 
107
{
 
108
  tests_start_mpfr ();
 
109
 
 
110
  check_specials ();
 
111
  check_bugs ();
 
112
  test_generic (2, 200, 10);
 
113
 
 
114
  tests_end_mpfr ();
 
115
  return 0;
 
116
}