The CMSIS DSP 5 library
Dependents: Nucleo-Heart-Rate ejercicioVrms2 PROYECTOFINAL ejercicioVrms ... more
functions/ComplexMathFunctions/arm_cmplx_conj_f32.c@3:4098b9d3d571, 2018-06-21 (annotated)
- Committer:
- xorjoep
- Date:
- Thu Jun 21 11:56:27 2018 +0000
- Revision:
- 3:4098b9d3d571
- Parent:
- 1:24714b45cd1b
headers is a folder not a library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xorjoep | 1:24714b45cd1b | 1 | /* ---------------------------------------------------------------------- |
xorjoep | 1:24714b45cd1b | 2 | * Project: CMSIS DSP Library |
xorjoep | 1:24714b45cd1b | 3 | * Title: arm_cmplx_conj_f32.c |
xorjoep | 1:24714b45cd1b | 4 | * Description: Floating-point complex conjugate |
xorjoep | 1:24714b45cd1b | 5 | * |
xorjoep | 1:24714b45cd1b | 6 | * $Date: 27. January 2017 |
xorjoep | 1:24714b45cd1b | 7 | * $Revision: V.1.5.1 |
xorjoep | 1:24714b45cd1b | 8 | * |
xorjoep | 1:24714b45cd1b | 9 | * Target Processor: Cortex-M cores |
xorjoep | 1:24714b45cd1b | 10 | * -------------------------------------------------------------------- */ |
xorjoep | 1:24714b45cd1b | 11 | /* |
xorjoep | 1:24714b45cd1b | 12 | * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. |
xorjoep | 1:24714b45cd1b | 13 | * |
xorjoep | 1:24714b45cd1b | 14 | * SPDX-License-Identifier: Apache-2.0 |
xorjoep | 1:24714b45cd1b | 15 | * |
xorjoep | 1:24714b45cd1b | 16 | * Licensed under the Apache License, Version 2.0 (the License); you may |
xorjoep | 1:24714b45cd1b | 17 | * not use this file except in compliance with the License. |
xorjoep | 1:24714b45cd1b | 18 | * You may obtain a copy of the License at |
xorjoep | 1:24714b45cd1b | 19 | * |
xorjoep | 1:24714b45cd1b | 20 | * www.apache.org/licenses/LICENSE-2.0 |
xorjoep | 1:24714b45cd1b | 21 | * |
xorjoep | 1:24714b45cd1b | 22 | * Unless required by applicable law or agreed to in writing, software |
xorjoep | 1:24714b45cd1b | 23 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
xorjoep | 1:24714b45cd1b | 24 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
xorjoep | 1:24714b45cd1b | 25 | * See the License for the specific language governing permissions and |
xorjoep | 1:24714b45cd1b | 26 | * limitations under the License. |
xorjoep | 1:24714b45cd1b | 27 | */ |
xorjoep | 1:24714b45cd1b | 28 | |
xorjoep | 1:24714b45cd1b | 29 | #include "arm_math.h" |
xorjoep | 1:24714b45cd1b | 30 | |
xorjoep | 1:24714b45cd1b | 31 | /** |
xorjoep | 1:24714b45cd1b | 32 | * @ingroup groupCmplxMath |
xorjoep | 1:24714b45cd1b | 33 | */ |
xorjoep | 1:24714b45cd1b | 34 | |
xorjoep | 1:24714b45cd1b | 35 | /** |
xorjoep | 1:24714b45cd1b | 36 | * @defgroup cmplx_conj Complex Conjugate |
xorjoep | 1:24714b45cd1b | 37 | * |
xorjoep | 1:24714b45cd1b | 38 | * Conjugates the elements of a complex data vector. |
xorjoep | 1:24714b45cd1b | 39 | * |
xorjoep | 1:24714b45cd1b | 40 | * The <code>pSrc</code> points to the source data and |
xorjoep | 1:24714b45cd1b | 41 | * <code>pDst</code> points to the where the result should be written. |
xorjoep | 1:24714b45cd1b | 42 | * <code>numSamples</code> specifies the number of complex samples |
xorjoep | 1:24714b45cd1b | 43 | * and the data in each array is stored in an interleaved fashion |
xorjoep | 1:24714b45cd1b | 44 | * (real, imag, real, imag, ...). |
xorjoep | 1:24714b45cd1b | 45 | * Each array has a total of <code>2*numSamples</code> values. |
xorjoep | 1:24714b45cd1b | 46 | * The underlying algorithm is used: |
xorjoep | 1:24714b45cd1b | 47 | * |
xorjoep | 1:24714b45cd1b | 48 | * <pre> |
xorjoep | 1:24714b45cd1b | 49 | * for(n=0; n<numSamples; n++) { |
xorjoep | 1:24714b45cd1b | 50 | * pDst[(2*n)+0)] = pSrc[(2*n)+0]; // real part |
xorjoep | 1:24714b45cd1b | 51 | * pDst[(2*n)+1)] = -pSrc[(2*n)+1]; // imag part |
xorjoep | 1:24714b45cd1b | 52 | * } |
xorjoep | 1:24714b45cd1b | 53 | * </pre> |
xorjoep | 1:24714b45cd1b | 54 | * |
xorjoep | 1:24714b45cd1b | 55 | * There are separate functions for floating-point, Q15, and Q31 data types. |
xorjoep | 1:24714b45cd1b | 56 | */ |
xorjoep | 1:24714b45cd1b | 57 | |
xorjoep | 1:24714b45cd1b | 58 | /** |
xorjoep | 1:24714b45cd1b | 59 | * @addtogroup cmplx_conj |
xorjoep | 1:24714b45cd1b | 60 | * @{ |
xorjoep | 1:24714b45cd1b | 61 | */ |
xorjoep | 1:24714b45cd1b | 62 | |
xorjoep | 1:24714b45cd1b | 63 | /** |
xorjoep | 1:24714b45cd1b | 64 | * @brief Floating-point complex conjugate. |
xorjoep | 1:24714b45cd1b | 65 | * @param *pSrc points to the input vector |
xorjoep | 1:24714b45cd1b | 66 | * @param *pDst points to the output vector |
xorjoep | 1:24714b45cd1b | 67 | * @param numSamples number of complex samples in each vector |
xorjoep | 1:24714b45cd1b | 68 | * @return none. |
xorjoep | 1:24714b45cd1b | 69 | */ |
xorjoep | 1:24714b45cd1b | 70 | |
xorjoep | 1:24714b45cd1b | 71 | void arm_cmplx_conj_f32( |
xorjoep | 1:24714b45cd1b | 72 | float32_t * pSrc, |
xorjoep | 1:24714b45cd1b | 73 | float32_t * pDst, |
xorjoep | 1:24714b45cd1b | 74 | uint32_t numSamples) |
xorjoep | 1:24714b45cd1b | 75 | { |
xorjoep | 1:24714b45cd1b | 76 | uint32_t blkCnt; /* loop counter */ |
xorjoep | 1:24714b45cd1b | 77 | |
xorjoep | 1:24714b45cd1b | 78 | #if defined (ARM_MATH_DSP) |
xorjoep | 1:24714b45cd1b | 79 | |
xorjoep | 1:24714b45cd1b | 80 | /* Run the below code for Cortex-M4 and Cortex-M3 */ |
xorjoep | 1:24714b45cd1b | 81 | float32_t inR1, inR2, inR3, inR4; |
xorjoep | 1:24714b45cd1b | 82 | float32_t inI1, inI2, inI3, inI4; |
xorjoep | 1:24714b45cd1b | 83 | |
xorjoep | 1:24714b45cd1b | 84 | /*loop Unrolling */ |
xorjoep | 1:24714b45cd1b | 85 | blkCnt = numSamples >> 2U; |
xorjoep | 1:24714b45cd1b | 86 | |
xorjoep | 1:24714b45cd1b | 87 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. |
xorjoep | 1:24714b45cd1b | 88 | ** a second loop below computes the remaining 1 to 3 samples. */ |
xorjoep | 1:24714b45cd1b | 89 | while (blkCnt > 0U) |
xorjoep | 1:24714b45cd1b | 90 | { |
xorjoep | 1:24714b45cd1b | 91 | /* C[0]+jC[1] = A[0]+ j (-1) A[1] */ |
xorjoep | 1:24714b45cd1b | 92 | /* Calculate Complex Conjugate and then store the results in the destination buffer. */ |
xorjoep | 1:24714b45cd1b | 93 | /* read real input samples */ |
xorjoep | 1:24714b45cd1b | 94 | inR1 = pSrc[0]; |
xorjoep | 1:24714b45cd1b | 95 | /* store real samples to destination */ |
xorjoep | 1:24714b45cd1b | 96 | pDst[0] = inR1; |
xorjoep | 1:24714b45cd1b | 97 | inR2 = pSrc[2]; |
xorjoep | 1:24714b45cd1b | 98 | pDst[2] = inR2; |
xorjoep | 1:24714b45cd1b | 99 | inR3 = pSrc[4]; |
xorjoep | 1:24714b45cd1b | 100 | pDst[4] = inR3; |
xorjoep | 1:24714b45cd1b | 101 | inR4 = pSrc[6]; |
xorjoep | 1:24714b45cd1b | 102 | pDst[6] = inR4; |
xorjoep | 1:24714b45cd1b | 103 | |
xorjoep | 1:24714b45cd1b | 104 | /* read imaginary input samples */ |
xorjoep | 1:24714b45cd1b | 105 | inI1 = pSrc[1]; |
xorjoep | 1:24714b45cd1b | 106 | inI2 = pSrc[3]; |
xorjoep | 1:24714b45cd1b | 107 | |
xorjoep | 1:24714b45cd1b | 108 | /* conjugate input */ |
xorjoep | 1:24714b45cd1b | 109 | inI1 = -inI1; |
xorjoep | 1:24714b45cd1b | 110 | |
xorjoep | 1:24714b45cd1b | 111 | /* read imaginary input samples */ |
xorjoep | 1:24714b45cd1b | 112 | inI3 = pSrc[5]; |
xorjoep | 1:24714b45cd1b | 113 | |
xorjoep | 1:24714b45cd1b | 114 | /* conjugate input */ |
xorjoep | 1:24714b45cd1b | 115 | inI2 = -inI2; |
xorjoep | 1:24714b45cd1b | 116 | |
xorjoep | 1:24714b45cd1b | 117 | /* read imaginary input samples */ |
xorjoep | 1:24714b45cd1b | 118 | inI4 = pSrc[7]; |
xorjoep | 1:24714b45cd1b | 119 | |
xorjoep | 1:24714b45cd1b | 120 | /* conjugate input */ |
xorjoep | 1:24714b45cd1b | 121 | inI3 = -inI3; |
xorjoep | 1:24714b45cd1b | 122 | |
xorjoep | 1:24714b45cd1b | 123 | /* store imaginary samples to destination */ |
xorjoep | 1:24714b45cd1b | 124 | pDst[1] = inI1; |
xorjoep | 1:24714b45cd1b | 125 | pDst[3] = inI2; |
xorjoep | 1:24714b45cd1b | 126 | |
xorjoep | 1:24714b45cd1b | 127 | /* conjugate input */ |
xorjoep | 1:24714b45cd1b | 128 | inI4 = -inI4; |
xorjoep | 1:24714b45cd1b | 129 | |
xorjoep | 1:24714b45cd1b | 130 | /* store imaginary samples to destination */ |
xorjoep | 1:24714b45cd1b | 131 | pDst[5] = inI3; |
xorjoep | 1:24714b45cd1b | 132 | |
xorjoep | 1:24714b45cd1b | 133 | /* increment source pointer by 8 to process next sampels */ |
xorjoep | 1:24714b45cd1b | 134 | pSrc += 8U; |
xorjoep | 1:24714b45cd1b | 135 | |
xorjoep | 1:24714b45cd1b | 136 | /* store imaginary sample to destination */ |
xorjoep | 1:24714b45cd1b | 137 | pDst[7] = inI4; |
xorjoep | 1:24714b45cd1b | 138 | |
xorjoep | 1:24714b45cd1b | 139 | /* increment destination pointer by 8 to store next samples */ |
xorjoep | 1:24714b45cd1b | 140 | pDst += 8U; |
xorjoep | 1:24714b45cd1b | 141 | |
xorjoep | 1:24714b45cd1b | 142 | /* Decrement the loop counter */ |
xorjoep | 1:24714b45cd1b | 143 | blkCnt--; |
xorjoep | 1:24714b45cd1b | 144 | } |
xorjoep | 1:24714b45cd1b | 145 | |
xorjoep | 1:24714b45cd1b | 146 | /* If the numSamples is not a multiple of 4, compute any remaining output samples here. |
xorjoep | 1:24714b45cd1b | 147 | ** No loop unrolling is used. */ |
xorjoep | 1:24714b45cd1b | 148 | blkCnt = numSamples % 0x4U; |
xorjoep | 1:24714b45cd1b | 149 | |
xorjoep | 1:24714b45cd1b | 150 | #else |
xorjoep | 1:24714b45cd1b | 151 | |
xorjoep | 1:24714b45cd1b | 152 | /* Run the below code for Cortex-M0 */ |
xorjoep | 1:24714b45cd1b | 153 | blkCnt = numSamples; |
xorjoep | 1:24714b45cd1b | 154 | |
xorjoep | 1:24714b45cd1b | 155 | #endif /* #if defined (ARM_MATH_DSP) */ |
xorjoep | 1:24714b45cd1b | 156 | |
xorjoep | 1:24714b45cd1b | 157 | while (blkCnt > 0U) |
xorjoep | 1:24714b45cd1b | 158 | { |
xorjoep | 1:24714b45cd1b | 159 | /* realOut + j (imagOut) = realIn + j (-1) imagIn */ |
xorjoep | 1:24714b45cd1b | 160 | /* Calculate Complex Conjugate and then store the results in the destination buffer. */ |
xorjoep | 1:24714b45cd1b | 161 | *pDst++ = *pSrc++; |
xorjoep | 1:24714b45cd1b | 162 | *pDst++ = -*pSrc++; |
xorjoep | 1:24714b45cd1b | 163 | |
xorjoep | 1:24714b45cd1b | 164 | /* Decrement the loop counter */ |
xorjoep | 1:24714b45cd1b | 165 | blkCnt--; |
xorjoep | 1:24714b45cd1b | 166 | } |
xorjoep | 1:24714b45cd1b | 167 | } |
xorjoep | 1:24714b45cd1b | 168 | |
xorjoep | 1:24714b45cd1b | 169 | /** |
xorjoep | 1:24714b45cd1b | 170 | * @} end of cmplx_conj group |
xorjoep | 1:24714b45cd1b | 171 | */ |