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

📄 mwutil.h

📁 《精通matlab与c++混合编程》的光盘内容
💻 H
📖 第 1 页 / 共 4 页
字号:
#define utDoubleScalarAtanh(a) 	utFdlibm_atanh(a)

/* ceil(a) */
#define utDoubleScalarCeil(a)  utFdlibm_ceil(a)

/* cos(a) */
#define utDoubleScalarCos(a) utFdlibm_cos(a)

/* cosh(a) */
#define utDoubleScalarCosh(a) utFdlibm_cosh(a)

/* cot(a) */
/* A warning 'Divide by zero' should be issued by users for a = 0 */
#define utDoubleScalarCot(a) 1.0/utFdlibm_tan(a)
	
/* coth(a) */
/*A warning 'Divide by zero' should be issued by users for a = 0 */
#define utDoubleScalarCoth(a) 1.0/utFdlibm_tanh(a)
			
/* csc(a) */
/*A warning 'Divide by zero' should be issued by users for a = 0 */
#define utDoubleScalarCsc(a) 1.0/utFdlibm_sin(a)

/* csch(a) */
/*A warning 'Divide by zero' should be issued by users for a = 0 */
#define utDoubleScalarCsch(a) 1.0/utFdlibm_sinh(a)

/* dot(a,b) */
#define utDoubleScalarDot(a,b) ((a)*(b))

/* double(a) */
#define utDoubleScalarDouble(a) (a)

/* exp(a) */	
#define utDoubleScalarExp(a)  utFdlibm_exp(a)

/* floor(a) */
#define utDoubleScalarFloor(a)  utFdlibm_floor(a)

/* full(a) */
#define utDoubleScalarFull(a)  (a)

/* imag(a) */
#define utDoubleScalarImag(a)  0.0

/* int8(a) */
#define utDoubleScalarInt8(a)  ( utIsNaN(a)                             \
                                         ? 0.0                          \
                                         : ( (a) > 127.                 \
                                              ? 127.                    \
                                              : ( (a) <= -128.          \
                                                   ? -128.              \
                                                   :  (char)(a))))

/* int16(a) */
#define utDoubleScalarInt16(a)  ( utIsNaN(a)                            \
                                          ? 0.0                         \
                                          : ( (a) > 32767.              \
                                               ?  32767.                \
                                               : ( (a) <= -32768.       \
                                                    ? -32768.           \
                                                    : (int)(a))))

/* int32(a) */
#define utDoubleScalarInt32(a)  ( utIsNaN(a)                            \
                                          ? 0.0                         \
                                          : ( (a) > 2147483647.         \
                                               ? 2147483647.            \
                                               : ( (a) <= -2147483648.  \
                                                    ? -2147483648.      \
                                                    :  (long)(a))))

/* isequal(a,b) */
#define utDoubleScalarIsequal(a,b)  (!utIsNaN(a) && !utIsNaN(b) && (a) == (b))

/* isempty(a) */
#define utDoubleScalarIsempty(a)  false

/* isfinite(a) */
#define utDoubleScalarIsfinite(a) (!( utIsInf(a) || utIsNaN(a) ))

/* is almost zero */
#define utDoubleScalarIsAlmostZero(a)                                   \
        (fabs((a) - utDoubleScalarRound(a)) <= utGetEps() * fabs(a))

/* islogical(a) */
#define utDoubleScalarIslogical(a)  false

/* ismember(a,b) */
#define utDoubleScalarIsmember(a,b) (!utIsNaN(a) && !utIsNaN(b) &&((a) == (b)))

/* isreal(a) */
#define utDoubleScalarIsreal(a)  true

/* issparse(a) */
#define utDoubleScalarIssparse(a) false

/* length(a) */
#define utDoubleScalarLength(a)  1

/* log */
/*A warning 'Log of zero' should be issued by users for a = 0 */
#define utDoubleScalarLog(a) utFdlibm_log(a)

/* log2 */
/*A warning 'Log of zero' should be issued by users for a = 0 */
#define utDoubleScalarLog2(a) (utFdlibm_log(a)/utFdlibm_log(2.0))
                             
/* log10 */
/*A warning 'Log of zero' should be issued by users for a = 0 */
#define utDoubleScalarLog10(a) utFdlibm_log10(a)


/* max(a,b) */

/*
	Maximum between a and b
*/
extern double utDoubleScalarMax( double a, double b);


/* min(a,b) */

/*
	Minimum between a and b
*/
extern double utDoubleScalarMin( double a,double b);


/* ndims(a) */
#define utDoubleScalarNdims(a)  2.0

/* power(a,b) */
#define utDoubleScalarPower(a,b) utFdlibm_pow(a,b)

/* pow2(a) */
#define utDoubleScalarPow2(a) utFdlibm_pow(2.0,a)

/* real(a) */
#define utDoubleScalarReal(a) (a)

/* rem */
/*A warning Divide by zero should be issued by users for a or b = {NaN,Inf} */
#define utDoubleScalarRem(a,b) ( !utDoubleScalarIsfinite(a) ||  !utDoubleScalarIsfinite(b)    \
                                 ? utGetNaN()                                                 \
                                 :(utDoubleScalarIsAlmostZero((a)/(b))                        \
                                      ? 0.0                                                   \
                                      : (a) - utDoubleScalarFix((a)/(b)) * (b)))
/* round(a) */
#define utDoubleScalarRound(a) 	((a) < 0.0                                 \
                                  ? -utDoubleScalarFloor(fabs(a) + 0.5)    \
                                  : utDoubleScalarFloor(fabs(a) + 0.5))
/* sec(a) */				
#define utDoubleScalarSec(a) (1.0/utFdlibm_cos(a))

/* sech(a) */
#define utDoubleScalarSech(a) (1.0/utFdlibm_cosh(a))

/* sin(a) */
#define utDoubleScalarSin(a) utFdlibm_sin(a)

/* single(a) */
#define utDoubleScalarSingle(a)  ((float)a)

/* sign(a) */
#define utDoubleScalarSign(a) (utIsNaN(a)                               \
                                       ? utGetNaN()                     \
                                       :( a == 0.0                      \
                                               ? 0.0                    \
                                               : (a < 0.0               \
                                                        ? -1.0          \
                                                           : 1.0)))

/* sinh(a) */
#define utDoubleScalarSinh(a) utFdlibm_sinh(a)

/* sqrt(a) */
#define utDoubleScalarSqrt(a) ( utIsNaN(a) || a < 0.0 ?  utGetNaN() : sqrt(a))

/* tan(a) */
#define utDoubleScalarTan(a) utFdlibm_tan(a)

/* tanh(a) */
#define utDoubleScalarTanh(a) utFdlibm_tanh(a)
		
/* uint8(a) */
#define utDoubleScalarUint8(a)  ( utIsNaN(a)                            \
                                  ? 0.0                                 \
                                  : ( (a) > 255.                        \
                                       ?  255.                          \
                                       : ( (a) < 0.0                    \
                                            ? 0.0                       \
                                            : (unsigned char)(a))))

/* uint16(a) */
#define utDoubleScalarUint16(a)  ( utIsNaN(a)                           \
                                   ? 0.0                                \
                                   :( (a) > 65535.                      \
                                       ? 65535.                         \
                                       : ((a) < 0.0                     \
                                           ? 0.0                        \
                                           :  (unsigned int)(a))))

/* uint32(a) */
#define utDoubleScalarUint32(a)  ( utIsNaN(a)                           \
                                   ? 0.0                                \
                                   : ((a) > 4294967295.                 \
                                       ? 4294967295.                    \
                                       : ((a) < 0.0                     \
                                           ? 0.0                        \
                                           : (unsigned long)(a))))

