Generates a triangle with a given frequency, phase, and magnitude.
IppStatus ippsTriangle_Direct_16s(Ipp16s* pDst, int len, Ipp16s magn, float rFreq, float asym, float* pPhase);
IppStatus ippsTriangle_Direct_16sc(Ipp16sc* pDst, int len, Ipp16s magn, float rFreq, float asym, float* pPhase);
IppStatus ippsTriangle_Direct_32f(Ipp32f* pDst, int len, float magn, float rFreq, float asym, float* pPhase);
IppStatus ippsTriangle_Direct_32fc(Ipp32fc* pDst, int len, float magn, float rFreq, float asym, float* pPhase);
IppStatus ippsTriangle_Direct_64f(Ipp64f* pDst, int len, double magn, double rFreq, double asym, double* pPhase);
IppStatus ippsTriangle_Direct_64fc(Ipp64fc* pDst, int len, double magn, double rFreq, double asym, double* pPhase);
rFreq |
Frequency of the triangle relative to the sampling frequency. It must be in range [0.0, 0.5). |
pPhase |
Pointer to the phase of the triangle relative to a cosine triangular analog wave. It must be in range [0.0, 2π). The returned value may be used to compute the next continuous data block. |
magn |
Magnitude of the triangle, that is, the maximum value attained by the wave. |
asym |
Asymmetry h of a triangle. It must be in range [-π , π ). If h=0, then the triangle is symmetric and a direct analog of a tone. |
pDst |
Pointer to the array which stores the samples. |
len |
Number of samples to be computed. |
The function ippsTriangle_Direct is declared in the ipps.h file. This function generates the triangle with the specified frequency rFreq, phase pointed by pPhase, and magnitude magn. The function computes len samples of the triangle, and stores them in the array pDst. For real triangle, x[n] is defined as:
x[n] = magn * cth(2π* rFreq*n + phase), n = 0, 1, 2,...
For complex triangles, x[n] is defined as:
x[n] = magn * [cth(2π* rFreq*n + phase) + j * sth(2π* rFreq*n + phase)], n = 0, 1, 2,...
See Triangle Generating Functions for the definition of functions cth and sth.
The example below demonstrates how to use the function ippsTriangle.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when the pDst or pPhase pointer is NULL. |
ippStsSizeErr |
Indicates an error when len is less than or equal to zero. |
ippStsTrnglMagnErr |
Indicates an error when magn is less than or equal to zero. |
ippStsTrnglFreqErr |
Indicates an error when rFreq is negative, or greater than or equal to 0.5. |
ippStsTrnglPhaseErr |
Indicates an error when the pPhase value is negative, or greater than or equal to IPP_2PI. |
ippStsTrnglAsymErr |
Indicates an error when asym is less than -IPP_PI, or greater than or equal to IPP_PI. |
void func_triangle_direct()
{
Ipp16s* pDst;
int len = 512;
Ipp16s magn = 4095;
float rFreq = 0.02;
float asym = 0.0;;
float Phase = 0.0;
IppStatus status;
status = ippsTriangle_Direct_16s(pDst, len, magn, rFreq, asym, &Phase);
if(ippStsNoErr != status)
printf("IPP Error: %s",ippGetStatusString(status));
}
result:
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.