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

ID 790148
Date 10/31/2024
Public
Document Table of Contents

MulPack

Multiply the elements of two vectors stored in Pack format.

Syntax

Case 1: Not-in-place operation

IppStatus ippsMulPack_32f(const Ipp32f* pSrc1, const Ipp32f* pSrc2, Ipp32f* pDst, int len);

IppStatus ippsMulPack_64f(const Ipp64f* pSrc1, const Ipp64f* pSrc2, Ipp64f* pDst, int len);

Case 2: In-place operation

IppStatus ippsMulPack_32f_I(const Ipp32f* pSrc, Ipp32f* pSrcDst, int len);

IppStatus ippsMulPack_64f_I(const Ipp64f* pSrc, Ipp64f* pSrcDst, int len);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

pSrc1, pSrc2

Pointers to the vectors whose elements are to be multiplied together.

pDst

Pointer to the destination vector which stores the result of the multiplication pSrc1[n] * pSrc2[n].

pSrc

Pointer to the vector whose elements are to be multiplied by the elements of pSrcDst in-place.

pSrcDst

Pointer to the source and destination vector (for the in-place operation).

len

Number of elements in the vector.

Description

This function multiplies the elements of the vector pSrc1 by the elements of the vector pSrc2, and stores the result in pDst.

The in-place flavors ippsMulPack multiply the elements of the vector pSrc by the elements of the vector pSrcDst, and store the result in pSrcDst.

The functions multiply the packed data according to their packed format. The data in Pack packed format include several real values, the rest are complex. Thus, the function performs several real multiplication operations on real elements and complex multiplication operations on complex data. Such kind of packed data multiplication is usually used for signals filtering with the FFT transform when the element-wise multiplication is performed in the frequency domain.

Return Values

ippStsNoErr

Indicates no error

ippStsNullPtrErr

Indicates an error when the pSrcDst, pDst, pSrc1, pSrc2, or pSrc pointer is NULL.

ippStsSizeErr

Indicates an error when len is less than or equal to 0.

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.
*******************************************************************************/

//    The code example below illustrates how to use the function ippsMulPack_32f_I.
// implemented with Intel(R) Integrated Performance Primitives (Intel(R) IPP) functions:
//     ippsFFTGetSize_R_32f
//     ippsFFTInit_R_32f
//     ippsSet_32f
//     ippsFFTFwd_RToPack_32f
//     ippsMulPack_32f_I
//     ippsFFTInv_PackToR_32f


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

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main(void)
{
    int i = 0;
    IppStatus status = ippStsNoErr;
    Ipp32f pFlt[8] = {1.0f/3,1.0f/3,1.0f/3,0,0,0,0,0};  /* Pointers to filter signal */
    Ipp32f pSrc[8],   pDst[8];    /* Pointers to source/filter/destination signals */
    Ipp32f pSrcFr[8], pFltFr[8];  /* Pointers to source/filter/destination signals into the frequency domain */

    IppsFFTSpec_R_32f* pSpec = NULL;                            /* Pointer to FFT pSpec structure */
    Ipp8u *pMemInit = NULL, *pBuffer = NULL, *pSpecMem = NULL;  /* Pointer to the work buffers */
    int sizeSpec = 0, sizeInit = 0, sizeBuf = 0;                /* size of FFT pSpec structure, Init and work buffers */

    check_sts( status = ippsFFTGetSize_R_32f(3, IPP_FFT_DIV_INV_BY_N, ippAlgHintNone, &sizeSpec, &sizeInit, &sizeBuf) )

    /* memory allocation */
    pSpecMem = (Ipp8u*) ippMalloc( sizeSpec );
    pBuffer  = (Ipp8u*) ippMalloc( sizeBuf );
    pMemInit = (Ipp8u*) ippMalloc( sizeInit );

    check_sts( status = ippsFFTInit_R_32f(&pSpec, 3, IPP_FFT_DIV_INV_BY_N, ippAlgHintNone, pSpecMem, pMemInit) )

    ippsSet_32f( 3, pSrc, 8 );
    pSrc[3] = 5;

    /* forward FFT transform : the source signal is transformed into the frequency domain*/
    check_sts( status = ippsFFTFwd_RToPack_32f( pSrc, pSrcFr, pSpec, NULL ) )

    /* forward FFT transform: the filter signal is transformed into the frequency domain */
    check_sts( status = ippsFFTFwd_RToPack_32f( pFlt, pFltFr, pSpec, NULL ) )

    /* multiplying the packed data */
    check_sts( status = ippsMulPack_32f_I( pFltFr, pSrcFr, 8 ) )

    /* inverse FFT transform : the filtered data is transformed to the time domain */
    check_sts( status = ippsFFTInv_PackToR_32f( pSrcFr, pDst, pSpec, NULL ) )

    printf("filtered =");

    for (i = 0; i < 8; ++i) printf(" %f", pDst[i]);
    printf("\n");

EXIT_MAIN
    ippFree( pMemInit );
    ippFree( pSpec );
    ippFree( pBuffer );
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return status;
}