1 /****************************************************************************** 2 * @file complex_math_functions.h 3 * @brief Public header file for CMSIS DSP Library 4 * @version V1.10.0 5 * @date 08 July 2021 6 * Target Processor: Cortex-M and Cortex-A cores 7 ******************************************************************************/ 8 /* 9 * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved. 10 * 11 * SPDX-License-Identifier: Apache-2.0 12 * 13 * Licensed under the Apache License, Version 2.0 (the License); you may 14 * not use this file except in compliance with the License. 15 * You may obtain a copy of the License at 16 * 17 * www.apache.org/licenses/LICENSE-2.0 18 * 19 * Unless required by applicable law or agreed to in writing, software 20 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 * See the License for the specific language governing permissions and 23 * limitations under the License. 24 */ 25 26 27 #ifndef _COMPLEX_MATH_FUNCTIONS_H_ 28 #define _COMPLEX_MATH_FUNCTIONS_H_ 29 30 #include "arm_math_types.h" 31 #include "arm_math_memory.h" 32 33 #include "dsp/none.h" 34 #include "dsp/utils.h" 35 #include "dsp/fast_math_functions.h" 36 37 #ifdef __cplusplus 38 extern "C" 39 { 40 #endif 41 42 /** 43 * @defgroup groupCmplxMath Complex Math Functions 44 * This set of functions operates on complex data vectors. 45 * The data in the complex arrays is stored in an interleaved fashion 46 * (real, imag, real, imag, ...). 47 * In the API functions, the number of samples in a complex array refers 48 * to the number of complex values; the array contains twice this number of 49 * real values. 50 */ 51 52 /** 53 * @brief Floating-point complex conjugate. 54 * @param[in] pSrc points to the input vector 55 * @param[out] pDst points to the output vector 56 * @param[in] numSamples number of complex samples in each vector 57 */ 58 void arm_cmplx_conj_f32( 59 const float32_t * pSrc, 60 float32_t * pDst, 61 uint32_t numSamples); 62 63 /** 64 * @brief Q31 complex conjugate. 65 * @param[in] pSrc points to the input vector 66 * @param[out] pDst points to the output vector 67 * @param[in] numSamples number of complex samples in each vector 68 */ 69 void arm_cmplx_conj_q31( 70 const q31_t * pSrc, 71 q31_t * pDst, 72 uint32_t numSamples); 73 74 75 /** 76 * @brief Q15 complex conjugate. 77 * @param[in] pSrc points to the input vector 78 * @param[out] pDst points to the output vector 79 * @param[in] numSamples number of complex samples in each vector 80 */ 81 void arm_cmplx_conj_q15( 82 const q15_t * pSrc, 83 q15_t * pDst, 84 uint32_t numSamples); 85 86 87 /** 88 * @brief Floating-point complex magnitude squared 89 * @param[in] pSrc points to the complex input vector 90 * @param[out] pDst points to the real output vector 91 * @param[in] numSamples number of complex samples in the input vector 92 */ 93 void arm_cmplx_mag_squared_f32( 94 const float32_t * pSrc, 95 float32_t * pDst, 96 uint32_t numSamples); 97 98 99 /** 100 * @brief Floating-point complex magnitude squared 101 * @param[in] pSrc points to the complex input vector 102 * @param[out] pDst points to the real output vector 103 * @param[in] numSamples number of complex samples in the input vector 104 */ 105 void arm_cmplx_mag_squared_f64( 106 const float64_t * pSrc, 107 float64_t * pDst, 108 uint32_t numSamples); 109 110 111 /** 112 * @brief Q31 complex magnitude squared 113 * @param[in] pSrc points to the complex input vector 114 * @param[out] pDst points to the real output vector 115 * @param[in] numSamples number of complex samples in the input vector 116 */ 117 void arm_cmplx_mag_squared_q31( 118 const q31_t * pSrc, 119 q31_t * pDst, 120 uint32_t numSamples); 121 122 123 /** 124 * @brief Q15 complex magnitude squared 125 * @param[in] pSrc points to the complex input vector 126 * @param[out] pDst points to the real output vector 127 * @param[in] numSamples number of complex samples in the input vector 128 */ 129 void arm_cmplx_mag_squared_q15( 130 const q15_t * pSrc, 131 q15_t * pDst, 132 uint32_t numSamples); 133 134 135 /** 136 * @brief Floating-point complex magnitude 137 * @param[in] pSrc points to the complex input vector 138 * @param[out] pDst points to the real output vector 139 * @param[in] numSamples number of complex samples in the input vector 140 */ 141 void arm_cmplx_mag_f32( 142 const float32_t * pSrc, 143 float32_t * pDst, 144 uint32_t numSamples); 145 146 147 /** 148 * @brief Floating-point complex magnitude 149 * @param[in] pSrc points to the complex input vector 150 * @param[out] pDst points to the real output vector 151 * @param[in] numSamples number of complex samples in the input vector 152 */ 153 void arm_cmplx_mag_f64( 154 const float64_t * pSrc, 155 float64_t * pDst, 156 uint32_t numSamples); 157 158 159 /** 160 * @brief Q31 complex magnitude 161 * @param[in] pSrc points to the complex input vector 162 * @param[out] pDst points to the real output vector 163 * @param[in] numSamples number of complex samples in the input vector 164 */ 165 void arm_cmplx_mag_q31( 166 const q31_t * pSrc, 167 q31_t * pDst, 168 uint32_t numSamples); 169 170 171 /** 172 * @brief Q15 complex magnitude 173 * @param[in] pSrc points to the complex input vector 174 * @param[out] pDst points to the real output vector 175 * @param[in] numSamples number of complex samples in the input vector 176 */ 177 void arm_cmplx_mag_q15( 178 const q15_t * pSrc, 179 q15_t * pDst, 180 uint32_t numSamples); 181 182 /** 183 * @brief Q15 complex magnitude 184 * @param[in] pSrc points to the complex input vector 185 * @param[out] pDst points to the real output vector 186 * @param[in] numSamples number of complex samples in the input vector 187 */ 188 void arm_cmplx_mag_fast_q15( 189 const q15_t * pSrc, 190 q15_t * pDst, 191 uint32_t numSamples); 192 193 194 /** 195 * @brief Q15 complex dot product 196 * @param[in] pSrcA points to the first input vector 197 * @param[in] pSrcB points to the second input vector 198 * @param[in] numSamples number of complex samples in each vector 199 * @param[out] realResult real part of the result returned here 200 * @param[out] imagResult imaginary part of the result returned here 201 */ 202 void arm_cmplx_dot_prod_q15( 203 const q15_t * pSrcA, 204 const q15_t * pSrcB, 205 uint32_t numSamples, 206 q31_t * realResult, 207 q31_t * imagResult); 208 209 210 /** 211 * @brief Q31 complex dot product 212 * @param[in] pSrcA points to the first input vector 213 * @param[in] pSrcB points to the second input vector 214 * @param[in] numSamples number of complex samples in each vector 215 * @param[out] realResult real part of the result returned here 216 * @param[out] imagResult imaginary part of the result returned here 217 */ 218 void arm_cmplx_dot_prod_q31( 219 const q31_t * pSrcA, 220 const q31_t * pSrcB, 221 uint32_t numSamples, 222 q63_t * realResult, 223 q63_t * imagResult); 224 225 226 /** 227 * @brief Floating-point complex dot product 228 * @param[in] pSrcA points to the first input vector 229 * @param[in] pSrcB points to the second input vector 230 * @param[in] numSamples number of complex samples in each vector 231 * @param[out] realResult real part of the result returned here 232 * @param[out] imagResult imaginary part of the result returned here 233 */ 234 void arm_cmplx_dot_prod_f32( 235 const float32_t * pSrcA, 236 const float32_t * pSrcB, 237 uint32_t numSamples, 238 float32_t * realResult, 239 float32_t * imagResult); 240 241 242 /** 243 * @brief Q15 complex-by-real multiplication 244 * @param[in] pSrcCmplx points to the complex input vector 245 * @param[in] pSrcReal points to the real input vector 246 * @param[out] pCmplxDst points to the complex output vector 247 * @param[in] numSamples number of samples in each vector 248 */ 249 void arm_cmplx_mult_real_q15( 250 const q15_t * pSrcCmplx, 251 const q15_t * pSrcReal, 252 q15_t * pCmplxDst, 253 uint32_t numSamples); 254 255 256 /** 257 * @brief Q31 complex-by-real multiplication 258 * @param[in] pSrcCmplx points to the complex input vector 259 * @param[in] pSrcReal points to the real input vector 260 * @param[out] pCmplxDst points to the complex output vector 261 * @param[in] numSamples number of samples in each vector 262 */ 263 void arm_cmplx_mult_real_q31( 264 const q31_t * pSrcCmplx, 265 const q31_t * pSrcReal, 266 q31_t * pCmplxDst, 267 uint32_t numSamples); 268 269 270 /** 271 * @brief Floating-point complex-by-real multiplication 272 * @param[in] pSrcCmplx points to the complex input vector 273 * @param[in] pSrcReal points to the real input vector 274 * @param[out] pCmplxDst points to the complex output vector 275 * @param[in] numSamples number of samples in each vector 276 */ 277 void arm_cmplx_mult_real_f32( 278 const float32_t * pSrcCmplx, 279 const float32_t * pSrcReal, 280 float32_t * pCmplxDst, 281 uint32_t numSamples); 282 283 /** 284 * @brief Q15 complex-by-complex multiplication 285 * @param[in] pSrcA points to the first input vector 286 * @param[in] pSrcB points to the second input vector 287 * @param[out] pDst points to the output vector 288 * @param[in] numSamples number of complex samples in each vector 289 */ 290 void arm_cmplx_mult_cmplx_q15( 291 const q15_t * pSrcA, 292 const q15_t * pSrcB, 293 q15_t * pDst, 294 uint32_t numSamples); 295 296 297 /** 298 * @brief Q31 complex-by-complex multiplication 299 * @param[in] pSrcA points to the first input vector 300 * @param[in] pSrcB points to the second input vector 301 * @param[out] pDst points to the output vector 302 * @param[in] numSamples number of complex samples in each vector 303 */ 304 void arm_cmplx_mult_cmplx_q31( 305 const q31_t * pSrcA, 306 const q31_t * pSrcB, 307 q31_t * pDst, 308 uint32_t numSamples); 309 310 311 /** 312 * @brief Floating-point complex-by-complex multiplication 313 * @param[in] pSrcA points to the first input vector 314 * @param[in] pSrcB points to the second input vector 315 * @param[out] pDst points to the output vector 316 * @param[in] numSamples number of complex samples in each vector 317 */ 318 void arm_cmplx_mult_cmplx_f32( 319 const float32_t * pSrcA, 320 const float32_t * pSrcB, 321 float32_t * pDst, 322 uint32_t numSamples); 323 324 325 326 /** 327 * @brief Floating-point complex-by-complex multiplication 328 * @param[in] pSrcA points to the first input vector 329 * @param[in] pSrcB points to the second input vector 330 * @param[out] pDst points to the output vector 331 * @param[in] numSamples number of complex samples in each vector 332 */ 333 void arm_cmplx_mult_cmplx_f64( 334 const float64_t * pSrcA, 335 const float64_t * pSrcB, 336 float64_t * pDst, 337 uint32_t numSamples); 338 339 340 341 #ifdef __cplusplus 342 } 343 #endif 344 345 #endif /* ifndef _COMPLEX_MATH_FUNCTIONS_H_ */ 346