Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
sinh.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2.1 of the GNU Lesser General Public License 
00007   as published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU Lesser General Public 
00021   License along with this program; if not, write the Free Software 
00022   Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 
00023   USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 
00037 /*   VMS Compatibility Version  @(#)sinh.c      1.1    7/18/87
00038  */
00039 /*
00040         sinh(arg) returns the hyperbolic sine of its floating-
00041         point argument.
00042 
00043         The exponential function is called for arguments
00044         greater in magnitude than 0.5.
00045 
00046         A series is used for arguments smaller in magnitude than 0.5.
00047         The coefficients are #2029 from Hart & Cheney. (20.36D)
00048 
00049         cosh(arg) is computed from the exponential function for
00050         all arguments.
00051 */
00052 #include "cmplrs/host.h"
00053 #include <math.h>
00054 #include "moremath.h"
00055 
00056 static double_t p0  = -0.6307673640497716991184787251e+6;
00057 static double_t p1  = -0.8991272022039509355398013511e+5;
00058 static double_t p2  = -0.2894211355989563807284660366e+4;
00059 static double_t p3  = -0.2630563213397497062819489e+2;
00060 static double_t q0  = -0.6307673640497716991212077277e+6;
00061 static double_t q1   = 0.1521517378790019070696485176e+5;
00062 static double_t q2  = -0.173678953558233699533450911e+3;
00063 
00064 double_t
00065 sinh(doublt_t arg)
00066 {
00067         double_t temp, argsq;
00068         register int32 sign;
00069 
00070         sign = 1;
00071         if(arg < 0) {
00072                 arg = - arg;
00073                 sign = -1;
00074         }
00075 
00076         if(arg > 21.) {
00077                 temp = exp(arg)/2;
00078                 if (sign>0)
00079                         return(temp);
00080                 else
00081                         return(-temp);
00082         }
00083 
00084         if(arg > 0.5) {
00085                 return(sign*(exp(arg) - exp(-arg))/2);
00086         }
00087 
00088         argsq = arg*arg;
00089         temp = (((p3*argsq+p2)*argsq+p1)*argsq+p0)*arg;
00090         temp /= (((argsq+q2)*argsq+q1)*argsq+q0);
00091         return(sign*temp);
00092 }
00093 
00094 double_t
00095 cosh(double_t arg)
00096 {
00097         if(arg < 0)
00098                 arg = - arg;
00099         if(arg > 21.) {
00100                 return(exp(arg)/2);
00101         }
00102 
00103         return((exp(arg) + exp(-arg))/2);
00104 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines