Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

Triangle

Generates a triangle with a given frequency, phase, and magnitude.

Syntax

IppStatus ippsTriangle_16s(Ipp16s* pDst, int len, Ipp16s magn, Ipp32f rFreq, Ipp32f asym, Ipp32f* pPhase);

IppStatus ippsTriangle_16sc(Ipp16sc* pDst, int len, Ipp16s magn, Ipp32f rFreq, Ipp32f asym, Ipp32f* pPhase);

IppStatus ippsTriangle_32f(Ipp32f* pDst, int len, Ipp32f magn, Ipp32f rFreq, Ipp32f asym, Ipp32f* pPhase);

IppStatus ippsTriangle_32fc(Ipp32fc* pDst, int len, Ipp32f magn, Ipp32f rFreq, Ipp32f asym, Ipp32f* pPhase);

IppStatus ippsTriangle_64f(Ipp64f* pDst, int len, Ipp64f magn, Ipp64f rFreq, Ipp64f asym, Ipp64f* pPhase);

IppStatus ippsTriangle_64fc(Ipp64fc* pDst, int len, Ipp64f magn, Ipp64f rFreq, Ipp64f asym, Ipp64f* pPhase);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

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π). You can use the returned value 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 that stores the samples.

len

Number of samples to be computed.

Description

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.

Return Values

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.

Example

The code example below demonstrates how to use the ippsTriangle function.

void func_triangle_direct() 
{
    Ipp16s* pDst;
    int len = 512;
    Ipp16s magn = 4095;
    Ipp32f rFreq = 0.02;
    Ipp32f asym = 0.0;
    Ipp32f Phase = 0.0;
    IppStatus status;

    status = ippsTriangle_16s(pDst, len, magn, rFreq, asym, &Phase);
    if(ippStsNoErr != status)
      printf("Intel(R) IPP Error: %s",ippGetStatusString(status)); 
}

Result: