BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / libm / common_source / exp__E.c
index 01ddeb6..4d452dc 100644 (file)
@@ -1,20 +1,39 @@
-/* 
+/*
  * Copyright (c) 1985 Regents of the University of California.
  * Copyright (c) 1985 Regents of the University of California.
- * 
- * Use and reproduction of this software are granted  in  accordance  with
- * the terms and conditions specified in  the  Berkeley  Software  License
- * Agreement (in particular, this entails acknowledgement of the programs'
- * source, and inclusion of this notice) with the additional understanding
- * that  all  recipients  should regard themselves as participants  in  an
- * ongoing  research  project and hence should  feel  obligated  to report
- * their  experiences (good or bad) with these elementary function  codes,
- * using "sendbug 4bsd-bugs@BERKELEY", to the authors.
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] =
-"@(#)exp__E.c  1.2 (Berkeley) 8/21/85; 1.4 (ucb.elefunt) %G%";
-#endif not lint
+static char sccsid[] = "@(#)exp__E.c   5.6 (Berkeley) 10/9/90";
+#endif /* not lint */
 
 /* exp__E(x,c)
  * ASSUMPTION: c << x  SO THAT  fl(x+c)=x.
 
 /* exp__E(x,c)
  * ASSUMPTION: c << x  SO THAT  fl(x+c)=x.
@@ -67,44 +86,40 @@ static char sccsid[] =
  * shown.
  */
 
  * shown.
  */
 
-#if (defined(VAX)||defined(TAHOE))     /* VAX D format */
-/* static double */
-/* p1     =  1.5150724356786683059E-2    , Hex  2^ -6   *  .F83ABE67E1066A */
-/* p2     =  6.3112487873718332688E-5    , Hex  2^-13   *  .845B4248CD0173 */
-/* q1     =  1.1363478204690669916E-1    , Hex  2^ -3   *  .E8B95A44A2EC45 */
-/* q2     =  1.2624568129896839182E-3    , Hex  2^ -9   *  .A5790572E4F5E7 */
-/* q3     =  1.5021856115869022674E-6    ; Hex  2^-19   *  .C99EB4604AC395 */
-static long        p1x[] = { 0x3abe3d78, 0x066a67e1};
-static long        p2x[] = { 0x5b423984, 0x017348cd};
-static long        q1x[] = { 0xb95a3ee8, 0xec4544a2};
-static long        q2x[] = { 0x79053ba5, 0xf5e772e4};
-static long        q3x[] = { 0x9eb436c9, 0xc395604a};
-#define       p1    (*(double*)p1x)
-#define       p2    (*(double*)p2x)
-#define       q1    (*(double*)q1x)
-#define       q2    (*(double*)q2x)
-#define       q3    (*(double*)q3x)
-#else  /* IEEE double */
-static double 
-p1     =  1.3887401997267371720E-2    , /*Hex  2^ -7   *  1.C70FF8B3CC2CF */
-p2     =  3.3044019718331897649E-5    , /*Hex  2^-15   *  1.15317DF4526C4 */
-q1     =  1.1110813732786649355E-1    , /*Hex  2^ -4   *  1.C719538248597 */
-q2     =  9.9176615021572857300E-4    ; /*Hex  2^-10   *  1.03FC4CB8C98E8 */
+#include "mathimpl.h"
+
+vc(p1, 1.5150724356786683059E-2 ,3abe,3d78,066a,67e1,  -6, .F83ABE67E1066A)
+vc(p2, 6.3112487873718332688E-5 ,5b42,3984,0173,48cd, -13, .845B4248CD0173)
+vc(q1, 1.1363478204690669916E-1 ,b95a,3ee8,ec45,44a2,  -3, .E8B95A44A2EC45)
+vc(q2, 1.2624568129896839182E-3 ,7905,3ba5,f5e7,72e4,  -9, .A5790572E4F5E7)
+vc(q3, 1.5021856115869022674E-6 ,9eb4,36c9,c395,604a, -19, .C99EB4604AC395)
+
+ic(p1, 1.3887401997267371720E-2,  -7, 1.C70FF8B3CC2CF)
+ic(p2, 3.3044019718331897649E-5, -15, 1.15317DF4526C4)
+ic(q1, 1.1110813732786649355E-1,  -4, 1.C719538248597)
+ic(q2, 9.9176615021572857300E-4, -10, 1.03FC4CB8C98E8)
+
+#ifdef vccast
+#define       p1    vccast(p1)
+#define       p2    vccast(p2)
+#define       q1    vccast(q1)
+#define       q2    vccast(q2)
+#define       q3    vccast(q3)
 #endif
 
 double exp__E(x,c)
 double x,c;
 {
 #endif
 
 double exp__E(x,c)
 double x,c;
 {
-       static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19;
-       double copysign(),z,p,q,xp,xh,w;
+       const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19;
+       double z,p,q,xp,xh,w;
        if(copysign(x,one)>small) {
            z = x*x  ;
           p = z*( p1 +z* p2 );
        if(copysign(x,one)>small) {
            z = x*x  ;
           p = z*( p1 +z* p2 );
-#if (defined(VAX)||defined(TAHOE))
+#if defined(vax)||defined(tahoe)
            q = z*( q1 +z*( q2 +z* q3 ));
            q = z*( q1 +z*( q2 +z* q3 ));
-#else  /* IEEE double */
+#else  /* defined(vax)||defined(tahoe) */
            q = z*( q1 +z*  q2 );
            q = z*( q1 +z*  q2 );
-#endif
+#endif /* defined(vax)||defined(tahoe) */
            xp= x*p     ; 
           xh= x*half  ;
            w = xh-(q-xp)  ;
            xp= x*p     ; 
           xh= x*half  ;
            w = xh-(q-xp)  ;