OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [mathfp/] [sf_asine.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)z_asinef.c 1.0 98/08/13 */
3
/******************************************************************
4
 * The following routines are coded directly from the algorithms
5
 * and coefficients given in "Software Manual for the Elementary
6
 * Functions" by William J. Cody, Jr. and William Waite, Prentice
7
 * Hall, 1980.
8
 ******************************************************************/
9
/******************************************************************
10
 * Arcsine
11
 *
12
 * Input:
13
 *   x - floating point value
14
 *   acosine - indicates acos calculation
15
 *
16
 * Output:
17
 *   Arcsine of x.
18
 *
19
 * Description:
20
 *   This routine calculates arcsine / arccosine.
21
 *
22
 *****************************************************************/
23
 
24
#include "fdlibm.h"
25
#include "zmath.h"
26
 
27
static const float p[] = { 0.933935835, -0.504400557 };
28
static const float q[] = { 0.560363004e+1, -0.554846723e+1 };
29
static const float a[] = { 0.0, 0.785398163 };
30
static const float b[] = { 1.570796326, 0.785398163 };
31
 
32
float
33
_DEFUN (asinef, (float, int),
34
        float x _AND
35
        int acosine)
36
{
37
  int flag, i;
38
  int branch = 0;
39
  float g, res, R, P, Q, y;
40
 
41
  /* Check for special values. */
42
  i = numtestf (x);
43
  if (i == NAN || i == INF)
44
    {
45
      errno = EDOM;
46
      if (i == NAN)
47
        return (x);
48
      else
49
        return (z_infinity_f.f);
50
    }
51
 
52
  y = fabsf (x);
53
  flag = acosine;
54
 
55
  if (y > 0.5)
56
    {
57
      i = 1 - flag;
58
 
59
      /* Check for range error. */
60
      if (y > 1.0)
61
        {
62
          errno = ERANGE;
63
          return (z_notanum_f.f);
64
        }
65
 
66
      g = (1 - y) / 2.0;
67
      y = -2 * sqrt (g);
68
      branch = 1;
69
    }
70
  else
71
    {
72
      i = flag;
73
      if (y < z_rooteps_f)
74
        res = y;
75
      else
76
        g = y * y;
77
    }
78
 
79
  if (y >= z_rooteps_f || branch == 1)
80
    {
81
      /* Calculate the Taylor series. */
82
      P = (p[1] * g + p[0]) * g;
83
      Q = (g + q[1]) * g + q[0];
84
      R = P / Q;
85
 
86
      res = y + y * R;
87
    }
88
 
89
  /* Calculate asine or acose. */
90
  if (flag == 0)
91
    {
92
      res = (a[i] + res) + a[i];
93
      if (x < 0.0)
94
        res = -res;
95
    }
96
  else
97
    {
98
      if (x < 0.0)
99
        res = (b[i] + res) + b[i];
100
      else
101
        res = (a[i] - res) + a[i];
102
    }
103
 
104
  return (res);
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.