Intel® Integrated Performance Primitives Developer Guide and Reference

ID 790148
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

IIRIIR

Filters a source vector through an IIRIIR filter.

Syntax

Case 1: Not-in-place operation

IppStatus ippsIIRIIR_32f(const Ipp32f* pSrc, Ipp32f* pDst, int len, IppsIIRState_32f* pState);

IppStatus ippsIIRIIR_64f(const Ipp64f* pSrc, Ipp64f* pDst, int len, IppsIIRState_64f* pState);

IppStatus ippsIIRIIR64f_32f(const Ipp32f* pSrc, Ipp32f* pDst, int len, IppsIIRState64f_32f* pState);

Case 2: In-place operation

IppStatus ippsIIRIIR_32f_I(Ipp32f* pSrcDst, int len, IppsIIRState_32f* pState);

IppStatus ippsIIRIIR_64f_I(Ipp64f* pSrcDst, int len, IppsIIRState_64f* pState);

IppStatus ippsIIRIIR64f_32f_I(Ipp32f* pSrcDst, int len, IppsIIRState64f_32f* pState);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

pState

Pointer to the IIRIIR filter state structure.

pSrc

Pointer to the source vector.

pDst

Pointer to the destination vector.

pSrcDst

Pointer to the source and destination vector for the in-place operations.

len

Number of elements of the vector to be filtered.

Description

This function filters len elements of the source vector pSrc or pSrcDst through an IIRIIR filter, and stores the results in pDst or pSrcDst, respectively. The filter parameters are specified in pState.

Before calling the ippsIIRIIR function, initialize the filter state structure by using the IIRIIRInit function and specify the number of taps tapsLen, the tap values in pTaps, the delay line values in pDlyLine, and the order value.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when one of the specified pointers is NULL.

ippStsLengthErr

Indicates an error when length of the vectors < 3*(IIR order).

ippStsContextMatchErr

Indicates an error when the state identifier is incorrect.

Example

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

#include <stdio.h>
#include "ipp/ipps.h"

#define SMP_RATE 1000.f
#define F1 50.f
#define F2 120.f
#define AMPL 10
#define CUT_OFF 0.3
#define LEN 256
#define ORDER 3

int main( ){
    Ipp32f *x, *y, *f1, *f2;
    Ipp32f phase;
    int i, bufferSizeGen, bufferSizeIIRIIR;
    Ipp64f *pTaps;
    Ipp8u *pBufIIRIIR;
    IppsIIRState64f_32f *pStateIIRIIR;
    IppStatus st;

    /* generate test input signal - sum of 2 sinusoids with 50 & 120 Hz */
    f1 = ippsMalloc_32f( LEN );
    f2 = ippsMalloc_32f( LEN );
    x  = ippsMalloc_32f( LEN );
    phase = 3 * (Ipp32f)IPP_PI2; /* ippsTone generates cos, we want sin */
    st = ippsTone_32f( f1, LEN, AMPL, F1/SMP_RATE, &phase, ippAlgHintAccurate ); /* generate 50 Hz sin */
    phase = 3 * (Ipp32f)IPP_PI2; /* restore phase*/
    st |= ippsTone_32f( f2, LEN, AMPL, F2/SMP_RATE, &phase, ippAlgHintAccurate ); /* generate 120 Hz sin */
    st |= ippsAdd_32f( f1, f2, x, LEN ); /* add 50 & 120 Hz sin to form input signal */
    st |= ippsAbs_32f_I( x, LEN ); /* make positive, x contains input signal to be filtered with IIRIIR */
    ippsFree( f1 );
    ippsFree( f2 );
    /* get size of mem buffers for IIR and IIRGen functions */
    st |= ippsIIRIIRGetStateSize64f_32f( ORDER, &bufferSizeIIRIIR );
    st |= ippsIIRGenGetBufferSize      ( ORDER, &bufferSizeGen    );
    /* we can allocate MAX size from two - operations are sequential and therefore buffer can be reused */
    pBufIIRIIR = ippsMalloc_8u( IPP_MAX( bufferSizeGen, bufferSizeIIRIIR ));
    pTaps = ippsMalloc_64f( 2 * ( ORDER + 1 ));
    /* gen LowPass filter coefficients */
    st |= ippsIIRGenLowpass_64f( CUT_OFF/2, 0.0, ORDER, pTaps, ippButterworth, pBufIIRIIR );
    /* init state structure for IIRIIR */
    st |= ippsIIRIIRInit64f_32f( &pStateIIRIIR, pTaps, ORDER, NULL, pBufIIRIIR );
    y = ippsMalloc_32f( LEN ); /* output vector */
    st |=ippsIIRIIR64f_32f( x, y, LEN, pStateIIRIIR );
    printf("idx,\tinput,\toutput\n");
    for( i = 0; i < LEN; i++ ){
        printf("%d,\t%f,\t%f\n", i, (double)x[i], (double)y[i] );
    }
    if( ippStsNoErr != st )
        printf("\nCertain problems in Intel(R) Integrated Primitives (Intel(R) IPP) !\n");
    ippsFree( y );
    ippsFree( pTaps );
    ippsFree( pBufIIRIIR );
    ippsFree( x );
    return 0;
}

The figure below shows the result of the example, where the X-axis is index of the input/output vector/signal to see that there is no phase distortion, Y-axis - amplitude of input/output signals.