C Run-Time Library Reference
Notes
The domain of the
[
,
0x8000
0x7fff
It is possible however to derive the full period using the following proper-
ties of the function.
cosine [0,
π
cosine [-
The function below uses these properties to calculate the full period (from
0 to 2π) of the
#include <math.h>
fract16 cos2pi_fr16 (fract16 x)
{
if (x < 0x2000) {
/* first quadrant [0..
/* cos_fr16([0x0..0x7fff]) = [0..0x7fff)
return cos_fr16(x * 4);
} else if (x < 0x6000) {
/* if (x < 0x4000)
/* second quadrant [
/* -cos_fr16([0x8000..0x0)) = [0x7fff..0) */
/*
/* if (x < 0x6000)
/* third quadrant [
/* -cos_fr16([0x0..0x7fff]) = [0..0x8000) */
return -cos_fr16((0xc000 + x) * 4);
} else {
/* fourth quadrant [3/2
/* cos_fr16([0x8000..0x0)) = [0x8000..0)
return cos_fr16((0x8000 + x) * 4);
}
}
3-46
function is restricted to the fractional range
cos_fr16
] which corresponds to half a period from –( π /2) to π/2.
π
/2] = -cosine [
/2, 0] = -cosine [
function using an input domain of
cosine
π
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
π
π
, 3/2
]
π
π
/2,
]
/* <0.25 */
π
/2):
/* < 0.75 */
π
π
/2..
):
π
..3/2
):
π
π
..
):
[0, 0x7fff]
*/
*/
*/
*/
*/
*/
*/
*/
*/
for ADSP-219x DSPs
.
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers