IQmath Library
8 - 24 C2000 Microcontroller Workshop - Numerical Concepts
IQmath Library
IQmath Library: Math & Trig Functions
Accuracy of functions/operations approx ~28 to ~31 bits
IQsin(A),IQcos(A)
IQsinPU(A),IQcosPU(A)
IQasin(A),IQacos(A)
IQatan(A),IQatan2(A,B)
IQatan2PU(A,B)
IQsqrt(A),IQisqrt(A)
IQmag(A,B)
IQexp(A)
_IQsin(A), _IQcos(A)
_IQsinPU(A), _IQcosPU(A)
_IQasin(A),_IQacos(A)
_IQatan(A), _IQatan2(A,B)
_IQatan2PU(A,B)
_IQsqrt(A), _IQisqrt(A)
_IQmag(A,B)
_IQexp(A)
sin(A),cos(A)
sin(A*2pi),cos(A*2pi)
asin(A),acos(A)
atan(A),atan2(A,B)
atan2(A,B)/2pi
sqrt(A),1/sqrt(A)
sqrt(A*A + B*B)
exp(A)
trig
and
power
functions
IQsat(A,Pos,Neg)
_IQsat(A,Pos,Neg)if(A > Pos) A = Pos
if(A < Neg) A = Neg
saturation
A – BA - BA - Bsubstract
>, >=, <, <=, ==, |=, &&, || >, >=, <, <=, ==, |=, &&, ||>, >=, <, <=, ==, |=, &&, ||
boolean
A + BA + B
A + B
add
A / B_IQdiv (A , B)A / B divide
A * B_IQmpy(A , B)A * Bmultiply
A = IQ(1.2345)A = _IQ(1.2345)A = 1.2345constant
iq A, B;_iq A, B;float A, B;type
“IQmath” in C++“IQmath” in CFloating-PointOperation
Additionally, the "IQmath" library contains DSP library modules for filters (FIR & IIR) and Fast
Fourier Transforms (FFT & IFFT).
IQmath Library: Conversion Functions
IQmath.lib > contains library of math functions
IQmathLib.h > C header file
IQmathCPP.h > C++ header file
atoIQ(char)_atoIQ(char)atof(char)string to iq
IQtoQN(A)_IQtoQN(A)Aiq to qN
QNtoIQ(A)_QNtoIQ(A)AqN to iq
IQmpyI32int(A,B)_IQmpyI32int(A,B)(long) (A * (float) B)integer(iq*long)
IQmpyI32frac(A,B)_IQmpyI32frac(A,B)A - (long) (A * (float) B)fraction(iq*long)
IQtoF(A)_IQtoF(A)AIQ to float
IQmpyI32(A,B)_IQmpyI32(A,B)
A * (float) B
iq = iq*long
IQfrac(A)_IQfrac(A)A – (long) Afraction(iq)
IQint(A)_IQint(A)(long) Ainteger(iq)
IQNtoIQ(A)_IQNtoIQ(A)AiqN to iq
IQtoIQN(A)_IQtoIQN(A)Aiq to iqN
“IQmath” in C++“IQmath” in CFloating-PointOperation
IQtoA(A,B,C)_IQtoA(A,B,C)sprintf(A,B,C)IQ to ASCII