Skip to content

/github/workspace/src/ComplexMathFunctions/kernels/plp_cmplx_dot_prod_i16_xpulpv2.c

Functions

Name
void plp_cmplx_dot_prod_i16_xpulpv2(const int16_t * pSrcA, const int16_t * pSrcB, uint32_t numSamples, int16_t * realResult, int16_t * imagResult)
16-bit integer complex dot product.

Functions Documentation

function plp_cmplx_dot_prod_i16_xpulpv2

void plp_cmplx_dot_prod_i16_xpulpv2(
    const int16_t * pSrcA,
    const int16_t * pSrcB,
    uint32_t numSamples,
    int16_t * realResult,
    int16_t * imagResult
)

16-bit integer complex dot product.

Parameters:

  • pSrcA points to the first input vector
  • pSrcB points to the second input vector
  • numSamples number of samples in each vector
  • realResult real part of the result returned here
  • imagResult imaginary part of the result returned here

Return: none

Source code

/* =====================================================================
 * Project:      PULP DSP Library
 * Title:        plp_cmplx_conj_f32_xpulpv2.c
 * Description:  16-bit integer complex dot product glue code
 *
 * $Date:        29. June 2020
 * $Revision:    V0
 *
 * Target Processor: PULP cores
 * ===================================================================== */
/*
 * Copyright (C) 2019 ETH Zurich and Ubiversity of Bologna.
 *
 * Author: Hanna Mueller, ETH Zurich
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Notice: project inspired by ARM CMSIS DSP and parts of source code
  ported and adopted for RISC-V PULP platform from ARM CMSIS DSP
 released under Copyright (C) 2010-2019 ARM Limited or its affiliates
  with Apache-2.0.
 */

#include "plp_math.h"

void plp_cmplx_dot_prod_i16_xpulpv2(const int16_t *pSrcA,
                                    const int16_t *pSrcB,
                                    uint32_t numSamples,
                                    int16_t *realResult,
                                    int16_t *imagResult) {
    uint32_t blkCnt;                    /* Loop counter */
    int16_t real_sum = 0, imag_sum = 0; /* Temporary result variables */
    int16_t a0, b0, c0, d0;

    /* Initialize blkCnt with number of samples */
    blkCnt = numSamples;
    while (blkCnt > 0U) {
        a0 = *pSrcA++;
        b0 = *pSrcA++;
        c0 = *pSrcB++;
        d0 = *pSrcB++;

        real_sum += a0 * c0;
        imag_sum += a0 * d0;
        real_sum -= b0 * d0;
        imag_sum += b0 * c0;

        /* Decrement loop counter */
        blkCnt--;
    }

    /* Store real and imaginary result in destination buffer. */
    *realResult = real_sum;
    *imagResult = imag_sum;
    // printf("real %d imag %d\n", real_sum, imag_sum);
}

Updated on 2023-03-01 at 16:16:32 +0000