⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ansimath.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ansiMath.c - ANSI `math' documentation *//* Copyright 1992-1995 Wind River Systems, Inc. *//*modification history--------------------01j,23may01,to   doc fix for frexp()01j,03jan01,pes  Fix compiler warnings.01i,04feb99,dgp  document errno values.01h,19mar95,dvs  removed TRON reference - no longer supported.01g,10feb95,rhp  update from subsidiary files01f,16jan95,rhp  library man page: correct spelling of HUGE_VAL01e,13mar93,jdi  doc tweak.01d,05feb93,jdi  doc changes based on kdl review.01c,02dec92,jdi  doc tweaks.01b,28oct92,jdi  updated with new versions of .c files01a,24oct92,smb  documentation*//*DESCRIPTIONThe header math.h declares several mathematical functions and defines onemacro.  The functions take double arguments and return double values.The macro defined is:.iP `HUGE_VAL' 15expands to a positive double expression, not necessarily representableas a float..LPThe behavior of each of these functions is defined for all representablevalues of their input arguments.  Each function executes as if it were asingle operation, without generating any externally visible exceptions.For all functions, a domain error occurs if an input argument is outsidethe domain over which the mathematical function is defined.  Thedescription of each function lists any applicable domain errors.  On adomain error, the function returns an implementation-defined value; thevalue EDOM is stored in `errno'.Similarly, a range error occurs if the result of the function cannot berepresented as a double value.  If the result overflows (the magnitude ofthe result is so large that it cannot be represented in an object of thespecified type), the function returns the value HUGE_VAL, with the samesign (except for the tan() function) as the correct value of the function;the value ERANGE is stored in `errno'.  If the result underflows (thetype), the function returns zero; whether the integer expression `errno'acquires the value ERANGE is implementation defined.INCLUDE FILES: math.hSEE ALSO: mathALib, American National Standard X3.159-1989INTERNALWhen generating man pages, the man pages from this library should bebuilt AFTER those from arch/mc68k/math/mathALib.  Thus, where there areequivalent man pages in both ansiMath and mathALib, the ones in ansiMathwill overwrite those from mathALib, which is the correct behavior.This ordering is set up in the overall makefile system.INTERNALThis module is built by appending the following files:    asincos.c    atan.c    atan2.c    ceil.c    cosh.c    exp.c    fabs.c    floor.c    fmod.c    frexp.c    ldexp.c    log.c    log10.c    modf.c    pow.c    sincos.c    sinh.c    sqrt.c    tan.c    tanh.c*//* asincos.c - inverse sine and cosine math routines *//* Copyright 1992-1994 Wind River Systems, Inc. *//*modification history--------------------01h,09dec94,rhp  fix man pages for inverse trig fns01g,05feb93,jdi  doc changes based on kdl review.01f,02dec92,jdi  doc tweaks.01e,28oct92,jdi  documentation cleanup.01d,13oct92,jdi  mangen fixes.01c,21sep92,smb  corrected file name in first line of file.01b,20sep92,smb  documentation additions01a,08jul92,smb  documentation*//*DESCRIPTION * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley.  The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * 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 * the sendbug(8) program, to the authors.SEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "math.h"/********************************************************************************* asin - compute an arc sine (ANSI)** This routine returns the principal value of the arc sine of <x>* in double precision (IEEE double, 53 bits).* If <x> is the sine of an angle <T>, this function returns <T>.** A domain error occurs for arguments not in the range [-1,+1].** INTERNAL* Method:*     asin(x) = atan2(x,sqrt(1-x*x))* For better accuracy, 1-x*x is computed as follows:*     1-x*x                     if x <  0.5,*     2*(1-|x|)-(1-|x|)*(1-|x|) if x >= 0.5.** INCLUDE FILES: math.h** RETURNS:* The double-precision arc sine of <x> in the range [-pi/2,pi/2] radians.** Special cases:*     If <x> is NaN, asin() returns <x>.*     If |x|>1, it returns NaN.** SEE ALSO: mathALib** INTERNAL* Coded in C by K.C. Ng, 4/16/85, REVISED ON 6/10/85.*/double asin    (    double x	/* number between -1 and 1 */    )    {	double s,t,copysign(),atan2(),sqrt(),one=1.0;#if !defined(vax)&&!defined(tahoe)	if(x!=x) return(x);	/* x is NaN */#endif	/* !defined(vax)&&!defined(tahoe) */	s=copysign(x,one);	if(s <= 0.5)	    return(atan2(x,sqrt(one-x*x)));	else	    { t=one-s; s=t+t; return(atan2(x,sqrt(s-t*t))); }    }/********************************************************************************* acos - compute an arc cosine (ANSI)** This routine returns principal value of the arc cosine of <x>* in double precision (IEEE double, 53 bits).* If <x> is the cosine of an angle <T>, this function returns <T>.** A domain error occurs for arguments not in the range [-1,+1].** INTERNAL* Method:*			      ________*                           / 1 - x*	acos(x) = 2*atan2( / -------- , 1 ) .*                        \/   1 + x** INCLUDE FILES: math.h** RETURNS:* The double-precision arc cosine of <x> in the range [0,pi] radians.** Special cases:*     If <x> is NaN, acos() returns <x>.*     If |x|>1, it returns NaN.** SEE ALSO: mathALib** INTERNAL* Coded in C by K.C. Ng, 4/16/85, revised on 6/10/85.*/double acos    (    double x	/* number between -1 and 1 */    )    {	double t,copysign(),atan2(),sqrt(),one=1.0;#if !defined(vax)&&!defined(tahoe)	if(x!=x) return(x);#endif	/* !defined(vax)&&!defined(tahoe) */	if( x != -1.0)	    t=atan2(sqrt((one-x)/(one+x)),one);	else	    t=atan2(one,0.0);	/* t = PI/2 */	return(t+t);    }/* atan.c - math routines *//* Copyright 1992-1994 Wind River Systems, Inc. *//*modification history--------------------01d,09dec94,rhp  fix man pages for inverse trig fns01e,05feb93,jdi  doc changes based on kdl review.01d,02dec92,jdi  doc tweaks.01c,28oct92,jdi  documentation cleanup.01b,20sep92,smb  documentation additions01a,08jul92,smb  documentation.*//*DESCRIPTION* Copyright (c) 1985 Regents of the University of California.* All rights reserved.** Redistribution and use in source and binary forms are permitted* provided that the above copyright notice and this paragraph are* duplicated in all such forms and that any documentation,* advertising materials, and other materials related to such* distribution and use acknowledge that the software was developed* by the University of California, Berkeley.  The name of the* University may not be used to endorse or promote products derived* from this software without specific prior written permission.* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.** 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* the sendbug(8) program, to the authors.SEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "math.h"/********************************************************************************* atan - compute an arc tangent (ANSI)** This routine returns the principal value of the arc tangent of <x> in* double precision (IEEE double, 53 bits).* If <x> is the tangent of an angle <T>, this function returns <T> * (in radians).** INCLUDE FILES: math.h** RETURNS:* The double-precision arc tangent of <x> in the range [-pi/2,pi/2] radians.* Special case:	if <x> is NaN, atan() returns <x> itself.** SEE ALSO: mathALib** INTERNAL:* Coded in C by K.C. Ng, 4/16/85, revised on 6/10/85.*/double atan    (    double x	/* tangent of an angle */    )    {	double atan2(),one=1.0;	return(atan2(x,one));    }/* atan2.c - math routines *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01e,05feb93,jdi  doc changes based on kdl review.01d,02dec92,jdi  doc tweaks.01c,28oct92,jdi  documentation cleanup.01b,20sep92,smb  documentation additions01a,08jul92,smb  documentation.*//*DESCRIPTION* Copyright (c) 1985 Regents of the University of California.* All rights reserved.** Redistribution and use in source and binary forms are permitted* provided that the above copyright notice and this paragraph are* duplicated in all such forms and that any documentation,* advertising materials, and other materials related to such* distribution and use acknowledge that the software was developed* by the University of California, Berkeley.  The name of the* University may not be used to endorse or promote products derived* from this software without specific prior written permission.* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.** 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* the sendbug(8) program, to the authors.*SEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "math.h"#if defined(vax)||defined(tahoe) 	/* VAX D format */#ifdef vax#define _0x(A,B)	0x/**/A/**/B#else	/* vax */#define _0x(A,B)	0x/**/B/**/A#endif	/* vax *//*static double *//*athfhi =  4.6364760900080611433E-1  ,*//*Hex  2^ -1   *  .ED63382B0DDA7B *//*athflo =  1.9338828231967579916E-19 ,*//*Hex  2^-62   *  .E450059CFE92C0 *//*PIo4   =  7.8539816339744830676E-1  ,*//*Hex  2^  0   *  .C90FDAA22168C2 *//*at1fhi =  9.8279372324732906796E-1  ,*//*Hex  2^  0   *  .FB985E940FB4D9 *//*at1flo = -3.5540295636764633916E-18 ,*//*Hex  2^-57   * -.831EDC34D6EAEA *//*PIo2   =  1.5707963267948966135E0   ,*//*Hex  2^  1   *  .C90FDAA22168C2 *//*PI     =  3.1415926535897932270E0   ,*//*Hex  2^  2   *  .C90FDAA22168C2 *//*a1     =  3.3333333333333473730E-1  ,*//*Hex  2^ -1   *  .AAAAAAAAAAAB75 *//*a2     = -2.0000000000017730678E-1  ,*//*Hex  2^ -2   * -.CCCCCCCCCD946E *//*a3     =  1.4285714286694640301E-1  ,*//*Hex  2^ -2   *  .92492492744262 *//*a4     = -1.1111111135032672795E-1  ,*//*Hex  2^ -3   * -.E38E38EBC66292 *//*a5     =  9.0909091380563043783E-2  ,*//*Hex  2^ -3   *  .BA2E8BB31BD70C *//*a6     = -7.6922954286089459397E-2  ,*//*Hex  2^ -3   * -.9D89C827C37F18 *//*a7     =  6.6663180891693915586E-2  ,*//*Hex  2^ -3   *  .8886B4AE379E58 *//*a8     = -5.8772703698290408927E-2  ,*//*Hex  2^ -4   * -.F0BBA58481A942 *//*a9     =  5.2170707402812969804E-2  ,*//*Hex  2^ -4   *  .D5B0F3A1AB13AB *//*a10    = -4.4895863157820361210E-2  ,*//*Hex  2^ -4   * -.B7E4B97FD1048F *//*a11    =  3.3006147437343875094E-2  ,*//*Hex  2^ -4   *  .8731743CF72D87 *//*a12    = -1.4614844866464185439E-2  ;*//*Hex  2^ -6   * -.EF731A2F3476D9 */static long athfhix[] = { _0x(6338,3fed), _0x(da7b,2b0d)};#define athfhi	(*(double *)athfhix)static long athflox[] = { _0x(5005,2164), _0x(92c0,9cfe)};#define athflo	(*(double *)athflox)static long   PIo4x[] = { _0x(0fda,4049), _0x(68c2,a221)};#define   PIo4	(*(double *)PIo4x)static long at1fhix[] = { _0x(985e,407b), _0x(b4d9,940f)};#define at1fhi	(*(double *)at1fhix)static long at1flox[] = { _0x(1edc,a383), _0x(eaea,34d6)};#define at1flo	(*(double *)at1flox)static long   PIo2x[] = { _0x(0fda,40c9), _0x(68c2,a221)};#define   PIo2	(*(double *)PIo2x)static long     PIx[] = { _0x(0fda,4149), _0x(68c2,a221)};#define     PI	(*(double *)PIx)static long     a1x[] = { _0x(aaaa,3faa), _0x(ab75,aaaa)};#define     a1	(*(double *)a1x)static long     a2x[] = { _0x(cccc,bf4c), _0x(946e,cccd)};#define     a2	(*(double *)a2x)static long     a3x[] = { _0x(4924,3f12), _0x(4262,9274)};#define     a3	(*(double *)a3x)static long     a4x[] = { _0x(8e38,bee3), _0x(6292,ebc6)};#define     a4	(*(double *)a4x)static long     a5x[] = { _0x(2e8b,3eba), _0x(d70c,b31b)};#define     a5	(*(double *)a5x)static long     a6x[] = { _0x(89c8,be9d), _0x(7f18,27c3)};#define     a6	(*(double *)a6x)static long     a7x[] = { _0x(86b4,3e88), _0x(9e58,ae37)};#define     a7	(*(double *)a7x)static long     a8x[] = { _0x(bba5,be70), _0x(a942,8481)};#define     a8	(*(double *)a8x)static long     a9x[] = { _0x(b0f3,3e55), _0x(13ab,a1ab)};#define     a9	(*(double *)a9x)static long    a10x[] = { _0x(e4b9,be37), _0x(048f,7fd1)};#define    a10	(*(double *)a10x)static long    a11x[] = { _0x(3174,3e07), _0x(2d87,3cf7)};#define    a11	(*(double *)a11x)static long    a12x[] = { _0x(731a,bd6f), _0x(76d9,2f34)};#define    a12	(*(double *)a12x)#else	/* defined(vax)||defined(tahoe) */static doubleathfhi =  4.6364760900080609352E-1    , /*Hex  2^ -2   *  1.DAC670561BB4F */athflo =  4.6249969567426939759E-18   , /*Hex  2^-58   *  1.5543B8F253271 */PIo4   =  7.8539816339744827900E-1    , /*Hex  2^ -1   *  1.921FB54442D18 */at1fhi =  9.8279372324732905408E-1    , /*Hex  2^ -1   *  1.F730BD281F69B */at1flo = -2.4407677060164810007E-17   , /*Hex  2^-56   * -1.C23DFEFEAE6B5 */PIo2   =  1.5707963267948965580E0     , /*Hex  2^  0   *  1.921FB54442D18 */PI     =  3.1415926535897931160E0     , /*Hex  2^  1   *  1.921FB54442D18 */a1     =  3.3333333333333942106E-1    , /*Hex  2^ -2   *  1.55555555555C3 */a2     = -1.9999999999979536924E-1    , /*Hex  2^ -3   * -1.9999999997CCD */a3     =  1.4285714278004377209E-1    , /*Hex  2^ -3   *  1.24924921EC1D7 */a4     = -1.1111110579344973814E-1    , /*Hex  2^ -4   * -1.C71C7059AF280 */a5     =  9.0908906105474668324E-2    , /*Hex  2^ -4   *  1.745CE5AA35DB2 */a6     = -7.6919217767468239799E-2    , /*Hex  2^ -4   * -1.3B0FA54BEC400 */a7     =  6.6614695906082474486E-2    , /*Hex  2^ -4   *  1.10DA924597FFF */a8     = -5.8358371008508623523E-2    , /*Hex  2^ -5   * -1.DE125FDDBD793 */a9     =  4.9850617156082015213E-2    , /*Hex  2^ -5   *  1.9860524BDD807 */a10    = -3.6700606902093604877E-2    , /*Hex  2^ -5   * -1.2CA6C04C6937A */a11    =  1.6438029044759730479E-2    ; /*Hex  2^ -6   *  1.0D52174A1BB54 */#endif	/* defined(vax)||defined(tahoe) *//********************************************************************************* atan2 - compute the arc tangent of y/x (ANSI)** This routine returns the principal value of the arc tangent of <y>/<x> in* double precision (IEEE double, 53 bits).* This routine uses the signs of both arguments to determine the quadrant of the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -