alsa.audio: limit the supported frequencies to common set
[AROS.git] / workbench / libs / mathieeesingtrans / ieeespacos.c
blobf10eafa6404deb529d8a05472bb61a00d36c354d
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunSoft, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
16 #include "mathieeesingtrans_intern.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH1(float, IEEESPAcos,
24 /* SYNOPSIS */
25 AROS_LHA(float, y, D0),
27 /* LOCATION */
28 struct Library *, MathIeeeSingTransBase, 20, MathIeeeSingTrans)
30 /* FUNCTION
31 Calculate arcuscos of the given number
33 INPUTS
35 RESULT
36 IEEE single precision floating point number
38 flags:
39 zero : result is zero
40 negative : 0 (not possible)
41 overflow : y < -1 or y > 1
43 BUGS
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 /* 1> |x| >= 0.5 */
52 LONG z,p,q,r,w,s,c,ix,df;
53 ix = y & (IEEESPMantisse_Mask | IEEESPExponent_Mask); /* ix = |y| */
55 z = IEEESPCmp(ix,one);
57 if (1==z) /* |y| > 1 */
59 SetSR(Overflow_Bit, Zero_Bit | Overflow_Bit | Negative_Bit);
60 return 0x7fffffff;
63 if (0==z) /* |y| = 1 */
65 if (y & IEEESPSign_Mask) /* y = -1 */ return pi;
66 SetSR(Zero_Bit, Zero_Bit | Overflow_Bit | Negative_Bit);
67 return 0;
70 /* error: 1 ulp (unit in the last place) */
71 if (-1 == IEEESPCmp(ix,onehalf)) /* |fnum1| < 0.5 */
73 z = IEEESPMul(y, y);
74 p = IEEESPMul(z, IEEESPAdd(pS0,
75 IEEESPMul(z, IEEESPAdd(pS1,
76 IEEESPMul(z, IEEESPAdd(pS2,
77 IEEESPMul(z, IEEESPAdd(pS3,
78 IEEESPMul(z, IEEESPAdd(pS4,
79 IEEESPMul(z, pS5)))))))))));
80 q = IEEESPAdd(one,
81 IEEESPMul(z, IEEESPAdd(qS1,
82 IEEESPMul(z, IEEESPAdd(qS2,
83 IEEESPMul(z, IEEESPAdd(qS3,
84 IEEESPMul(z, qS4))))))));
85 r = IEEESPDiv(p, q);
87 return (IEEESPSub(pio2,IEEESPAdd(y,IEEESPMul(y,r))));
90 /* error: 1 ulp */
91 if (y & IEEESPSign_Mask) /* y < -0.5 */
93 z = IEEESPMul(onehalf, IEEESPAdd(one, y));
94 p = IEEESPMul(z, IEEESPAdd(pS0,
95 IEEESPMul(z, IEEESPAdd(pS1,
96 IEEESPMul(z, IEEESPAdd(pS2,
97 IEEESPMul(z, IEEESPAdd(pS3,
98 IEEESPMul(z, IEEESPAdd(pS4,
99 IEEESPMul(z, pS5)))))))))));
100 q = IEEESPAdd(one,
101 IEEESPMul(z, IEEESPAdd(qS1,
102 IEEESPMul(z, IEEESPAdd(qS2,
103 IEEESPMul(z, IEEESPAdd(qS3,
104 IEEESPMul(z, qS4))))))));
105 s = IEEESPSqrt(z);
106 r = IEEESPDiv(p,q); /* r = p/q; */
107 w = IEEESPMul(r,s);
109 return IEEESPSub(pi, IEEESPMul(two, IEEESPAdd(s, w)));
112 /* fnum1 > 0.5 */
113 /* error : 1 ulp */
114 z = IEEESPMul(onehalf, IEEESPSub(one, y));
115 s = IEEESPSqrt(z);
116 df = s;
117 //df = df & 0xfff000ff;
118 c = IEEESPDiv(IEEESPSub(z, IEEESPMul(df,df)), IEEESPAdd(df,s) );
119 p = IEEESPMul(z, IEEESPAdd(pS0,
120 IEEESPMul(z, IEEESPAdd(pS1,
121 IEEESPMul(z, IEEESPAdd(pS2,
122 IEEESPMul(z, IEEESPAdd(pS3,
123 IEEESPMul(z, IEEESPAdd(pS4,
124 IEEESPMul(z, pS5)))))))))));
125 q = IEEESPAdd(one,
126 IEEESPMul(z, IEEESPAdd(qS1,
127 IEEESPMul(z, IEEESPAdd(qS2,
128 IEEESPMul(z, IEEESPAdd(qS3,
129 IEEESPMul(z, qS4))))))));
130 r = IEEESPDiv(p, q);
131 w = IEEESPAdd(c, IEEESPMul(r,s));
133 return IEEESPMul(two, IEEESPAdd(df,w));
135 AROS_LIBFUNC_EXIT