Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6633 Discussions

## ippsTone_Direct_32f function to genrate sine phasor Beginner
228 Views
Hi,

I am try to genrate quadrature phasor vector using ippsTone_Direct_32f

foffsin = foffCos + pi/2;

.ippStatsSin = ippsTone_Direct_32f(&v2,Np,1.0,foffsin,&ZeroPh1,ippAlgHintAccurate);

but the genrated phasor is inverse i.e instead sin(x) its gnerating sin(-x); If i try foffsin = foffCos - pi/2 the phasor is all zero.
Kindly let me know what could be wrong.

Regards
Rohit
6 Replies Beginner
228 Views
Hi,

The problem was due to freq range in case of real is 0-0.5 instead of 0-1. But t perfromace of IPP function is not comparable with matlab. Kindly share some light on this

Regards
Rohit Valued Contributor II
228 Views
Quoting rohitspandey
...Butperfromace of IPP function is not comparable with matlab...

Could you provide more technical details? Was it faster or slower? Beginner
228 Views

Hi,

The EVM i.e difference betweenthe matlab numerical value and IPP results increases as the number of sample points are big like 10^5 and high...

Regards
Rohit New Contributor II
228 Views
Matlab uses 64f internaly (maybe 80f) - so you can try ippsTone_Direct_64f with conversion to 32f

Regards,
Igor Beginner
228 Views
Hi,

Thats correct matlab uses double but if use the float variable in matlab the the results should be same.But you will see this is not the case. I tried comparing the tone generation with direct sin and cos function and compared the results are different.Tone generation function is not correctly working

Direct implementation

ippC = ippsVectorSlope_32f(&v1,Np,0,foff);

ippA = ippsCos_32f_A24(&v1, &v2, Np);

ippB = ippsSin_32f_A24(&v1, &v3, Np);

tone genrator

ippStatsSin = ippsTone_Direct_32fc(pbuf,Np,1.0,foff,&ZeroPh,ippAlgHintAccurate);

Used following matlab code

ang=2;%4,6,8,....

in=single([0:1:len-1]);

ph = single(pi/ang);

xI = single(cos(ph.*in));

xQ = single(sin(ph.*in));

And compared the result among them and with matlab. The direct implementation exactly matches matlab while tone genrator has rounding error and it grows as number of sample

Kindly verify the tone genrator implementation Function.

Regards
Rohit Beginner
228 Views
Using your example, try this:
xl1 = single(cos(single(single(pi/2)*(0:100000))));
xl2 = single(cos(pi/2*(0:100000)));
plot(xl1-xl2)
The error will grow linearly with length (on average).
Now try this:
xl1a = single(cos(single(single(pi/2)*mod(0:100000,4))));
hold on;
plot(xl1a-xl2, 'g')
The error will be consistent and very small.
Cos and Sin are VERY sensitive to precision when their value is near zero, and since the cos(x) = cos(mod(x,2*pi)), the loss of significant digits to the right of the decimal has a huge impact on the output.
The main point is that your single precision matlab code is not a good reference. 