## Developer Reference

• 2021
• 06/28/2021
• Public Content
Contents

# Triangle

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

## Syntax

Include Files
ipps.h
Domain Dependencies
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 *
ct
h
(2π*
rFreq
*
n
+
phase
)
,
n
= 0, 1, 2,...
For complex triangles,
x
[
n
]
is defined as:
x
[
n
] = magn * [
ct
h
(2π*
rFreq
*
n
+
phase
) + j *
st
h
(2π*
rFreq
*
n
+
phase
)]
,
n
= 0, 1, 2,...
See Triangle-Generating Functions for the definition of functions
ct
h
and
st
h
.
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: #### Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.