?? mathsoftlib.c
字號:
/******************************************************************************** mathSoftAsinf - single-precision software floating point arc sine** This routine takes the input single-precision floating point* parameter and returns the arc sine.** RETURNS: single-precision arc sine value.*/LOCAL float mathSoftAsinf ( float fltParam ) { return atanf (fltParam / sqrtf (1.0 - fltParam * fltParam)); }/******************************************************************************** mathSoftAcosf - single-precision software floating point arc cosine** This routine takes the input single-precision floating point* parameter and returns the arc cosine.** RETURNS: single-precision arc cosine value.*/LOCAL float mathSoftAcosf ( float fltParam ) { float result; result = atanf (sqrtf(1.0 - fltParam * fltParam) / fltParam); if (fltParam < 0.0) return (result + PI_SINGLE); /* [pi/2 .. pi] */ else return (result); /* [0 .. pi/2) */ }/******************************************************************************** mathSoftAtan2f - single-precision software arc tangent of two arguments** This routine takes two input single-precision floating point* parameters, <fltY> and <fltX>, and returns the single precision* arc tangent of <fltY> / <fltX>.** RETURNS: single-precision arc tangent of <fltY> / <fltX>.*/LOCAL float mathSoftAtan2f ( float fltY, float fltX ) { float result; result = atanf(fltY/fltX); if (fltX >= 0.0) return (result); /* [-pi/2 .. pi/2) */ else if (result < 0.0) return (result + PI_SINGLE); /* [pi/2 .. pi) */ else return (result - PI_SINGLE); /* [-pi .. -pi/2) */ }/******************************************************************************** mathSoftHypotf - single-precision software floating point Euclidean distance** This routine takes two input single-precision floating point* parameters and returns length of the corresponding Euclidean distance* (hypotenuse).** RETURNS: single-precision hypotenuse.*/LOCAL float mathSoftHypotf ( float fltX, float fltY ) { return (sqrtf (fltX * fltX + fltY * fltY)); }/******************************************************************************** mathSoftCbrtf - single-precision software floating point cube root** This routine takes the input single-precision floating point* parameter and returns the cube root.** RETURNS: single-precision cube root.** AUTHOR: Kahan's cube root, coded in C by K.C. Ng, UC Berkeley, 4/30/85.* Copyright (c) 1985 Regents of the University of California.* Adapted by Scott Huddleston, Computer Research Lab, Tektronix.*/LOCAL float mathSoftCbrtf ( float x ) { float r,s,t=0.0; unsigned long *px = (unsigned long *) &x, *pt = (unsigned long *) &t, mexp,sign; static long B0 = 0x4b800000; /* (float) 2**24 */ static long B1 = 0x2a4ed9f4, B2 = 0x29ced9f4; /* B1 / (float) 2**8 */ static float C= 19./35., D= -864./1225., E= 99./70., F= 45./28., G= 5./14.;#ifdef NATIONAL /* ordering of words in a floating points number */ int n0=1;#else int n0=0;#endif mexp = px[n0]&0x7ff00000; if(isINFNaN_SINGLE(x)) return(x); /* cbrt(NaN,INF) is itself */ if(x==0.0) return(x); /* cbrt(0) is itself */ sign=px[n0]&0x80000000; /* sign= sign(x) */ px[n0] ^= sign; /* x=|x| */ /* rough cbrt to 5 bits */ if(mexp==0) /* subnormal number */ {pt[n0]=B0; /* scale t to be normal, 2^54 or 2^18 */ t*=x; pt[n0]=pt[n0]/3+B2; } else pt[n0]=px[n0]/3+B1; /* new cbrt to 23 bits, may be implemented in single precision */ r=t*t/x; s=C+r*t; t*=G+F/(s+E+D/s); /* restore the sign bit */ pt[n0] |= sign; return(t); }/********************************************************************************* mathSoftLog2f - single-precision emulation for floating point log base 2** This routine returns a single-precision log base 2 of a single-precision* floating point number.** Computes log2(x) from:** log2(x) = log2(e) * log(x)*** RETURNS: single-precision log base 2**/LOCAL float mathSoftLog2f ( float fltParam ) { return (LOG2E * logf (fltParam)); }/********************************************************************************* mathSoftSincosf - single-precision emulation for simultaneous sine and cosine** This routine obtains both the sine and cosine for the specified* floating point value and returns both.** NOMANUAL*/void mathSoftSincosf ( float fltParam, /* angle in radians */ float *pSinResult, /* sine result buffer */ float *pCosResult /* cosine result buffer */ ) { *pSinResult = sinf (fltParam); *pCosResult = cosf (fltParam); }/********************************************************************************* mathSoftFmod - double-precision software floating-point modulus** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftFmod ( double dblParam, /* argument */ double dblDivisor /* divisor */ ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "fmod", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftIrint - double-precision software floating-point round to integer** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftIrint ( double dblParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "irint", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftIround - double-precision software floating-point round to nearest** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftIround ( double dblParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "iround", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftRound - double-precision software floating-point round** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftRound ( double dblParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "round", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftTrunc - double-precision software floating-point truncation** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftTrunc ( double dblParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "trunc", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftFmodf - single-precision software floating-point modulus** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftFmodf ( float fltParam, /* argument */ float fltDivisor /* divisor */ ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "fmodf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftIrintf - single-precision software floating-point round to integer** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftIrintf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "irintf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftIroundf - single-precision software floating-point round to nearest** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftIroundf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "iroundf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftRoundf - single-precision software floating-point round** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftRoundf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "roundf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftCoshf - single-precision software hyperbolic cosine** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftCoshf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "coshf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftSinhf - single-precision software hyperbolic sine** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftSinhf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "sinhf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftTanhf - single-precision software hyperbolic tangent** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftTanhf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "tanhf", 0, 0, 0, 0, 0); }/********************************************************************************* mathSoftTruncf - single-precision software floating-point truncation** THIS FUNCTION IS NOT SUPPORTED. If called, a logMsg() call will display* an error message on the VxWorks console.**/LOCAL void mathSoftTruncf ( float fltParam ) { if (_func_logMsg != NULL) (* _func_logMsg) (errMsgString, (int) "truncf", 0, 0, 0, 0, 0); }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -