Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

## Efficient Generation of Sinusoids

Beginner
677 Views

Given a real dTheta, I want to create a largish complex linear array of the form z=(cos(n*dTheta),sin(n*dTheta))

People must need this for signal processing all the time.  Anyhow, I need to do it again and again with different values of dTheta.

Anybody could do this:

1. Create an array {0.0, 1.0, 2.0, ...}
2. Use MKL to multiply this by dTheta
3. Use MKL to compute the trig functions

Efficiency is the issue here. The symmetry of my problem is much greater than that of the above solution.  I assert that it is possible to speed up the above recipe by a large factor in normal coding.  Is this also possible using SSE type parallelism via the MKL?

R

Employee
677 Views

Hi Ray,

The dTheta is related PI or freqency?

https://software.intel.com/en-us/ipp-dev-reference-tone

Tone-Generating Functions

The functions described below generate a tone (or “sinusoid”) of a given frequency, phase, and magnitude. Tones are fundamental building blocks for analog signals. Thus, sampled tones are extremely useful in signal processing systems as test signals and as building blocks for more complex signals.

The use of tone functions is preferable against the analogous C math library's sin() function for many applications, because Intel IPP functions can use information retained from the computation of the previous sample to compute the next sample much faster than standard sin() or cos().

This function generates the tone with the specified frequency rFreq, phase pPhase, and magnitude magn. The function computes len samples of the tone, and stores them in the array pDst. For real tones, each generated value x[n] is defined as:

x[n] = magn * cos(2πn*rFreq + phase)

For complex tones, x[n] is defined as:

x[n] = magn * (cos(2πn*rFreq + phase)+j* sin(2πn*rFreq + phase))

The parameter hint suggests using specific code, which provides for either fast but less accurate calculation, or more accurate but slower execution.

or MKL function

https://software.intel.com/en-us/articles/intel-math-kernel-library-documentation

vsSinCos( n, a, y, z );

Computes sine and cosine of vector elements.

Pointers to arrays that contain the output vectors y (for sinevalues) and z(for cosine values).

Best Regards,

Ying