65 lines
2.1 KiB
C
65 lines
2.1 KiB
C
/*
|
|
*========================================================================================
|
|
* (C) Copyright 2019 ŔÎ "Äčŕęîíň"
|
|
* ă. Ńŕíęň-Ďĺňĺđáóđă, Đîńńč˙
|
|
*
|
|
* Ôŕéë: iqmath.h
|
|
* Îďčńŕíčĺ: Đĺŕëčçŕöč˙ âű÷čńëĺíčé iq
|
|
*
|
|
*========================================================================================
|
|
*/
|
|
#ifndef IQMATH_H_
|
|
#define IQMATH_H_
|
|
/*
|
|
*----------------------------------------------------------------------------------------
|
|
*Âęëţ÷ŕĺěűĺ ôŕéëű
|
|
*----------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
/*
|
|
*----------------------------------------------------------------------------------------
|
|
*Îáú˙âëĺíč˙ ěŕęđîńîâ
|
|
*----------------------------------------------------------------------------------------
|
|
*/
|
|
#define _IQsat(A, Pos, Neg) (__fmax(((__fmin((A),(Pos)))),(Neg)))
|
|
#define _IQ(A) (A)
|
|
#define _IQmpy(A, B) ((A) * (B))
|
|
#define _IQdiv2(A) ((A) * 0.5f)
|
|
#define _IQmpy2(A) ((A) * 2.0f)
|
|
|
|
#define IQtoQ5(A) (long) ((A) * 32.0f)
|
|
#define IQtoQ6(A) (long) ((A) * 64.0f)
|
|
#define IQtoQ8(A) (long) ((A) * 256.0f)
|
|
#define IQtoQ12(A) (long) ((A) * 4096.0f)
|
|
|
|
#define Q5toIQ(A) (((float) (A)) * 0.031250f)
|
|
#define Q6toIQ(A) (((float) (A)) * 0.015625f)
|
|
|
|
#define ONEbySQRT3 0.57735026918963 /* 1/sqrt(3) */
|
|
|
|
|
|
#define ABS(x) ( ((x) >= 0) ? (x) : -(x) )
|
|
#define FABS(x) ( ((x) >= 0.0f) ? (x) : -(x) )
|
|
|
|
/*
|
|
*----------------------------------------------------------------------------------------
|
|
*Îáú˙âëĺíč˙ ňčďîâ
|
|
*----------------------------------------------------------------------------------------
|
|
*/
|
|
typedef float _iq;
|
|
|
|
/*
|
|
*----------------------------------------------------------------------------------------
|
|
*Îáú˙âëĺíč˙ ôóíęöčé
|
|
*----------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
/*
|
|
*----------------------------------------------------------------------------------------
|
|
*Îďđĺäĺëĺíč˙ ăëîáŕëüíűő ďĺđĺěĺííűő
|
|
*----------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
#endif /* IQMATH_H_ */
|