/* xor(a,b) */
/*An error message should be issued by users if a or b = NaN */
#define utDoubleScalarXor(a,b)                             \
        ((a) == 0.0                                        \
          ? ((b) == 0.0                                    \
              ? 0.0                                        \
              : 1.0)                                       \
          : ((b) == 0.0                                    \
              ? 1.0                                        \
              : 0.0))



/* mod(a,b) */
extern double utDoubleScalarMod(double a, double b);


/* 
 * convert a double to an signed integer
 *      returns INT_MAX on positive overflow or NaN conversion
 *      returns INT_MIN on negative overflow
 * 
 *      sets errno to ERANGE on overflow
 *      sets errno to EDOM on domain error (NaN conversion)
 */
extern int utDbl2Int(double x);


/* 
 * convert a double to an unsigned integer
 *      returns UINT_MAX on positive overflow or NaN conversion
 * 
 *      sets errno to ERANGE on overflow
 *      sets errno to EDOM on domain error (NaN conversion)
 */
extern unsigned int utDbl2UInt(double x);


/*
 * floor(x)
 * Return x rounded toward -inf to integral value
 */
extern double utFdlibm_floor(double x);


/*
 * ceil(x)
 * Return x rounded toward -inf to integral value
 */
extern double utFdlibm_ceil(double x);


/*
 * For non-zero x 
 *	x = frexp(arg,&exp);
 * returns a double fp quantity x such that 0.5 <= |x| <1.0
 * and the corresponding binary exponent "exp". That is
 *	arg = x*2^exp.
 * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg 
 * with *exp=0. 
 */
extern double utFdlibm_frexp(double x, int *eptr);


/*
 * ilogb(double x)
 * returns the binary exponent of non-zero x
 * ilogb(0) = 0x80000001
 * ilogb(inf/NaN) = 0x7fffffff (no signal is raised)
 */
extern int utFdlibm_ilogb(double x);


/* 
 * scalbn (double x, int n)
 * scalbn(x,n) returns x* 2**n  computed by  exponent  
 * manipulation rather than by actually performing an 
 * exponentiation or a multiplication.
 */
extern double utFdlibm_scalbn (double x, int n);


/*
 * double logb(x)
 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
 * Use ilogb instead.
 */
extern double utFdlibm_logb(double x);


/*
 * modf(double x, double *iptr) 
 * returns fraction part of x, and return x's integral part in *iptr.
 */
extern double utFdlibm_modf(double x, double *iptr);


/*
 * nextafter(x,y)
 * return the next machine floating-point number of x in the
 * direction toward y.
 */
extern double utFdlibm_nextafter(double x, double y);


/*
 * rint(x)
 * Return x rounded to integral value according to the prevailing
 * rounding mode.
 */
extern double utFdlibm_rint(double x);


extern double utFdlibm_expm1(double x);


extern double utFdlibm_log1p(double x);


extern double utFdlibm_exp(double x);


extern double utFdlibm_log(double x);


extern double utFdlibm_log10(double x);


extern double utFdlibm_acos(double x);


extern double utFdlibm_acosh(double x);


extern double utFdlibm_asin(double x);


extern double utFdlibm_atan(double x);


extern double utFdlibm_atan2(double y, double x);


extern double utFdlibm_atanh(double x);


extern double utFdlibm_cosh(double x);


extern double utFdlibm_fmod(double x, double y);


extern double utFdlibm_hypot(double x, double y);


extern double utFdlibm_pow(double x, double y);


extern double utFdlibm_remainder(double x, double p);


extern double utFdlibm_sinh(double x);


extern double utFdlibm_asinh(double x);


extern double utFdlibm_cos(double x);


extern double utFdlibm_sin(double x);


extern double utFdlibm_tan(double x);


extern double utFdlibm_tanh(double x);

#ifdef __cplusplus
    }	/* extern "C" */
#endif

#ifdef __cplusplus
    extern "C" {
#endif

#ifdef __cplusplus
    }	/* extern "C" */
#endif

#endif /* mwutil_h */

⌨️ 快捷键说明

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