10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #pragma weak logl = __logl
31
32 /*
33 * logl(x)
34 * Table look-up algorithm
35 * By K.C. Ng, March 6, 1989
36 *
37 * (a). For x in [31/33,33/31], using a special approximation:
38 * f = x - 1;
39 * s = f/(2.0+f); ... here |s| <= 0.03125
40 * z = s*s;
41 * return f-s*(f-z*(B1+z*(B2+z*(B3+z*(B4+...+z*B9)...))));
42 *
43 * (b). Otherwise, normalize x = 2^n * 1.f.
44 * Use a 6-bit table look-up: find a 6 bit g that match f to 6.5 bits,
45 * then
46 * log(x) = n*ln2 + log(1.g) + log(1.f/1.g).
47 * Here the leading and trailing values of log(1.g) are obtained from
48 * a size-64 table.
49 * For log(1.f/1.g), let s = (1.f-1.g)/(1.f+1.g), then
50 * log(1.f/1.g) = log((1+s)/(1-s)) = 2s + 2/3 s^3 + 2/5 s^5 +...
|
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #pragma weak __logl = logl
31
32 /*
33 * logl(x)
34 * Table look-up algorithm
35 * By K.C. Ng, March 6, 1989
36 *
37 * (a). For x in [31/33,33/31], using a special approximation:
38 * f = x - 1;
39 * s = f/(2.0+f); ... here |s| <= 0.03125
40 * z = s*s;
41 * return f-s*(f-z*(B1+z*(B2+z*(B3+z*(B4+...+z*B9)...))));
42 *
43 * (b). Otherwise, normalize x = 2^n * 1.f.
44 * Use a 6-bit table look-up: find a 6 bit g that match f to 6.5 bits,
45 * then
46 * log(x) = n*ln2 + log(1.g) + log(1.f/1.g).
47 * Here the leading and trailing values of log(1.g) are obtained from
48 * a size-64 table.
49 * For log(1.f/1.g), let s = (1.f-1.g)/(1.f+1.g), then
50 * log(1.f/1.g) = log((1+s)/(1-s)) = 2s + 2/3 s^3 + 2/5 s^5 +...
|