summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/cephes/elog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libc/cephes/elog.c')
-rw-r--r--src/regress/lib/libc/cephes/elog.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/regress/lib/libc/cephes/elog.c b/src/regress/lib/libc/cephes/elog.c
deleted file mode 100644
index 079cc754f4..0000000000
--- a/src/regress/lib/libc/cephes/elog.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/* $OpenBSD: elog.c,v 1.1 2011/07/02 18:11:01 martynas Exp $ */
2
3/*
4 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/* xlog.c */
20/* natural logarithm */
21/* by Stephen L. Moshier. */
22
23#include "mconf.h"
24#include "ehead.h"
25
26
27
28void elog( x, y )
29unsigned short *x, *y;
30{
31unsigned short xx[NE], z[NE], a[NE], b[NE], t[NE], qj[NE];
32long ex;
33int fex;
34
35
36if( x[NE-1] & (unsigned short )0x8000 )
37 {
38 eclear(y);
39 mtherr( "elog", DOMAIN );
40 return;
41 }
42if( ecmp( x, ezero ) == 0 )
43 {
44 einfin( y );
45 eneg(y);
46 mtherr( "elog", SING );
47 return;
48 }
49if( ecmp( x, eone ) == 0 )
50 {
51 eclear( y );
52 return;
53 }
54
55/* range reduction: log x = log( 2**ex * m ) = ex * log2 + log m */
56efrexp( x, &fex, xx );
57/*
58emov(x, xx );
59ex = xx[NX-1] & 0x7fff;
60ex -= 0x3ffe;
61xx[NX-1] = 0x3ffe;
62*/
63
64/* Adjust range to 1/sqrt(2), sqrt(2) */
65esqrt2[NE-1] -= 1;
66if( ecmp( xx, esqrt2 ) < 0 )
67 {
68 fex -= 1;
69 emul( xx, etwo, xx );
70 }
71esqrt2[NE-1] += 1;
72
73esub( eone, xx, a );
74if( a[NE-1] == 0 )
75 {
76 eclear( y );
77 goto logdon;
78 }
79eadd( eone, xx, b );
80ediv( b, a, y ); /* store (x-1)/(x+1) in y */
81
82emul( y, y, z );
83
84emov( eone, a );
85emov( eone, b );
86emov( eone, qj );
87do
88 {
89 eadd( etwo, qj, qj ); /* 2 * i + 1 */
90 emul( z, a, a );
91 ediv( qj, a, t );
92 eadd( t, b, b );
93 }
94while( ((b[NE-1] & 0x7fff) - (t[NE-1] & 0x7fff)) < NBITS );
95
96
97emul( b, y, y );
98emul( y, etwo, y );
99
100logdon:
101
102/* now add log of 2**ex */
103if( fex != 0 )
104 {
105 ex = fex;
106 ltoe( &ex, b );
107 emul( elog2, b, b );
108 eadd( b, y, y );
109 }
110}