📄 mathspt.h
字号:
/**
mathspt.h
数学支持库设置文件
舍弃对VC33 DSP的支持。
*/
#ifndef __INC_MATHSPRT_H__
#define __INC_MATHSPRT_H__
#if defined(_TMS320C6400) || defined(_TMS320C6400_PLUS)
#define _TI_ENHANCED_MATH_H 1
#include <fastrts62x64x.h> // 需要fastrts62x64x.lib支持
// 该库并不是标准配置,需要
// 额外下载安装
#define recip recipdp
#define recipf recipsp
#define DIVconst_I(x,y) ((x)/(y))
#define DIVF(x,y) ((x)/(y))
#define DIVD(x,y) ((x)/(y))
#include <c6x.h>
#define lmbd(bit,x) _lmbd(bit,x)
#elif defined(_TMS320C6700)
#define _TI_ENHANCED_MATH_H 1
#include <fastmath67x.h>
#define DIVconst_I(x,y) ((I4)((x)*(1.0/(y))))
#define DIVF(x,y) ((x)*recipf(y))
#define DIVD(x,y) ((x)*recip(y))
#include <c6x.h>
#define lmbd(bit,x) _lmbd(bit,x)
#else
#define recip(x) (1.0/(x))
#define recipf(x) (1.0/(x))
#define rsqrt(x) (1.0/sqrt(x))
#define rsqrtf(x) (1.0/sqrtf(x))
#define DIVconst_I(x,y) ((x)/(y))
#define DIVF(x,y) ((x)/(y))
#define DIVD(x,y) ((x)/(y))
#endif
#include <math.h>
#ifndef PI
#define PI (3.1415926535897932384626433832795)
#endif
#ifndef _recip_PI
#define _recip_PI (1.0/PI)
#endif
#ifndef LIGHT_SPEED
#define LIGHT_SPEED (299792458.0)
#endif
#ifndef _recip_LIGHT_SPEED
#define _recip_LIGHT_SPEED (1.0/LIGHT_SPEED)
#endif
#ifndef MAX_SIGNED_INTEGER
#define MAX_SIGNED_INTEGER (0x7FFFFFFF)
#endif
#ifndef MAX_UNSIGNED_INTEGER
#define MAX_UNSIGNED_INTEGER (0xFFFFFFFF)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*!
@function _negll
@brief 对64bits有符号整型数符号取反,仅适用于负数以补码形式表示的系统
@para x, 输入待符号取反的64bits整型数
@return I8型,符号取反后的数值
*/
inline I8 _negll(register I8 x)
{
return (~x)+1;
}
/*!
@function _llabs
@brief 对64bits有符号整型数取绝对值,仅适用于负数以补码形式表示的系统
@para x, 输入待取绝对值的64bits整型数
@return I8型,x的绝对值
*/
inline I8 _llabs(register I8 x)
{
return (!(((I4)(x>>32))&(1<<31))) ? x:(~x+1);
}
#ifndef lmbd
/*!
@function _lmbd
@brief TIC6X指令LMBD的替代支持函数,用于非C6X平台。
对一个32bits字从高向低搜索指定比特,得到最先搜索到的比特的位置索引
@para bit, 待搜索的比特位,1/0
@para x, 待搜索的32bits字
@para I4型,待搜索比特位在待搜索的字中的位置索引。若未搜到指定比特,则返回32
*/
inline I4 _lmbd(
register I4 bit,
register U4 x
)
{
register U4 t;
register I4 cnt = 32;
x = x^(-(bit==0));
if((t = (x>>16)) != 0) {
cnt -= 16;
x = t;
}
if((t = (x>>8)) != 0) {
cnt -= 8;
x = t;
}
if((t = (x>>4)) != 0) {
cnt -= 4;
x = t;
}
if((t = (x>>2)) == 0) {
cnt -= 2;
x = t;
}
cnt -= ((x>>1)+(x&1));
return cnt;
}
#define lmbd(bit,x) _lmbd(bit,x)
#endif//lmbd
#ifdef __cplusplus
}
#endif
#endif//__INC_MATHSPRT_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -