Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add exp2 and exp2m
details: https://anonhg.NetBSD.org/src/rev/b7db1ce24906
branches: trunk
changeset: 750709:b7db1ce24906
user: christos <christos%NetBSD.org@localhost>
date: Mon Jan 11 16:28:39 2010 +0000
description:
Add exp2 and exp2m
diffstat:
include/math.h | 4 +-
lib/libm/Makefile | 5 +-
lib/libm/man/exp.3 | 50 ++++-
lib/libm/shlib_version | 4 +-
lib/libm/src/math_private.h | 20 ++-
lib/libm/src/s_exp2.c | 399 ++++++++++++++++++++++++++++++++++++++++++++
lib/libm/src/s_exp2f.c | 139 +++++++++++++++
7 files changed, 610 insertions(+), 11 deletions(-)
diffs (truncated from 733 to 300 lines):
diff -r 1549ab0386e8 -r b7db1ce24906 include/math.h
--- a/include/math.h Mon Jan 11 16:28:06 2010 +0000
+++ b/include/math.h Mon Jan 11 16:28:39 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: math.h,v 1.49 2009/10/04 22:59:25 christos Exp $ */
+/* $NetBSD: math.h,v 1.50 2010/01/11 16:28:39 christos Exp $ */
/*
* ====================================================
@@ -194,6 +194,7 @@
double tanh(double);
double exp(double);
+double exp2(double);
double frexp(double, int *);
double ldexp(double, int);
double log(double);
@@ -282,6 +283,7 @@
/* 7.12.6 exp / log */
float expf(float);
+float exp2f(float);
float expm1f(float);
float frexpf(float, int *);
int ilogbf(float);
diff -r 1549ab0386e8 -r b7db1ce24906 lib/libm/Makefile
--- a/lib/libm/Makefile Mon Jan 11 16:28:06 2010 +0000
+++ b/lib/libm/Makefile Mon Jan 11 16:28:39 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.91 2009/10/23 23:42:52 joerg Exp $
+# $NetBSD: Makefile,v 1.92 2010/01/11 16:28:39 christos Exp $
#
# @(#)Makefile 5.1beta 93/09/24
#
@@ -119,7 +119,8 @@
k_standard.c k_tan.c k_tanf.c \
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_cbrt.c s_cbrtf.c s_ceil.c \
s_ceilf.c s_copysign.c s_copysignf.c s_cos.c s_cosf.c s_erf.c \
- s_erff.c s_expm1.c s_expm1f.c s_fabsf.c s_finite.c s_finitef.c \
+ s_erff.c s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c \
+ s_finite.c s_finitef.c \
s_floor.c s_floorf.c s_frexpf.c s_ilogb.c s_ilogbf.c \
s_isinff.c s_isnanf.c s_ldexpf.c s_lib_version.c s_log1p.c \
s_log1pf.c s_logb.c s_logbf.c s_matherr.c s_modff.c s_nextafter.c \
diff -r 1549ab0386e8 -r b7db1ce24906 lib/libm/man/exp.3
--- a/lib/libm/man/exp.3 Mon Jan 11 16:28:06 2010 +0000
+++ b/lib/libm/man/exp.3 Mon Jan 11 16:28:39 2010 +0000
@@ -26,14 +26,19 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
-.\" $NetBSD: exp.3,v 1.23 2005/07/21 12:58:22 wiz Exp $
+.\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
+.\" $NetBSD: exp.3,v 1.24 2010/01/11 16:28:39 christos Exp $
.\"
-.Dd July 21, 2005
+.Dd January 11, 2010
.Dt EXP 3
.Os
.Sh NAME
.Nm exp ,
.Nm expf ,
+.\" The sorting error is intentional. exp and expf should be adjacent.
+.Nm exp2 ,
+.Nm exp2f ,
+.\" .Nm exp2l ,
.Nm expm1 ,
.Nm expm1f ,
.Nm log ,
@@ -56,6 +61,12 @@
.Ft float
.Fn expf "float x"
.Ft double
+.Fn exp2 "double x"
+.Ft float
+.Fn exp2f "float x"
+.\" .Ft long double
+.\" .Fn exp2l "long double x"
+.Ft double
.Fn expm1 "double x"
.Ft float
.Fn expm1f "float x"
@@ -82,12 +93,28 @@
.Sh DESCRIPTION
The
.Fn exp
-function computes the exponential value of the given argument
+and the
+.Fn expf
+functions compute the base
+.Ms e
+exponential value of the given argument
+.Fa x .
+.Pp
+The
+.Fn exp2 ,
+and
+.Fn exp2f
+.\" .Fn exp2f ,
+.\" and
+.\" .Fn exp2l
+functions compute the base 2 exponential of the given argument
.Fa x .
.Pp
The
.Fn expm1
-function computes the value exp(x)\-1 accurately even for tiny argument
+and the
+.Fn expm1f
+functions computes the value exp(x)\-1 accurately even for tiny argument
.Fa x .
.Pp
The
@@ -117,11 +144,24 @@
.Pp
The
.Fn pow
-computes the value
+and
+.Fn powf
+functions compute the value
of
.Ar x
to the exponent
.Ar y .
+.Sh ERROR (due to Roundoff etc.)
+The values of
+.Fn exp 0 ,
+.Fn expm1 0 ,
+.Fn exp2 integer ,
+and
+.Fn pow integer integer
+are exact provided that they are representable.
+.\" XXX Is this really true for pow()?
+Otherwise the error in these functions is generally below one
+.Em ulp .
.Sh RETURN VALUES
These functions will return the appropriate computation unless an error
occurs or an argument is out of range.
diff -r 1549ab0386e8 -r b7db1ce24906 lib/libm/shlib_version
--- a/lib/libm/shlib_version Mon Jan 11 16:28:06 2010 +0000
+++ b/lib/libm/shlib_version Mon Jan 11 16:28:39 2010 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.10 2009/10/04 22:04:30 christos Exp $
+# $NetBSD: shlib_version,v 1.11 2010/01/11 16:28:39 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=0
-minor=7
+minor=8
diff -r 1549ab0386e8 -r b7db1ce24906 lib/libm/src/math_private.h
--- a/lib/libm/src/math_private.h Mon Jan 11 16:28:06 2010 +0000
+++ b/lib/libm/src/math_private.h Mon Jan 11 16:28:39 2010 +0000
@@ -11,7 +11,7 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
- * $NetBSD: math_private.h,v 1.13 2008/04/26 23:49:50 christos Exp $
+ * $NetBSD: math_private.h,v 1.14 2010/01/11 16:28:39 christos Exp $
*/
#ifndef _MATH_PRIVATE_H_
@@ -152,6 +152,24 @@
(d) = sf_u.value; \
} while (/*CONSTCOND*/0)
+/*
+ * Attempt to get strict C99 semantics for assignment with non-C99 compilers.
+ */
+#if FLT_EVAL_METHOD == 0 || __GNUC__ == 0
+#define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval))
+#else
+#define STRICT_ASSIGN(type, lval, rval) do { \
+ volatile type __lval; \
+ \
+ if (sizeof(type) >= sizeof(double)) \
+ (lval) = (rval); \
+ else { \
+ __lval = (rval); \
+ (lval) = __lval; \
+ } \
+} while (/*CONSTCOND*/0)
+#endif
+
/* ieee style elementary functions */
extern double __ieee754_sqrt __P((double));
extern double __ieee754_acos __P((double));
diff -r 1549ab0386e8 -r b7db1ce24906 lib/libm/src/s_exp2.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/src/s_exp2.c Mon Jan 11 16:28:39 2010 +0000
@@ -0,0 +1,399 @@
+/*-
+ * Copyright (c) 2005 David Schultz <das%FreeBSD.ORG@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: s_exp2.c,v 1.1 2010/01/11 16:28:39 christos Exp $");
+#ifdef __FBSDID
+__FBSDID("$FreeBSD: src/lib/msun/src/s_exp2.c,v 1.7 2008/02/22 02:27:34 das Exp $");
+#endif
+
+#include <float.h>
+
+#include "math.h"
+#include "math_private.h"
+
+#define TBLBITS 8
+#define TBLSIZE (1 << TBLBITS)
+
+static const double
+ huge = 0x1p1000,
+ redux = 0x1.8p52 / TBLSIZE,
+ P1 = 0x1.62e42fefa39efp-1,
+ P2 = 0x1.ebfbdff82c575p-3,
+ P3 = 0x1.c6b08d704a0a6p-5,
+ P4 = 0x1.3b2ab88f70400p-7,
+ P5 = 0x1.5d88003875c74p-10;
+
+static volatile double twom1000 = 0x1p-1000;
+
+static const double tbl[TBLSIZE * 2] = {
+/* exp2(z + eps) eps */
+ 0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
+ 0x1.6b052fa751744p-1, 0x1.8000p-50,
+ 0x1.6c012750bd9fep-1, -0x1.8780p-45,
+ 0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
+ 0x1.6dfb23c651a29p-1, -0x1.8000p-50,
+ 0x1.6ef9298593ae3p-1, -0x1.c000p-52,
+ 0x1.6ff7df9519386p-1, -0x1.fd80p-45,
+ 0x1.70f7466f42da3p-1, -0x1.c880p-45,
+ 0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
+ 0x1.72f8286eacf05p-1, -0x1.8300p-44,
+ 0x1.73f9a48a58152p-1, -0x1.0c00p-47,
+ 0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
+ 0x1.75feb564267f1p-1, 0x1.3e00p-47,
+ 0x1.77024b1ab6d48p-1, -0x1.7d00p-45,
+ 0x1.780694fde5d38p-1, -0x1.d000p-50,
+ 0x1.790b938ac1d00p-1, 0x1.3000p-49,
+ 0x1.7a11473eb0178p-1, -0x1.d000p-49,
+ 0x1.7b17b0976d060p-1, 0x1.0400p-45,
+ 0x1.7c1ed0130c133p-1, 0x1.0000p-53,
+ 0x1.7d26a62ff8636p-1, -0x1.6900p-45,
+ 0x1.7e2f336cf4e3bp-1, -0x1.2e00p-47,
+ 0x1.7f3878491c3e8p-1, -0x1.4580p-45,
+ 0x1.80427543e1b4ep-1, 0x1.3000p-44,
+ 0x1.814d2add1071ap-1, 0x1.f000p-47,
+ 0x1.82589994ccd7ep-1, -0x1.1c00p-45,
+ 0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
+ 0x1.8471a4623cab5p-1, 0x1.7100p-43,
+ 0x1.857f4179f5bbcp-1, 0x1.2600p-45,
+ 0x1.868d99b4491afp-1, -0x1.2c40p-44,
+ 0x1.879cad931a395p-1, -0x1.3000p-45,
+ 0x1.88ac7d98a65b8p-1, -0x1.a800p-45,
+ 0x1.89bd0a4785800p-1, -0x1.d000p-49,
+ 0x1.8ace5422aa223p-1, 0x1.3280p-44,
+ 0x1.8be05bad619fap-1, 0x1.2b40p-43,
+ 0x1.8cf3216b54383p-1, -0x1.ed00p-45,
+ 0x1.8e06a5e08664cp-1, -0x1.0500p-45,
+ 0x1.8f1ae99157807p-1, 0x1.8280p-45,
+ 0x1.902fed0282c0ep-1, -0x1.cb00p-46,
+ 0x1.9145b0b91ff96p-1, -0x1.5e00p-47,
+ 0x1.925c353aa2ff9p-1, 0x1.5400p-48,
+ 0x1.93737b0cdc64ap-1, 0x1.7200p-46,
+ 0x1.948b82b5f98aep-1, -0x1.9000p-47,
+ 0x1.95a44cbc852cbp-1, 0x1.5680p-45,
+ 0x1.96bdd9a766f21p-1, -0x1.6d00p-44,
+ 0x1.97d829fde4e2ap-1, -0x1.1000p-47,
+ 0x1.98f33e47a23a3p-1, 0x1.d000p-45,
+ 0x1.9a0f170ca0604p-1, -0x1.8a40p-44,
+ 0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
+ 0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
+ 0x1.9d674194bb8c5p-1, -0x1.c000p-49,
+ 0x1.9e86319e3238ep-1, 0x1.7d00p-46,
+ 0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
+ 0x1.a0c667b5de54dp-1, -0x1.5000p-48,
+ 0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
+ 0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
+ 0x1.a42c980460a5dp-1, -0x1.af00p-46,
Home |
Main Index |
Thread Index |
Old Index