file_path
stringlengths
20
202
content
stringlengths
9
3.85M
size
int64
9
3.85M
lang
stringclasses
9 values
avg_line_length
float64
3.33
100
max_line_length
int64
8
993
alphanum_fraction
float64
0.26
0.93
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/arm_scale_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_scale_q15.c * Description: Multiplies a Q15 vector by a scalar * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMath */ /** @addtogroup BasicScale @{ */ /** @brief Multiplies a Q15 vector by a scalar. @param[in] pSrc points to the input vector @param[in] scaleFract fractional portion of the scale value @param[in] shift number of bits to shift the result by @param[out] pDst points to the output vector @param[in] blockSize number of samples in each vector @return none @par Scaling and Overflow Behavior The input data <code>*pSrc</code> and <code>scaleFract</code> are in 1.15 format. These are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format. */ void arm_scale_q15( const q15_t *pSrc, q15_t scaleFract, int8_t shift, q15_t *pDst, uint32_t blockSize) { uint32_t blkCnt; /* Loop counter */ int8_t kShift = 15 - shift; /* Shift to apply after scaling */ #if defined (ARM_MATH_LOOPUNROLL) #if defined (ARM_MATH_DSP) q31_t inA1, inA2; q31_t out1, out2, out3, out4; /* Temporary output variables */ q15_t in1, in2, in3, in4; /* Temporary input variables */ #endif #endif #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A * scale */ #if defined (ARM_MATH_DSP) /* read 2 times 2 samples at a time from source */ inA1 = read_q15x2_ia ((q15_t **) &pSrc); inA2 = read_q15x2_ia ((q15_t **) &pSrc); /* Scale inputs and store result in temporary variables * in single cycle by packing the outputs */ out1 = (q31_t) ((q15_t) (inA1 >> 16) * scaleFract); out2 = (q31_t) ((q15_t) (inA1 ) * scaleFract); out3 = (q31_t) ((q15_t) (inA2 >> 16) * scaleFract); out4 = (q31_t) ((q15_t) (inA2 ) * scaleFract); /* apply shifting */ out1 = out1 >> kShift; out2 = out2 >> kShift; out3 = out3 >> kShift; out4 = out4 >> kShift; /* saturate the output */ in1 = (q15_t) (__SSAT(out1, 16)); in2 = (q15_t) (__SSAT(out2, 16)); in3 = (q15_t) (__SSAT(out3, 16)); in4 = (q15_t) (__SSAT(out4, 16)); /* store result to destination */ write_q15x2_ia (&pDst, __PKHBT(in2, in1, 16)); write_q15x2_ia (&pDst, __PKHBT(in4, in3, 16)); #else *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16)); *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16)); *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16)); *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16)); #endif /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C = A * scale */ /* Scale input and store result in destination buffer. */ *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16)); /* Decrement loop counter */ blkCnt--; } } /** @} end of BasicScale group */
4,362
C
29.089655
127
0.571298
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/arm_scale_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_scale_f32.c * Description: Multiplies a floating-point vector by a scalar * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMath */ /** @defgroup BasicScale Vector Scale Multiply a vector by a scalar value. For floating-point data, the algorithm used is: <pre> pDst[n] = pSrc[n] * scale, 0 <= n < blockSize. </pre> In the fixed-point Q7, Q15, and Q31 functions, <code>scale</code> is represented by a fractional multiplication <code>scaleFract</code> and an arithmetic shift <code>shift</code>. The shift allows the gain of the scaling operation to exceed 1.0. The algorithm used with fixed-point data is: <pre> pDst[n] = (pSrc[n] * scaleFract) << shift, 0 <= n < blockSize. </pre> The overall scale factor applied to the fixed-point data is <pre> scale = scaleFract * 2^shift. </pre> The functions support in-place computation allowing the source and destination pointers to reference the same memory buffer. */ /** @addtogroup BasicScale @{ */ /** @brief Multiplies a floating-point vector by a scalar. @param[in] pSrc points to the input vector @param[in] scale scale factor to be applied @param[out] pDst points to the output vector @param[in] blockSize number of samples in each vector @return none */ void arm_scale_f32( const float32_t *pSrc, float32_t scale, float32_t *pDst, uint32_t blockSize) { uint32_t blkCnt; /* Loop counter */ #if defined(ARM_MATH_NEON_EXPERIMENTAL) float32x4_t vec1; float32x4_t res; /* Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A * scale */ /* Scale the input and then store the results in the destination buffer. */ vec1 = vld1q_f32(pSrc); res = vmulq_f32(vec1, vdupq_n_f32(scale)); vst1q_f32(pDst, res); /* Increment pointers */ pSrc += 4; pDst += 4; /* Decrement the loop counter */ blkCnt--; } /* Tail */ blkCnt = blockSize & 0x3; #else #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A * scale */ /* Scale input and store result in destination buffer. */ *pDst++ = (*pSrc++) * scale; *pDst++ = (*pSrc++) * scale; *pDst++ = (*pSrc++) * scale; *pDst++ = (*pSrc++) * scale; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ #endif /* #if defined(ARM_MATH_NEON_EXPERIMENTAL) */ while (blkCnt > 0U) { /* C = A * scale */ /* Scale input and store result in destination buffer. */ *pDst++ = (*pSrc++) * scale; /* Decrement loop counter */ blkCnt--; } } /** @} end of BasicScale group */
4,023
C
24.15
97
0.597813
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/BasicMathFunctions.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: BasicMathFunctions.c * Description: Combination of all basic math function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_abs_f32.c" #include "arm_abs_q15.c" #include "arm_abs_q31.c" #include "arm_abs_q7.c" #include "arm_add_f32.c" #include "arm_add_q15.c" #include "arm_add_q31.c" #include "arm_add_q7.c" #include "arm_dot_prod_f32.c" #include "arm_dot_prod_q15.c" #include "arm_dot_prod_q31.c" #include "arm_dot_prod_q7.c" #include "arm_mult_f32.c" #include "arm_mult_q15.c" #include "arm_mult_q31.c" #include "arm_mult_q7.c" #include "arm_negate_f32.c" #include "arm_negate_q15.c" #include "arm_negate_q31.c" #include "arm_negate_q7.c" #include "arm_offset_f32.c" #include "arm_offset_q15.c" #include "arm_offset_q31.c" #include "arm_offset_q7.c" #include "arm_scale_f32.c" #include "arm_scale_q15.c" #include "arm_scale_q31.c" #include "arm_scale_q7.c" #include "arm_shift_q15.c" #include "arm_shift_q31.c" #include "arm_shift_q7.c" #include "arm_sub_f32.c" #include "arm_sub_q15.c" #include "arm_sub_q31.c" #include "arm_sub_q7.c"
1,985
C
30.03125
74
0.652897
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/arm_dot_prod_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_dot_prod_f32.c * Description: Floating-point dot product * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMath */ /** @defgroup BasicDotProd Vector Dot Product Computes the dot product of two vectors. The vectors are multiplied element-by-element and then summed. <pre> sum = pSrcA[0]*pSrcB[0] + pSrcA[1]*pSrcB[1] + ... + pSrcA[blockSize-1]*pSrcB[blockSize-1] </pre> There are separate functions for floating-point, Q7, Q15, and Q31 data types. */ /** @addtogroup BasicDotProd @{ */ /** @brief Dot product of floating-point vectors. @param[in] pSrcA points to the first input vector. @param[in] pSrcB points to the second input vector. @param[in] blockSize number of samples in each vector. @param[out] result output result returned here. @return none */ void arm_dot_prod_f32( const float32_t * pSrcA, const float32_t * pSrcB, uint32_t blockSize, float32_t * result) { uint32_t blkCnt; /* Loop counter */ float32_t sum = 0.0f; /* Temporary return variable */ #if defined(ARM_MATH_NEON) float32x4_t vec1; float32x4_t vec2; float32x4_t res; float32x4_t accum = vdupq_n_f32(0); /* Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; vec1 = vld1q_f32(pSrcA); vec2 = vld1q_f32(pSrcB); while (blkCnt > 0U) { /* C = A[0]*B[0] + A[1]*B[1] + A[2]*B[2] + ... + A[blockSize-1]*B[blockSize-1] */ /* Calculate dot product and then store the result in a temporary buffer. */ accum = vmlaq_f32(accum, vec1, vec2); /* Increment pointers */ pSrcA += 4; pSrcB += 4; vec1 = vld1q_f32(pSrcA); vec2 = vld1q_f32(pSrcB); /* Decrement the loop counter */ blkCnt--; } #if __aarch64__ sum = vpadds_f32(vpadd_f32(vget_low_f32(accum), vget_high_f32(accum))); #else sum = (vpadd_f32(vget_low_f32(accum), vget_high_f32(accum)))[0] + (vpadd_f32(vget_low_f32(accum), vget_high_f32(accum)))[1]; #endif /* Tail */ blkCnt = blockSize & 0x3; #else #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; /* First part of the processing with loop unrolling. Compute 4 outputs at a time. ** a second loop below computes the remaining 1 to 3 samples. */ while (blkCnt > 0U) { /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ sum += (*pSrcA++) * (*pSrcB++); sum += (*pSrcA++) * (*pSrcB++); sum += (*pSrcA++) * (*pSrcB++); sum += (*pSrcA++) * (*pSrcB++); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ #endif /* #if defined(ARM_MATH_NEON) */ while (blkCnt > 0U) { /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ sum += (*pSrcA++) * (*pSrcB++); /* Decrement loop counter */ blkCnt--; } /* Store result in destination buffer */ *result = sum; } /** @} end of BasicDotProd group */
4,430
C
26.018293
128
0.57991
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/arm_scale_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_scale_q7.c * Description: Multiplies a Q7 vector by a scalar * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMath */ /** @addtogroup BasicScale @{ */ /** @brief Multiplies a Q7 vector by a scalar. @param[in] pSrc points to the input vector @param[in] scaleFract fractional portion of the scale value @param[in] shift number of bits to shift the result by @param[out] pDst points to the output vector @param[in] blockSize number of samples in each vector @return none @par Scaling and Overflow Behavior The input data <code>*pSrc</code> and <code>scaleFract</code> are in 1.7 format. These are multiplied to yield a 2.14 intermediate result and this is shifted with saturation to 1.7 format. */ void arm_scale_q7( const q7_t * pSrc, q7_t scaleFract, int8_t shift, q7_t * pDst, uint32_t blockSize) { uint32_t blkCnt; /* Loop counter */ int8_t kShift = 7 - shift; /* Shift to apply after scaling */ #if defined (ARM_MATH_LOOPUNROLL) #if defined (ARM_MATH_DSP) q7_t in1, in2, in3, in4; /* Temporary input variables */ q7_t out1, out2, out3, out4; /* Temporary output variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A * scale */ #if defined (ARM_MATH_DSP) /* Reading 4 inputs from memory */ in1 = *pSrc++; in2 = *pSrc++; in3 = *pSrc++; in4 = *pSrc++; /* Scale inputs and store result in the temporary variable. */ out1 = (q7_t) (__SSAT(((in1) * scaleFract) >> kShift, 8)); out2 = (q7_t) (__SSAT(((in2) * scaleFract) >> kShift, 8)); out3 = (q7_t) (__SSAT(((in3) * scaleFract) >> kShift, 8)); out4 = (q7_t) (__SSAT(((in4) * scaleFract) >> kShift, 8)); /* Pack and store result in destination buffer (in single write) */ write_q7x4_ia (&pDst, __PACKq7(out1, out2, out3, out4)); #else *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8)); *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8)); *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8)); *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8)); #endif /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C = A * scale */ /* Scale input and store result in destination buffer. */ *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8)); /* Decrement loop counter */ blkCnt--; } } /** @} end of BasicScale group */
3,926
C
29.207692
126
0.569282
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/arm_dot_prod_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_dot_prod_q7.c * Description: Q7 dot product * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMath */ /** @addtogroup BasicDotProd @{ */ /** @brief Dot product of Q7 vectors. @param[in] pSrcA points to the first input vector @param[in] pSrcB points to the second input vector @param[in] blockSize number of samples in each vector @param[out] result output result returned here @return none @par Scaling and Overflow Behavior The intermediate multiplications are in 1.7 x 1.7 = 2.14 format and these results are added to an accumulator in 18.14 format. Nonsaturating additions are used and there is no danger of wrap around as long as the vectors are less than 2^18 elements long. The return result is in 18.14 format. */ void arm_dot_prod_q7( const q7_t * pSrcA, const q7_t * pSrcB, uint32_t blockSize, q31_t * result) { uint32_t blkCnt; /* Loop counter */ q31_t sum = 0; /* Temporary return variable */ #if defined (ARM_MATH_LOOPUNROLL) #if defined (ARM_MATH_DSP) q31_t input1, input2; /* Temporary variables */ q31_t inA1, inA2, inB1, inB2; /* Temporary variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ #if defined (ARM_MATH_DSP) /* read 4 samples at a time from sourceA */ input1 = read_q7x4_ia ((q7_t **) &pSrcA); /* read 4 samples at a time from sourceB */ input2 = read_q7x4_ia ((q7_t **) &pSrcB); /* extract two q7_t samples to q15_t samples */ inA1 = __SXTB16(__ROR(input1, 8)); /* extract reminaing two samples */ inA2 = __SXTB16(input1); /* extract two q7_t samples to q15_t samples */ inB1 = __SXTB16(__ROR(input2, 8)); /* extract reminaing two samples */ inB2 = __SXTB16(input2); /* multiply and accumulate two samples at a time */ sum = __SMLAD(inA1, inB1, sum); sum = __SMLAD(inA2, inB2, sum); #else sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); #endif /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ //#if defined (ARM_MATH_DSP) // sum = __SMLAD(*pSrcA++, *pSrcB++, sum); //#else sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); //#endif /* Decrement loop counter */ blkCnt--; } /* Store result in destination buffer in 18.14 format */ *result = sum; } /** @} end of BasicDotProd group */
4,209
C
29.071428
100
0.568306
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/BasicMathFunctions/arm_shift_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_shift_q31.c * Description: Shifts the elements of a Q31 vector by a specified number of bits * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMath */ /** @defgroup BasicShift Vector Shift Shifts the elements of a fixed-point vector by a specified number of bits. There are separate functions for Q7, Q15, and Q31 data types. The underlying algorithm used is: <pre> pDst[n] = pSrc[n] << shift, 0 <= n < blockSize. </pre> If <code>shift</code> is positive then the elements of the vector are shifted to the left. If <code>shift</code> is negative then the elements of the vector are shifted to the right. The functions support in-place computation allowing the source and destination pointers to reference the same memory buffer. */ /** @addtogroup BasicShift @{ */ /** @brief Shifts the elements of a Q31 vector a specified number of bits. @param[in] pSrc points to the input vector @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. @param[out] pDst points to the output vector @param[in] blockSize number of samples in the vector @return none @par Scaling and Overflow Behavior The function uses saturating arithmetic. Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. */ void arm_shift_q31( const q31_t * pSrc, int8_t shiftBits, q31_t * pDst, uint32_t blockSize) { uint32_t blkCnt; /* Loop counter */ uint8_t sign = (shiftBits & 0x80); /* Sign of shiftBits */ #if defined (ARM_MATH_LOOPUNROLL) q31_t in, out; /* Temporary variables */ /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; /* If the shift value is positive then do right shift else left shift */ if (sign == 0U) { while (blkCnt > 0U) { /* C = A << shiftBits */ /* Shift input and store result in destination buffer. */ in = *pSrc++; out = in << shiftBits; if (in != (out >> shiftBits)) out = 0x7FFFFFFF ^ (in >> 31); *pDst++ = out; in = *pSrc++; out = in << shiftBits; if (in != (out >> shiftBits)) out = 0x7FFFFFFF ^ (in >> 31); *pDst++ = out; in = *pSrc++; out = in << shiftBits; if (in != (out >> shiftBits)) out = 0x7FFFFFFF ^ (in >> 31); *pDst++ = out; in = *pSrc++; out = in << shiftBits; if (in != (out >> shiftBits)) out = 0x7FFFFFFF ^ (in >> 31); *pDst++ = out; /* Decrement loop counter */ blkCnt--; } } else { while (blkCnt > 0U) { /* C = A >> shiftBits */ /* Shift input and store results in destination buffer. */ *pDst++ = (*pSrc++ >> -shiftBits); *pDst++ = (*pSrc++ >> -shiftBits); *pDst++ = (*pSrc++ >> -shiftBits); *pDst++ = (*pSrc++ >> -shiftBits); /* Decrement loop counter */ blkCnt--; } } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* If the shift value is positive then do right shift else left shift */ if (sign == 0U) { while (blkCnt > 0U) { /* C = A << shiftBits */ /* Shift input and store result in destination buffer. */ *pDst++ = clip_q63_to_q31((q63_t) *pSrc++ << shiftBits); /* Decrement loop counter */ blkCnt--; } } else { while (blkCnt > 0U) { /* C = A >> shiftBits */ /* Shift input and store result in destination buffer. */ *pDst++ = (*pSrc++ >> -shiftBits); /* Decrement loop counter */ blkCnt--; } } } /** @} end of BasicShift group */
4,918
C
26.027472
114
0.56954
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_inverse_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_inverse_f32.c * Description: Floating-point matrix inverse * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @defgroup MatrixInv Matrix Inverse Computes the inverse of a matrix. The inverse is defined only if the input matrix is square and non-singular (the determinant is non-zero). The function checks that the input and output matrices are square and of the same size. Matrix inversion is numerically sensitive and the CMSIS DSP library only supports matrix inversion of floating-point matrices. @par Algorithm The Gauss-Jordan method is used to find the inverse. The algorithm performs a sequence of elementary row-operations until it reduces the input matrix to an identity matrix. Applying the same sequence of elementary row-operations to an identity matrix yields the inverse matrix. If the input matrix is singular, then the algorithm terminates and returns error status <code>ARM_MATH_SINGULAR</code>. \image html MatrixInverse.gif "Matrix Inverse of a 3 x 3 matrix using Gauss-Jordan Method" */ /** @addtogroup MatrixInv @{ */ /** @brief Floating-point matrix inverse. @param[in] pSrc points to input matrix structure @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed - \ref ARM_MATH_SINGULAR : Input matrix is found to be singular (non-invertible) */ #if defined(ARM_MATH_NEON) arm_status arm_mat_inverse_f32( const arm_matrix_instance_f32 * pSrc, arm_matrix_instance_f32 * pDst) { float32_t *pIn = pSrc->pData; /* input data matrix pointer */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ float32_t *pInT1, *pInT2; /* Temporary input data matrix pointer */ float32_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */ float32_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, *pPRT_pDst; /* Temporary input and output data matrix pointer */ uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */ uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */ float32_t maxC; /* maximum value in the column */ float32_t Xchg, in = 0.0f, in1; /* Temporary input values */ uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ arm_status status; /* status of matrix inverse */ float32x4_t vec1; float32x4_t vec2; float32x4_t tmpV; #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || (pSrc->numRows != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /*-------------------------------------------------------------------------------------------------------------- * Matrix Inverse can be solved using elementary row operations. * * Gauss-Jordan Method: * * 1. First combine the identity matrix and the input matrix separated by a bar to form an * augmented matrix as follows: * _ _ _ _ * | a11 a12 | 1 0 | | X11 X12 | * | | | = | | * |_ a21 a22 | 0 1 _| |_ X21 X21 _| * * 2. In our implementation, pDst Matrix is used as identity matrix. * * 3. Begin with the first row. Let i = 1. * * 4. Check to see if the pivot for column i is the greatest of the column. * The pivot is the element of the main diagonal that is on the current row. * For instance, if working with row i, then the pivot element is aii. * If the pivot is not the most significant of the columns, exchange that row with a row * below it that does contain the most significant value in column i. If the most * significant value of the column is zero, then an inverse to that matrix does not exist. * The most significant value of the column is the absolute maximum. * * 5. Divide every element of row i by the pivot. * * 6. For every row below and row i, replace that row with the sum of that row and * a multiple of row i so that each new element in column i below row i is zero. * * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros * for every element below and above the main diagonal. * * 8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc). * Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ pOutT1 = pOut; /* Loop over the number of rows */ rowCnt = numRows; /* Making the destination matrix as identity matrix */ while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; while (j > 0U) { *pOutT1++ = 0.0f; j--; } /* Writing all ones in the diagonal of the destination matrix */ *pOutT1++ = 1.0f; /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; while (j > 0U) { *pOutT1++ = 0.0f; j--; } /* Decrement the loop counter */ rowCnt--; } /* Loop over the number of columns of the input matrix. All the elements in each column are processed by the row operations */ loopCnt = numCols; /* Index modifier to navigate through the columns */ l = 0U; while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, * then the matrix is Singular. */ /* Working pointer for the input matrix that points * to the pivot element of the particular row */ pInT1 = pIn + (l * numCols); /* Working pointer for the destination matrix that points * to the pivot element of the particular row */ pOutT1 = pOut + (l * numCols); /* Temporary variable to hold the pivot value */ in = *pInT1; /* Grab the most significant value from column l */ maxC = 0; for (i = l; i < numRows; i++) { maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) : (-*pInT1 > maxC ? -*pInT1 : maxC); pInT1 += numCols; } /* Update the status if the matrix is singular */ if (maxC == 0.0f) { return ARM_MATH_SINGULAR; } /* Restore pInT1 */ pInT1 = pIn; /* Destination pointer modifier */ k = 1U; /* Check if the pivot element is the most significant of the column */ if ( (in > 0.0f ? in : -in) != maxC) { /* Loop over the number rows present below */ i = numRows - (l + 1U); while (i > 0U) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Look for the most significant element to * replace in the rows below */ if ((*pInT2 > 0.0f ? *pInT2: -*pInT2) == maxC) { /* Loop over number of columns * to the right of the pilot element */ j = numCols - l; while (j > 0U) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; *pInT1++ = Xchg; /* Decrement the loop counter */ j--; } /* Loop over number of columns of the destination matrix */ j = numCols; while (j > 0U) { /* Exchange the row elements of the destination matrix */ Xchg = *pOutT2; *pOutT2++ = *pOutT1; *pOutT1++ = Xchg; /* Decrement the loop counter */ j--; } /* Flag to indicate whether exchange is done or not */ flag = 1U; /* Break after exchange is done */ break; } /* Update the destination pointer modifier */ k++; /* Decrement the loop counter */ i--; } } /* Update the status if the matrix is singular */ if ((flag != 1U) && (in == 0.0f)) { return ARM_MATH_SINGULAR; } /* Points to the pivot row of input and destination matrices */ pPivotRowIn = pIn + (l * numCols); pPivotRowDst = pOut + (l * numCols); /* Temporary pointers to the pivot row pointers */ pInT1 = pPivotRowIn; pInT2 = pPivotRowDst; /* Pivot element of the row */ in = *pPivotRowIn; tmpV = vdupq_n_f32(1.0/in); /* Loop over number of columns * to the right of the pilot element */ j = (numCols - l) >> 2; while (j > 0U) { /* Divide each element of the row of the input matrix * by the pivot element */ vec1 = vld1q_f32(pInT1); vec1 = vmulq_f32(vec1, tmpV); vst1q_f32(pInT1, vec1); pInT1 += 4; /* Decrement the loop counter */ j--; } /* Tail */ j = (numCols - l) & 3; while (j > 0U) { /* Divide each element of the row of the input matrix * by the pivot element */ in1 = *pInT1; *pInT1++ = in1 / in; /* Decrement the loop counter */ j--; } /* Loop over number of columns of the destination matrix */ j = numCols >> 2; while (j > 0U) { /* Divide each element of the row of the destination matrix * by the pivot element */ vec1 = vld1q_f32(pInT2); vec1 = vmulq_f32(vec1, tmpV); vst1q_f32(pInT2, vec1); pInT2 += 4; /* Decrement the loop counter */ j--; } /* Tail */ j = numCols & 3; while (j > 0U) { /* Divide each element of the row of the destination matrix * by the pivot element */ in1 = *pInT2; *pInT2++ = in1 / in; /* Decrement the loop counter */ j--; } /* Replace the rows with the sum of that row and a multiple of row i * so that each new element in column i above row i is zero.*/ /* Temporary pointers for input and destination matrices */ pInT1 = pIn; pInT2 = pOut; /* index used to check for pivot element */ i = 0U; /* Loop over number of rows */ /* to be replaced by the sum of that row and a multiple of row i */ k = numRows; while (k > 0U) { /* Check for the pivot element */ if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pInT2 += numCols; } else { /* Element of the reference row */ in = *pInT1; tmpV = vdupq_n_f32(in); /* Working pointers for input and destination pivot rows */ pPRT_in = pPivotRowIn; pPRT_pDst = pPivotRowDst; /* Loop over the number of columns to the right of the pivot element, to replace the elements in the input matrix */ j = (numCols - l) >> 2; while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ vec1 = vld1q_f32(pInT1); vec2 = vld1q_f32(pPRT_in); vec1 = vmlsq_f32(vec1, tmpV, vec2); vst1q_f32(pInT1, vec1); pPRT_in += 4; pInT1 += 4; /* Decrement the loop counter */ j--; } /* Tail */ j = (numCols - l) & 3; while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT1; *pInT1++ = in1 - (in * *pPRT_in++); /* Decrement the loop counter */ j--; } /* Loop over the number of columns to replace the elements in the destination matrix */ j = numCols >> 2; while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ vec1 = vld1q_f32(pInT2); vec2 = vld1q_f32(pPRT_pDst); vec1 = vmlsq_f32(vec1, tmpV, vec2); vst1q_f32(pInT2, vec1); pPRT_pDst += 4; pInT2 += 4; /* Decrement the loop counter */ j--; } /* Tail */ j = numCols & 3; while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT2; *pInT2++ = in1 - (in * *pPRT_pDst++); /* Decrement the loop counter */ j--; } } /* Increment the temporary input pointer */ pInT1 = pInT1 + l; /* Decrement the loop counter */ k--; /* Increment the pivot index */ i++; } /* Increment the input pointer */ pIn++; /* Decrement the loop counter */ loopCnt--; /* Increment the index modifier */ l++; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; if ((flag != 1U) && (in == 0.0f)) { pIn = pSrc->pData; for (i = 0; i < numRows * numCols; i++) { if (pIn[i] != 0.0f) break; } if (i == numRows * numCols) status = ARM_MATH_SINGULAR; } } /* Return to application */ return (status); } #else arm_status arm_mat_inverse_f32( const arm_matrix_instance_f32 * pSrc, arm_matrix_instance_f32 * pDst) { float32_t *pIn = pSrc->pData; /* input data matrix pointer */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ float32_t *pInT1, *pInT2; /* Temporary input data matrix pointer */ float32_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */ float32_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, *pPRT_pDst; /* Temporary input and output data matrix pointer */ uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */ uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */ #if defined (ARM_MATH_DSP) float32_t maxC; /* maximum value in the column */ float32_t Xchg, in = 0.0f, in1; /* Temporary input values */ uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ arm_status status; /* status of matrix inverse */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || (pSrc->numRows != pDst->numRows) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /*-------------------------------------------------------------------------------------------------------------- * Matrix Inverse can be solved using elementary row operations. * * Gauss-Jordan Method: * * 1. First combine the identity matrix and the input matrix separated by a bar to form an * augmented matrix as follows: * _ _ _ _ * | a11 a12 | 1 0 | | X11 X12 | * | | | = | | * |_ a21 a22 | 0 1 _| |_ X21 X21 _| * * 2. In our implementation, pDst Matrix is used as identity matrix. * * 3. Begin with the first row. Let i = 1. * * 4. Check to see if the pivot for column i is the greatest of the column. * The pivot is the element of the main diagonal that is on the current row. * For instance, if working with row i, then the pivot element is aii. * If the pivot is not the most significant of the columns, exchange that row with a row * below it that does contain the most significant value in column i. If the most * significant value of the column is zero, then an inverse to that matrix does not exist. * The most significant value of the column is the absolute maximum. * * 5. Divide every element of row i by the pivot. * * 6. For every row below and row i, replace that row with the sum of that row and * a multiple of row i so that each new element in column i below row i is zero. * * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros * for every element below and above the main diagonal. * * 8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc). * Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ pOutT1 = pOut; /* Loop over the number of rows */ rowCnt = numRows; /* Making the destination matrix as identity matrix */ while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; while (j > 0U) { *pOutT1++ = 0.0f; j--; } /* Writing all ones in the diagonal of the destination matrix */ *pOutT1++ = 1.0f; /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; while (j > 0U) { *pOutT1++ = 0.0f; j--; } /* Decrement loop counter */ rowCnt--; } /* Loop over the number of columns of the input matrix. All the elements in each column are processed by the row operations */ loopCnt = numCols; /* Index modifier to navigate through the columns */ l = 0U; while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, * then the matrix is Singular. */ /* Working pointer for the input matrix that points * to the pivot element of the particular row */ pInT1 = pIn + (l * numCols); /* Working pointer for the destination matrix that points * to the pivot element of the particular row */ pOutT1 = pOut + (l * numCols); /* Temporary variable to hold the pivot value */ in = *pInT1; /* Grab the most significant value from column l */ maxC = 0; for (i = l; i < numRows; i++) { maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) : (-*pInT1 > maxC ? -*pInT1 : maxC); pInT1 += numCols; } /* Update the status if the matrix is singular */ if (maxC == 0.0f) { return ARM_MATH_SINGULAR; } /* Restore pInT1 */ pInT1 = pIn; /* Destination pointer modifier */ k = 1U; /* Check if the pivot element is the most significant of the column */ if ( (in > 0.0f ? in : -in) != maxC) { /* Loop over the number rows present below */ i = numRows - (l + 1U); while (i > 0U) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Look for the most significant element to * replace in the rows below */ if ((*pInT2 > 0.0f ? *pInT2: -*pInT2) == maxC) { /* Loop over number of columns * to the right of the pilot element */ j = numCols - l; while (j > 0U) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; *pInT1++ = Xchg; /* Decrement the loop counter */ j--; } /* Loop over number of columns of the destination matrix */ j = numCols; while (j > 0U) { /* Exchange the row elements of the destination matrix */ Xchg = *pOutT2; *pOutT2++ = *pOutT1; *pOutT1++ = Xchg; /* Decrement loop counter */ j--; } /* Flag to indicate whether exchange is done or not */ flag = 1U; /* Break after exchange is done */ break; } /* Update the destination pointer modifier */ k++; /* Decrement loop counter */ i--; } } /* Update the status if the matrix is singular */ if ((flag != 1U) && (in == 0.0f)) { return ARM_MATH_SINGULAR; } /* Points to the pivot row of input and destination matrices */ pPivotRowIn = pIn + (l * numCols); pPivotRowDst = pOut + (l * numCols); /* Temporary pointers to the pivot row pointers */ pInT1 = pPivotRowIn; pInT2 = pPivotRowDst; /* Pivot element of the row */ in = *pPivotRowIn; /* Loop over number of columns * to the right of the pilot element */ j = (numCols - l); while (j > 0U) { /* Divide each element of the row of the input matrix * by the pivot element */ in1 = *pInT1; *pInT1++ = in1 / in; /* Decrement the loop counter */ j--; } /* Loop over number of columns of the destination matrix */ j = numCols; while (j > 0U) { /* Divide each element of the row of the destination matrix * by the pivot element */ in1 = *pInT2; *pInT2++ = in1 / in; /* Decrement the loop counter */ j--; } /* Replace the rows with the sum of that row and a multiple of row i * so that each new element in column i above row i is zero.*/ /* Temporary pointers for input and destination matrices */ pInT1 = pIn; pInT2 = pOut; /* index used to check for pivot element */ i = 0U; /* Loop over number of rows */ /* to be replaced by the sum of that row and a multiple of row i */ k = numRows; while (k > 0U) { /* Check for the pivot element */ if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pInT2 += numCols; } else { /* Element of the reference row */ in = *pInT1; /* Working pointers for input and destination pivot rows */ pPRT_in = pPivotRowIn; pPRT_pDst = pPivotRowDst; /* Loop over the number of columns to the right of the pivot element, to replace the elements in the input matrix */ j = (numCols - l); while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT1; *pInT1++ = in1 - (in * *pPRT_in++); /* Decrement the loop counter */ j--; } /* Loop over the number of columns to replace the elements in the destination matrix */ j = numCols; while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT2; *pInT2++ = in1 - (in * *pPRT_pDst++); /* Decrement loop counter */ j--; } } /* Increment temporary input pointer */ pInT1 = pInT1 + l; /* Decrement loop counter */ k--; /* Increment pivot index */ i++; } /* Increment the input pointer */ pIn++; /* Decrement the loop counter */ loopCnt--; /* Increment the index modifier */ l++; } #else float32_t Xchg, in = 0.0f; /* Temporary input values */ uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ arm_status status; /* status of matrix inverse */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || (pSrc->numRows != pDst->numRows) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /*-------------------------------------------------------------------------------------------------------------- * Matrix Inverse can be solved using elementary row operations. * * Gauss-Jordan Method: * * 1. First combine the identity matrix and the input matrix separated by a bar to form an * augmented matrix as follows: * _ _ _ _ _ _ _ _ * | | a11 a12 | | | 1 0 | | | X11 X12 | * | | | | | | | = | | * |_ |_ a21 a22 _| | |_0 1 _| _| |_ X21 X21 _| * * 2. In our implementation, pDst Matrix is used as identity matrix. * * 3. Begin with the first row. Let i = 1. * * 4. Check to see if the pivot for row i is zero. * The pivot is the element of the main diagonal that is on the current row. * For instance, if working with row i, then the pivot element is aii. * If the pivot is zero, exchange that row with a row below it that does not * contain a zero in column i. If this is not possible, then an inverse * to that matrix does not exist. * * 5. Divide every element of row i by the pivot. * * 6. For every row below and row i, replace that row with the sum of that row and * a multiple of row i so that each new element in column i below row i is zero. * * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros * for every element below and above the main diagonal. * * 8. Now an identical matrix is formed to the left of the bar(input matrix, src). * Therefore, the matrix to the right of the bar is our solution(dst matrix, dst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ pOutT1 = pOut; /* Loop over the number of rows */ rowCnt = numRows; /* Making the destination matrix as identity matrix */ while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; while (j > 0U) { *pOutT1++ = 0.0f; j--; } /* Writing all ones in the diagonal of the destination matrix */ *pOutT1++ = 1.0f; /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; while (j > 0U) { *pOutT1++ = 0.0f; j--; } /* Decrement loop counter */ rowCnt--; } /* Loop over the number of columns of the input matrix. All the elements in each column are processed by the row operations */ loopCnt = numCols; /* Index modifier to navigate through the columns */ l = 0U; while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, * then the matrix is Singular. */ /* Working pointer for the input matrix that points * to the pivot element of the particular row */ pInT1 = pIn + (l * numCols); /* Working pointer for the destination matrix that points * to the pivot element of the particular row */ pOutT1 = pOut + (l * numCols); /* Temporary variable to hold the pivot value */ in = *pInT1; /* Destination pointer modifier */ k = 1U; /* Check if the pivot element is zero */ if (*pInT1 == 0.0f) { /* Loop over the number rows present below */ for (i = (l + 1U); i < numRows; i++) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Check if there is a non zero pivot element to * replace in the rows below */ if (*pInT2 != 0.0f) { /* Loop over number of columns * to the right of the pilot element */ for (j = 0U; j < (numCols - l); j++) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; *pInT1++ = Xchg; } for (j = 0U; j < numCols; j++) { Xchg = *pOutT2; *pOutT2++ = *pOutT1; *pOutT1++ = Xchg; } /* Flag to indicate whether exchange is done or not */ flag = 1U; /* Break after exchange is done */ break; } /* Update the destination pointer modifier */ k++; } } /* Update the status if the matrix is singular */ if ((flag != 1U) && (in == 0.0f)) { return ARM_MATH_SINGULAR; } /* Points to the pivot row of input and destination matrices */ pPivotRowIn = pIn + (l * numCols); pPivotRowDst = pOut + (l * numCols); /* Temporary pointers to the pivot row pointers */ pInT1 = pPivotRowIn; pOutT1 = pPivotRowDst; /* Pivot element of the row */ in = *(pIn + (l * numCols)); /* Loop over number of columns * to the right of the pilot element */ for (j = 0U; j < (numCols - l); j++) { /* Divide each element of the row of the input matrix * by the pivot element */ *pInT1 = *pInT1 / in; pInT1++; } for (j = 0U; j < numCols; j++) { /* Divide each element of the row of the destination matrix * by the pivot element */ *pOutT1 = *pOutT1 / in; pOutT1++; } /* Replace the rows with the sum of that row and a multiple of row i * so that each new element in column i above row i is zero.*/ /* Temporary pointers for input and destination matrices */ pInT1 = pIn; pOutT1 = pOut; for (i = 0U; i < numRows; i++) { /* Check for the pivot element */ if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pOutT1 += numCols; } else { /* Element of the reference row */ in = *pInT1; /* Working pointers for input and destination pivot rows */ pPRT_in = pPivotRowIn; pPRT_pDst = pPivotRowDst; /* Loop over the number of columns to the right of the pivot element, to replace the elements in the input matrix */ for (j = 0U; j < (numCols - l); j++) { /* Replace the element by the sum of that row and a multiple of the reference row */ *pInT1 = *pInT1 - (in * *pPRT_in++); pInT1++; } /* Loop over the number of columns to replace the elements in the destination matrix */ for (j = 0U; j < numCols; j++) { /* Replace the element by the sum of that row and a multiple of the reference row */ *pOutT1 = *pOutT1 - (in * *pPRT_pDst++); pOutT1++; } } /* Increment temporary input pointer */ pInT1 = pInT1 + l; } /* Increment the input pointer */ pIn++; /* Decrement the loop counter */ loopCnt--; /* Increment the index modifier */ l++; } #endif /* #if defined (ARM_MATH_DSP) */ /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; if ((flag != 1U) && (in == 0.0f)) { pIn = pSrc->pData; for (i = 0; i < numRows * numCols; i++) { if (pIn[i] != 0.0f) break; } if (i == numRows * numCols) status = ARM_MATH_SINGULAR; } } /* Return to application */ return (status); } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of MatrixInv group */
35,100
C
30.117908
120
0.515499
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_add_q15.c * Description: Q15 matrix addition * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixAdd @{ */ /** @brief Q15 matrix addition. @param[in] pSrcA points to first input matrix structure @param[in] pSrcB points to second input matrix structure @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The function uses saturating arithmetic. Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. */ arm_status arm_mat_add_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst) { q15_t *pInA = pSrcA->pData; /* input data matrix pointer A */ q15_t *pInB = pSrcB->pData; /* input data matrix pointer B */ q15_t *pOut = pDst->pData; /* output data matrix pointer */ uint32_t numSamples; /* total number of elements in the matrix */ uint32_t blkCnt; /* loop counters */ arm_status status; /* status of matrix addition */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || (pSrcA->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add, saturate and store result in destination buffer. */ #if defined (ARM_MATH_DSP) write_q15x2_ia (&pOut, __QADD16(read_q15x2_ia (&pInA), read_q15x2_ia (&pInB))); write_q15x2_ia (&pOut, __QADD16(read_q15x2_ia (&pInA), read_q15x2_ia (&pInB))); #else *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); #endif /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = numSamples % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = numSamples; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add, saturate and store result in destination buffer. */ #if defined (ARM_MATH_DSP) *pOut++ = (q15_t) __QADD16(*pInA++, *pInB++); #else *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); #endif /* Decrement loop counter */ blkCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixAdd group */
4,468
C
28.793333
99
0.562668
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_scale_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_scale_f32.c * Description: Multiplies a floating-point matrix by a scalar * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @defgroup MatrixScale Matrix Scale Multiplies a matrix by a scalar. This is accomplished by multiplying each element in the matrix by the scalar. For example: \image html MatrixScale.gif "Matrix Scaling of a 3 x 3 matrix" The function checks to make sure that the input and output matrices are of the same size. In the fixed-point Q15 and Q31 functions, <code>scale</code> is represented by a fractional multiplication <code>scaleFract</code> and an arithmetic shift <code>shift</code>. The shift allows the gain of the scaling operation to exceed 1.0. The overall scale factor applied to the fixed-point data is <pre> scale = scaleFract * 2^shift. </pre> */ /** @addtogroup MatrixScale @{ */ /** @brief Floating-point matrix scaling. @param[in] pSrc points to input matrix @param[in] scale scale factor to be applied @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ #if defined(ARM_MATH_NEON_EXPERIMENTAL) arm_status arm_mat_scale_f32( const arm_matrix_instance_f32 * pSrc, float32_t scale, arm_matrix_instance_f32 * pDst) { float32_t *pIn = pSrc->pData; /* input data matrix pointer */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ uint32_t numSamples; /* total number of elements in the matrix */ uint32_t blkCnt; /* loop counters */ arm_status status; /* status of matrix scaling */ float32_t in1, in2, in3, in4; /* temporary variables */ float32_t out1, out2, out3, out4; /* temporary variables */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { float32x4_t vec1; float32x4_t res; /* Total number of samples in the input matrix */ numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; blkCnt = numSamples >> 2; /* Compute 4 outputs at a time. ** a second loop below computes the remaining 1 to 3 samples. */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) * scale */ /* Scaling and results are stored in the destination buffer. */ vec1 = vld1q_f32(pIn); res = vmulq_f32(vec1, vdupq_n_f32(scale)); vst1q_f32(pOut, res); /* update pointers to process next sampels */ pIn += 4U; pOut += 4U; /* Decrement the numSamples loop counter */ blkCnt--; } /* If the numSamples is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ blkCnt = numSamples % 0x4U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) * scale */ /* The results are stored in the destination buffer. */ *pOut++ = (*pIn++) * scale; /* Decrement the loop counter */ blkCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #else arm_status arm_mat_scale_f32( const arm_matrix_instance_f32 * pSrc, float32_t scale, arm_matrix_instance_f32 * pDst) { float32_t *pIn = pSrc->pData; /* Input data matrix pointer */ float32_t *pOut = pDst->pData; /* Output data matrix pointer */ uint32_t numSamples; /* Total number of elements in the matrix */ uint32_t blkCnt; /* Loop counters */ arm_status status; /* Status of matrix scaling */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) * scale */ /* Scale and store result in destination buffer. */ *pOut++ = (*pIn++) * scale; *pOut++ = (*pIn++) * scale; *pOut++ = (*pIn++) * scale; *pOut++ = (*pIn++) * scale; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = numSamples % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = numSamples; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) * scale */ /* Scale and store result in destination buffer. */ *pOut++ = (*pIn++) * scale; /* Decrement loop counter */ blkCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of MatrixScale group */
6,563
C
28.567567
97
0.587689
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_init_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_init_f32.c * Description: Floating-point matrix initialization * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @defgroup MatrixInit Matrix Initialization Initializes the underlying matrix data structure. The functions set the <code>numRows</code>, <code>numCols</code>, and <code>pData</code> fields of the matrix data structure. */ /** @addtogroup MatrixInit @{ */ /** @brief Floating-point matrix initialization. @param[in,out] S points to an instance of the floating-point matrix structure @param[in] nRows number of rows in the matrix @param[in] nColumns number of columns in the matrix @param[in] pData points to the matrix data array @return none */ void arm_mat_init_f32( arm_matrix_instance_f32 * S, uint16_t nRows, uint16_t nColumns, float32_t * pData) { /* Assign Number of Rows */ S->numRows = nRows; /* Assign Number of Columns */ S->numCols = nColumns; /* Assign Data pointer */ S->pData = pData; } /** @} end of MatrixInit group */
2,042
C
25.532467
87
0.629775
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_add_f32.c * Description: Floating-point matrix addition * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @defgroup MatrixAdd Matrix Addition Adds two matrices. \image html MatrixAddition.gif "Addition of two 3 x 3 matrices" The functions check to make sure that <code>pSrcA</code>, <code>pSrcB</code>, and <code>pDst</code> have the same number of rows and columns. */ /** @addtogroup MatrixAdd @{ */ /** @brief Floating-point matrix addition. @param[in] pSrcA points to first input matrix structure @param[in] pSrcB points to second input matrix structure @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ #if defined(ARM_MATH_NEON) /* Neon version is assuming the matrix is small enough. So no blocking is used for taking into account cache effects. For big matrix, there exist better libraries for Neon. */ arm_status arm_mat_add_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst) { float32_t *pIn1 = pSrcA->pData; /* input data matrix pointer A */ float32_t *pIn2 = pSrcB->pData; /* input data matrix pointer B */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ float32_t inA1, inA2, inB1, inB2, out1, out2; /* temporary variables */ uint32_t numSamples; /* total number of elements in the matrix */ uint32_t blkCnt; /* loop counters */ arm_status status; /* status of matrix addition */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif { float32x4_t vec1; float32x4_t vec2; float32x4_t res; /* Total number of samples in the input matrix */ numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; blkCnt = numSamples >> 2U; /* Compute 4 outputs at a time. ** a second loop below computes the remaining 1 to 3 samples. */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add and then store the results in the destination buffer. */ vec1 = vld1q_f32(pIn1); vec2 = vld1q_f32(pIn2); res = vaddq_f32(vec1, vec2); vst1q_f32(pOut, res); /* update pointers to process next samples */ pIn1 += 4U; pIn2 += 4U; pOut += 4U; /* Decrement the loop counter */ blkCnt--; } /* If the numSamples is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ blkCnt = numSamples % 0x4U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add and then store the results in the destination buffer. */ *pOut++ = (*pIn1++) + (*pIn2++); /* Decrement the loop counter */ blkCnt--; } /* set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #else arm_status arm_mat_add_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst) { float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ float32_t *pInB = pSrcB->pData; /* input data matrix pointer B */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ uint32_t numSamples; /* total number of elements in the matrix */ uint32_t blkCnt; /* loop counters */ arm_status status; /* status of matrix addition */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || (pSrcA->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add and store result in destination buffer. */ *pOut++ = *pInA++ + *pInB++; *pOut++ = *pInA++ + *pInB++; *pOut++ = *pInA++ + *pInB++; *pOut++ = *pInA++ + *pInB++; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = numSamples % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = numSamples; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add and store result in destination buffer. */ *pOut++ = *pInA++ + *pInB++; /* Decrement loop counter */ blkCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of MatrixAdd group */
6,652
C
27.553648
94
0.58193
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cmplx_mat_mult_q15.c * Description: Q15 complex matrix multiplication * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup CmplxMatrixMult @{ */ /** @brief Q15 Complex matrix multiplication. @param[in] pSrcA points to first input complex matrix structure @param[in] pSrcB points to second input complex matrix structure @param[out] pDst points to output complex matrix structure @param[in] pScratch points to an array for storing intermediate results @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Conditions for optimum performance Input, output and state buffers should be aligned by 32-bit @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The inputs to the multiplications are in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. This approach provides 33 guard bits and there is no risk of overflow. The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format. */ arm_status arm_mat_cmplx_mult_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst, q15_t * pScratch) { q15_t *pSrcBT = pScratch; /* input data matrix pointer for transpose */ q15_t *pInA = pSrcA->pData; /* input data matrix pointer A of Q15 type */ q15_t *pInB = pSrcB->pData; /* input data matrix pointer B of Q15 type */ q15_t *px; /* Temporary output data matrix pointer */ uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */ uint16_t numRowsB = pSrcB->numRows; /* number of rows of input matrix A */ q63_t sumReal, sumImag; /* accumulator */ uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ arm_status status; /* Status of matrix multiplication */ #if defined (ARM_MATH_DSP) q31_t prod1, prod2; q31_t pSourceA, pSourceB; #else q15_t a, b, c, d; #endif /* #if defined (ARM_MATH_DSP) */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose */ do { /* The pointer px is set to starting address of column being processed */ px = pSrcBT + i; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and exchange the columns with row elements */ col = numColsB >> 2; /* First part of the processing with loop unrolling. Compute 4 outputs at a time. a second loop below computes the remaining 1 to 3 samples. */ while (col > 0U) { /* Read two elements from row */ write_q15x2 (px, read_q15x2_ia (&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Read two elements from row */ write_q15x2 (px, read_q15x2_ia (&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Read two elements from row */ write_q15x2 (px, read_q15x2_ia (&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Read two elements from row */ write_q15x2 (px, read_q15x2_ia (&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Decrement column loop counter */ col--; } /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ col = numColsB % 0x4U; #else /* Initialize blkCnt with number of samples */ col = numColsB; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (col > 0U) { /* Read two elements from row */ write_q15x2 (px, read_q15x2_ia (&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Decrement column loop counter */ col--; } i = i + 2U; /* Decrement row loop counter */ row--; } while (row > 0U); /* Reset variables for usage in following multiplication process */ row = numRowsA; i = 0U; px = pDst->pData; /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ do { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; /* For every row wise process, pIn2 pointer is set to starting address of transposed pSrcB data */ pInB = pSrcBT; /* column loop */ do { /* Set variable sum, that acts as accumulator, to zero */ sumReal = 0; sumImag = 0; /* Initiate pointer pInA to point to starting address of column being processed */ pInA = pSrcA->pData + i * 2; /* Apply loop unrolling and compute 2 MACs simultaneously. */ colCnt = numColsA >> 1U; /* matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ #if defined (ARM_MATH_DSP) /* read real and imag values from pSrcA and pSrcB buffer */ pSourceA = read_q15x2_ia ((q15_t **) &pInA); pSourceB = read_q15x2_ia ((q15_t **) &pInB); /* Multiply and Accumlates */ #ifdef ARM_MATH_BIG_ENDIAN prod1 = -__SMUSD(pSourceA, pSourceB); #else prod1 = __SMUSD(pSourceA, pSourceB); #endif prod2 = __SMUADX(pSourceA, pSourceB); sumReal += (q63_t) prod1; sumImag += (q63_t) prod2; /* read real and imag values from pSrcA and pSrcB buffer */ pSourceA = read_q15x2_ia ((q15_t **) &pInA); pSourceB = read_q15x2_ia ((q15_t **) &pInB); /* Multiply and Accumlates */ #ifdef ARM_MATH_BIG_ENDIAN prod1 = -__SMUSD(pSourceA, pSourceB); #else prod1 = __SMUSD(pSourceA, pSourceB); #endif prod2 = __SMUADX(pSourceA, pSourceB); sumReal += (q63_t) prod1; sumImag += (q63_t) prod2; #else /* #if defined (ARM_MATH_DSP) */ /* read real and imag values from pSrcA buffer */ a = *pInA; b = *(pInA + 1U); /* read real and imag values from pSrcB buffer */ c = *pInB; d = *(pInB + 1U); /* Multiply and Accumlates */ sumReal += (q31_t) a *c; sumImag += (q31_t) a *d; sumReal -= (q31_t) b *d; sumImag += (q31_t) b *c; /* read next real and imag values from pSrcA buffer */ a = *(pInA + 2U); b = *(pInA + 3U); /* read next real and imag values from pSrcB buffer */ c = *(pInB + 2U); d = *(pInB + 3U); /* update pointer */ pInA += 4U; /* Multiply and Accumlates */ sumReal += (q31_t) a * c; sumImag += (q31_t) a * d; sumReal -= (q31_t) b * d; sumImag += (q31_t) b * c; /* update pointer */ pInB += 4U; #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ colCnt--; } /* process odd column samples */ if ((numColsA & 0x1U) > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ #if defined (ARM_MATH_DSP) /* read real and imag values from pSrcA and pSrcB buffer */ pSourceA = read_q15x2_ia ((q15_t **) &pInA); pSourceB = read_q15x2_ia ((q15_t **) &pInB); /* Multiply and Accumlates */ #ifdef ARM_MATH_BIG_ENDIAN prod1 = -__SMUSD(pSourceA, pSourceB); #else prod1 = __SMUSD(pSourceA, pSourceB); #endif prod2 = __SMUADX(pSourceA, pSourceB); sumReal += (q63_t) prod1; sumImag += (q63_t) prod2; #else /* #if defined (ARM_MATH_DSP) */ /* read real and imag values from pSrcA and pSrcB buffer */ a = *pInA++; b = *pInA++; c = *pInB++; d = *pInB++; /* Multiply and Accumlates */ sumReal += (q31_t) a * c; sumImag += (q31_t) a * d; sumReal -= (q31_t) b * d; sumImag += (q31_t) b * c; #endif /* #if defined (ARM_MATH_DSP) */ } /* Saturate and store result in destination buffer */ *px++ = (q15_t) (__SSAT(sumReal >> 15, 16)); *px++ = (q15_t) (__SSAT(sumImag >> 15, 16)); /* Decrement column loop counter */ col--; } while (col > 0U); i = i + numColsA; /* Decrement row loop counter */ row--; } while (row > 0U); /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixMult group */
10,896
C
30.956012
114
0.546714
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_mult_fast_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_mult_fast_q31.c * Description: Q31 matrix multiplication (fast variant) * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixMult @{ */ /** @brief Q31 matrix multiplication (fast variant). @param[in] pSrcA points to the first input matrix structure @param[in] pSrcB points to the second input matrix structure @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The difference between the function \ref arm_mat_mult_q31() and this fast variant is that the fast variant use a 32-bit rather than a 64-bit accumulator. The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format. These intermediate results are accumulated in a 32-bit register in 2.30 format. Finally, the accumulator is saturated and converted to a 1.31 result. @par The fast version has the same overflow behavior as the standard version but provides less precision since it discards the low 32 bits of each multiplication result. In order to avoid overflows completely the input signals must be scaled down. Scale down one of the input matrices by log2(numColsA) bits to avoid overflows, as a total of numColsA additions are computed internally for each output element. @remark Refer to \ref arm_mat_mult_q31() for a slower implementation of this function which uses 64-bit accumulation to provide higher precision. */ arm_status arm_mat_mult_fast_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst) { q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ q31_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ q31_t *pInA2; q31_t *px; /* Temporary output data matrix pointer */ q31_t *px2; q31_t sum1, sum2, sum3, sum4; /* Accumulator */ q31_t inA1, inA2, inB1, inB2; uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* Loop counters */ arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { px = pDst->pData; row = row >> 1U; px2 = px + numColsB; /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ while (row > 0U) { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ pInB = pSrcB->pData; j = 0U; col = col >> 1U; /* column loop */ while (col > 0U) { /* Set the variable sum, that acts as accumulator, to zero */ sum1 = 0; sum2 = 0; sum3 = 0; sum4 = 0; /* Initiate data pointers */ pInA = pSrcA->pData + i; pInB = pSrcB->pData + j; pInA2 = pInA + numColsA; colCnt = numColsA; /* matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ inA1 = *pInA++; inB1 = pInB[0]; inA2 = *pInA2++; inB2 = pInB[1]; pInB += numColsB; #if defined (ARM_MATH_DSP) sum1 = __SMMLA(inA1, inB1, sum1); sum2 = __SMMLA(inA1, inB2, sum2); sum3 = __SMMLA(inA2, inB1, sum3); sum4 = __SMMLA(inA2, inB2, sum4); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA1 * inB1)) >> 32); sum2 = (q31_t) ((((q63_t) sum2 << 32) + ((q63_t) inA1 * inB2)) >> 32); sum3 = (q31_t) ((((q63_t) sum3 << 32) + ((q63_t) inA2 * inB1)) >> 32); sum4 = (q31_t) ((((q63_t) sum4 << 32) + ((q63_t) inA2 * inB2)) >> 32); #endif /* Decrement loop counter */ colCnt--; } /* Convert the result from 2.30 to 1.31 format and store in destination buffer */ *px++ = sum1 << 1; *px++ = sum2 << 1; *px2++ = sum3 << 1; *px2++ = sum4 << 1; j += 2; /* Decrement column loop counter */ col--; } i = i + (numColsA << 1U); px = px2 + (numColsB & 1U); px2 = px + numColsB; /* Decrement row loop counter */ row--; } /* Compute any remaining odd row/column below */ /* Compute remaining output column */ if (numColsB & 1U) { /* Avoid redundant computation of last element */ row = numRowsA & (~1U); /* Point to remaining unfilled column in output matrix */ px = pDst->pData + numColsB-1; pInA = pSrcA->pData; /* row loop */ while (row > 0) { /* point to last column in matrix B */ pInB = pSrcB->pData + numColsB-1; /* Set variable sum1, that acts as accumulator, to zero */ sum1 = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 columns at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { #if defined (ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); #endif pInB += numColsB; #if defined (ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); #endif pInB += numColsB; #if defined (ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); #endif pInB += numColsB; #if defined (ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); #endif pInB += numColsB; /* Decrement loop counter */ colCnt--; } /* Loop unrolling: Compute remaining column */ colCnt = numColsA % 4U; #else /* Initialize colCnt with number of columns */ colCnt = numColsA; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { #if defined (ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); #endif pInB += numColsB; colCnt--; } /* Convert the result from 2.30 to 1.31 format and store in destination buffer */ *px = sum1 << 1; px += numColsB; /* Decrement row loop counter */ row--; } } /* Compute remaining output row */ if (numRowsA & 1U) { /* point to last row in output matrix */ px = pDst->pData + (numColsB) * (numRowsA-1); col = numColsB; i = 0U; /* col loop */ while (col > 0) { /* point to last row in matrix A */ pInA = pSrcA->pData + (numRowsA-1) * numColsA; pInB = pSrcB->pData + i; /* Set variable sum1, that acts as accumulator, to zero */ sum1 = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 columns at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { inA1 = *pInA++; inA2 = *pInA++; inB1 = *pInB; pInB += numColsB; inB2 = *pInB; pInB += numColsB; #if defined (ARM_MATH_DSP) sum1 = __SMMLA(inA1, inB1, sum1); sum1 = __SMMLA(inA2, inB2, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA1 * inB1)) >> 32); sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA2 * inB2)) >> 32); #endif inA1 = *pInA++; inA2 = *pInA++; inB1 = *pInB; pInB += numColsB; inB2 = *pInB; pInB += numColsB; #if defined (ARM_MATH_DSP) sum1 = __SMMLA(inA1, inB1, sum1); sum1 = __SMMLA(inA2, inB2, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA1 * inB1)) >> 32); sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA2 * inB2)) >> 32); #endif /* Decrement loop counter */ colCnt--; } /* Loop unrolling: Compute remaining column */ colCnt = numColsA % 4U; #else /* Initialize colCnt with number of columns */ colCnt = numColsA; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { #if defined (ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); #endif pInB += numColsB; colCnt--; } /* Saturate and store the result in the destination buffer */ *px++ = sum1 << 1; i++; /* Decrement col loop counter */ col--; } } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixMult group */
11,190
C
28.842667
108
0.524754
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_scale_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_scale_q31.c * Description: Multiplies a Q31 matrix by a scalar * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixScale @{ */ /** @brief Q31 matrix scaling. @param[in] pSrc points to input matrix @param[in] scaleFract fractional portion of the scale factor @param[in] shift number of bits to shift the result by @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The input data <code>*pSrc</code> and <code>scaleFract</code> are in 1.31 format. These are multiplied to yield a 2.62 intermediate result which is shifted with saturation to 1.31 format. */ arm_status arm_mat_scale_q31( const arm_matrix_instance_q31 * pSrc, q31_t scaleFract, int32_t shift, arm_matrix_instance_q31 * pDst) { q31_t *pIn = pSrc->pData; /* Input data matrix pointer */ q31_t *pOut = pDst->pData; /* Output data matrix pointer */ uint32_t numSamples; /* Total number of elements in the matrix */ uint32_t blkCnt; /* Loop counter */ arm_status status; /* Status of matrix scaling */ int32_t kShift = shift + 1; /* Shift to apply after scaling */ q31_t in, out; /* Temporary variabels */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ /* Scale, saturate and store result in destination buffer. */ in = *pIn++; /* read four inputs from source */ in = ((q63_t) in * scaleFract) >> 32; /* multiply input with scaler value */ out = in << kShift; /* apply shifting */ if (in != (out >> kShift)) /* saturate the results. */ out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; /* Store result destination */ in = *pIn++; in = ((q63_t) in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; in = *pIn++; in = ((q63_t) in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; in = *pIn++; in = ((q63_t) in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = numSamples % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = numSamples; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ /* Scale, saturate and store result in destination buffer. */ in = *pIn++; in = ((q63_t) in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; /* Decrement loop counter */ blkCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixScale group */
5,135
C
30.127273
124
0.533009
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_trans_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_trans_q15.c * Description: Q15 matrix transpose * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixTrans @{ */ /** @brief Q15 matrix transpose. @param[in] pSrc points to input matrix @param[out] pDst points to output matrix @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ arm_status arm_mat_trans_q15( const arm_matrix_instance_q15 * pSrc, arm_matrix_instance_q15 * pDst) { q15_t *pIn = pSrc->pData; /* input data matrix pointer */ q15_t *pOut = pDst->pData; /* output data matrix pointer */ uint16_t nRows = pSrc->numRows; /* number of rows */ uint16_t nCols = pSrc->numCols; /* number of columns */ uint32_t col, row = nRows, i = 0U; /* Loop counters */ arm_status status; /* status of matrix transpose */ #if defined (ARM_MATH_LOOPUNROLL) q31_t in; /* variable to hold temporary output */ #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose by exchanging the rows with columns */ /* row loop */ do { /* Pointer pOut is set to starting address of column being processed */ pOut = pDst->pData + i; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ col = nCols >> 2U; while (col > 0U) /* column loop */ { /* Read two elements from row */ in = read_q15x2_ia ((q15_t **) &pIn); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN *pOut = (q15_t) in; #else *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ pOut += nRows; /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #else *pOut = (q15_t) in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ pOut += nRows; /* Read two elements from row */ in = read_q15x2_ia ((q15_t **) &pIn); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN *pOut = (q15_t) in; #else *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ pOut += nRows; /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #else *pOut = (q15_t) in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ pOut += nRows; /* Decrement column loop counter */ col--; } /* Loop unrolling: Compute remaining outputs */ col = nCols % 0x4U; #else /* Initialize col with number of samples */ col = nCols; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (col > 0U) { /* Read and store input element in destination */ *pOut = *pIn++; /* Update pointer pOut to point to next row of transposed matrix */ pOut += nRows; /* Decrement column loop counter */ col--; } i++; /* Decrement row loop counter */ row--; } while (row > 0U); /* row loop end */ /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixTrans group */
5,192
C
27.377049
95
0.559129
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_mult_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_mult_q31.c * Description: Q31 matrix multiplication * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixMult @{ */ /** @brief Q31 matrix multiplication. @param[in] pSrcA points to the first input matrix structure @param[in] pSrcB points to the second input matrix structure @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. There is no saturation on intermediate additions. Thus, if the accumulator overflows it wraps around and distorts the result. The input signals should be scaled down to avoid intermediate overflows. The input is thus scaled down by log2(numColsA) bits to avoid overflows, as a total of numColsA additions are performed internally. The 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. @remark Refer to \ref arm_mat_mult_fast_q31() for a faster but less precise implementation of this function. */ arm_status arm_mat_mult_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst) { q31_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ q31_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ q31_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ q31_t *pOut = pDst->pData; /* Output data matrix pointer */ q31_t *px; /* Temporary output data matrix pointer */ q63_t sum; /* Accumulator */ uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ do { /* Output pointer is set to starting address of row being processed */ px = pOut + i; /* For every row wise process, column loop counter is to be initiated */ col = numColsB; /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ pIn2 = pSrcB->pData; /* column loop */ do { /* Set the variable sum, that acts as accumulator, to zero */ sum = 0; /* Initialize pointer pIn1 to point to starting address of column being processed */ pIn1 = pInA; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 MACs at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ /* Perform the multiply-accumulates */ sum += (q63_t) *pIn1++ * *pIn2; pIn2 += numColsB; sum += (q63_t) *pIn1++ * *pIn2; pIn2 += numColsB; sum += (q63_t) *pIn1++ * *pIn2; pIn2 += numColsB; sum += (q63_t) *pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ colCnt--; } /* Loop unrolling: Compute remaining MACs */ colCnt = numColsA % 0x4U; #else /* Initialize cntCnt with number of columns */ colCnt = numColsA; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ /* Perform the multiply-accumulates */ sum += (q63_t) *pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ colCnt--; } /* Convert result from 2.62 to 1.31 format and store in destination buffer */ *px++ = (q31_t) (sum >> 31); /* Decrement column loop counter */ col--; /* Update pointer pIn2 to point to starting address of next column */ pIn2 = pInB + (numColsB - col); } while (col > 0U); /* Update pointer pInA to point to starting address of next row */ i = i + numColsB; pInA = pInA + numColsA; /* Decrement row loop counter */ row--; } while (row > 0U); /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixMult group */
6,678
C
32.903553
123
0.565439
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_scale_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_scale_q15.c * Description: Multiplies a Q15 matrix by a scalar * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixScale @{ */ /** @brief Q15 matrix scaling. @param[in] pSrc points to input matrix @param[in] scaleFract fractional portion of the scale factor @param[in] shift number of bits to shift the result by @param[out] pDst points to output matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The input data <code>*pSrc</code> and <code>scaleFract</code> are in 1.15 format. These are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format. */ arm_status arm_mat_scale_q15( const arm_matrix_instance_q15 * pSrc, q15_t scaleFract, int32_t shift, arm_matrix_instance_q15 * pDst) { q15_t *pIn = pSrc->pData; /* Input data matrix pointer */ q15_t *pOut = pDst->pData; /* Output data matrix pointer */ uint32_t numSamples; /* Total number of elements in the matrix */ uint32_t blkCnt; /* Loop counter */ arm_status status; /* Status of matrix scaling */ int32_t kShift = 15 - shift; /* Total shift to apply after scaling */ #if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) q31_t inA1, inA2; q31_t out1, out2, out3, out4; /* Temporary output variables */ q15_t in1, in2, in3, in4; /* Temporary input variables */ #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ #if defined (ARM_MATH_DSP) /* read 2 times 2 samples at a time from source */ inA1 = read_q15x2_ia ((q15_t **) &pIn); inA2 = read_q15x2_ia ((q15_t **) &pIn); /* Scale inputs and store result in temporary variables * in single cycle by packing the outputs */ out1 = (q31_t) ((q15_t) (inA1 >> 16) * scaleFract); out2 = (q31_t) ((q15_t) (inA1 ) * scaleFract); out3 = (q31_t) ((q15_t) (inA2 >> 16) * scaleFract); out4 = (q31_t) ((q15_t) (inA2 ) * scaleFract); /* apply shifting */ out1 = out1 >> kShift; out2 = out2 >> kShift; out3 = out3 >> kShift; out4 = out4 >> kShift; /* saturate the output */ in1 = (q15_t) (__SSAT(out1, 16)); in2 = (q15_t) (__SSAT(out2, 16)); in3 = (q15_t) (__SSAT(out3, 16)); in4 = (q15_t) (__SSAT(out4, 16)); /* store result to destination */ write_q15x2_ia (&pOut, __PKHBT(in2, in1, 16)); write_q15x2_ia (&pOut, __PKHBT(in4, in3, 16)); #else *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); #endif /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = numSamples % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = numSamples; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ /* Scale, saturate and store result in destination buffer. */ *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); /* Decrement loop counter */ blkCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixScale group */
5,552
C
31.473684
127
0.550793
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_cmplx_mult_q31.c * Description: Floating-point matrix multiplication * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup CmplxMatrixMult @{ */ /** @brief Q31 Complex matrix multiplication. @param[in] pSrcA points to first input complex matrix structure @param[in] pSrcB points to second input complex matrix structure @param[out] pDst points to output complex matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. There is no saturation on intermediate additions. Thus, if the accumulator overflows it wraps around and distorts the result. The input signals should be scaled down to avoid intermediate overflows. The input is thus scaled down by log2(numColsA) bits to avoid overflows, as a total of numColsA additions are performed internally. The 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. */ arm_status arm_mat_cmplx_mult_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst) { q31_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ q31_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ q31_t *pOut = pDst->pData; /* Output data matrix pointer */ q31_t *px; /* Temporary output data matrix pointer */ uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ q63_t sumReal, sumImag; /* Accumulator */ q31_t a1, b1, c1, d1; uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* loop counters */ arm_status status; /* status of matrix multiplication */ #if defined (ARM_MATH_LOOPUNROLL) q31_t a0, b0, c0, d0; #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ do { /* Output pointer is set to starting address of the row being processed */ px = pOut + 2 * i; /* For every row wise process, the column loop counter is to be initiated */ col = numColsB; /* For every row wise process, the pIn2 pointer is set ** to the starting address of the pSrcB data */ pIn2 = pSrcB->pData; j = 0U; /* column loop */ do { /* Set the variable sum, that acts as accumulator, to zero */ sumReal = 0.0; sumImag = 0.0; /* Initiate pointer pIn1 to point to starting address of column being processed */ pIn1 = pInA; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 MACs simultaneously. */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { /* Reading real part of complex matrix A */ a0 = *pIn1; /* Reading real part of complex matrix B */ c0 = *pIn2; /* Reading imaginary part of complex matrix A */ b0 = *(pIn1 + 1U); /* Reading imaginary part of complex matrix B */ d0 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += (q63_t) a0 * c0; sumImag += (q63_t) b0 * c0; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= (q63_t) b0 * d0; sumImag += (q63_t) a0 * d0; /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ /* read real and imag values from pSrcA and pSrcB buffer */ a1 = *(pIn1 ); c1 = *(pIn2 ); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += (q63_t) a1 * c1; sumImag += (q63_t) b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= (q63_t) b1 * d1; sumImag += (q63_t) a1 * d1; a0 = *(pIn1 ); c0 = *(pIn2 ); b0 = *(pIn1 + 1U); d0 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += (q63_t) a0 * c0; sumImag += (q63_t) b0 * c0; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= (q63_t) b0 * d0; sumImag += (q63_t) a0 * d0; /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ a1 = *(pIn1 ); c1 = *(pIn2 ); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += (q63_t) a1 * c1; sumImag += (q63_t) b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= (q63_t) b1 * d1; sumImag += (q63_t) a1 * d1; /* Decrement loop count */ colCnt--; } /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ colCnt = numColsA % 0x4U; #else /* Initialize blkCnt with number of samples */ colCnt = numColsA; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ a1 = *(pIn1 ); c1 = *(pIn2 ); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += (q63_t) a1 * c1; sumImag += (q63_t) b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= (q63_t) b1 * d1; sumImag += (q63_t) a1 * d1; /* Decrement loop counter */ colCnt--; } /* Store result in destination buffer */ *px++ = (q31_t) clip_q63_to_q31(sumReal >> 31); *px++ = (q31_t) clip_q63_to_q31(sumImag >> 31); /* Update pointer pIn2 to point to starting address of next column */ j++; pIn2 = pSrcB->pData + 2U * j; /* Decrement column loop counter */ col--; } while (col > 0U); /* Update pointer pInA to point to starting address of next row */ i = i + numColsB; pInA = pInA + 2 * numColsA; /* Decrement row loop counter */ row--; } while (row > 0U); /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixMult group */
8,938
C
30.475352
123
0.525285
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_mult_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_mult_f32.c * Description: Floating-point matrix multiplication * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** * @ingroup groupMatrix */ /** * @defgroup MatrixMult Matrix Multiplication * * Multiplies two matrices. * * \image html MatrixMultiplication.gif "Multiplication of two 3 x 3 matrices" * Matrix multiplication is only defined if the number of columns of the * first matrix equals the number of rows of the second matrix. * Multiplying an <code>M x N</code> matrix with an <code>N x P</code> matrix results * in an <code>M x P</code> matrix. * When matrix size checking is enabled, the functions check: (1) that the inner dimensions of * <code>pSrcA</code> and <code>pSrcB</code> are equal; and (2) that the size of the output * matrix equals the outer dimensions of <code>pSrcA</code> and <code>pSrcB</code>. */ /** * @addtogroup MatrixMult * @{ */ /** * @brief Floating-point matrix multiplication. * @param[in] *pSrcA points to the first input matrix structure * @param[in] *pSrcB points to the second input matrix structure * @param[out] *pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ #if defined(ARM_MATH_NEON) #define GROUPOFROWS 8 arm_status arm_mat_mult_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst) { float32_t *pIn1 = pSrcA->pData; /* input data matrix pointer A */ float32_t *pIn2 = pSrcB->pData; /* input data matrix pointer B */ float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ float32_t *px; /* Temporary output data matrix pointer */ float32_t sum; /* Accumulator */ uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */ float32_t in1, in2, in3, in4; uint16_t col, i = 0U, j, row = numRowsA, rowCnt, colCnt; /* loop counters */ arm_status status; /* status of matrix multiplication */ float32x4_t a0V, a1V, a2V, a3V, a4V, a5V, a6V, a7V; float32x4_t acc0,acc1,acc2,acc3,acc4,acc5,acc6,acc7,temp; float32x2_t accum = vdup_n_f32(0); float32_t *pIn1B = pSrcA->pData; float32_t *pIn1C = pSrcA->pData; float32_t *pIn1D = pSrcA->pData; float32_t *pIn1E = pSrcA->pData; float32_t *pIn1F = pSrcA->pData; float32_t *pIn1G = pSrcA->pData; float32_t *pIn1H = pSrcA->pData; float32_t *pxB,*pxC, *pxD, *pxE, *pxF, *pxG, *pxH; /* Temporary output data matrix pointer */ float32_t sum0,sum1, sum2,sum3, sum4, sum5 , sum6, sum7; #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* Row loop */ rowCnt = row >> 3; while(rowCnt > 0) { /* Output pointer is set to starting address of the row being processed */ px = pOut + GROUPOFROWS*i; pxB = px + numColsB; pxC = px + 2*numColsB; pxD = px + 3*numColsB; pxE = px + 4*numColsB; pxF = px + 5*numColsB; pxG = px + 6*numColsB; pxH = px + 7*numColsB; /* For every row wise process, the column loop counter is to be initiated */ col = numColsB; /* For every row wise process, the pIn2 pointer is set ** to the starting address of the pSrcB data */ pIn2 = pSrcB->pData; j = 0U; /* Column loop */ do { /* Set the variable sum, that acts as accumulator, to zero */ sum0 = 0.0f; sum1 = 0.0f; sum2 = 0.0f; sum3 = 0.0f; sum4 = 0.0f; sum5 = 0.0f; sum6 = 0.0f; sum7 = 0.0f; /* Initiate the pointer pIn1 to point to the starting address of the column being processed */ pIn1 = pInA; pIn1B = pIn1 + numColsA; pIn1C = pIn1 + 2*numColsA; pIn1D = pIn1 + 3*numColsA; pIn1E = pIn1 + 4*numColsA; pIn1F = pIn1 + 5*numColsA; pIn1G = pIn1 + 6*numColsA; pIn1H = pIn1 + 7*numColsA; acc0 = vdupq_n_f32(0.0); acc1 = vdupq_n_f32(0.0); acc2 = vdupq_n_f32(0.0); acc3 = vdupq_n_f32(0.0); acc4 = vdupq_n_f32(0.0); acc5 = vdupq_n_f32(0.0); acc6 = vdupq_n_f32(0.0); acc7 = vdupq_n_f32(0.0); /* Compute 4 MACs simultaneously. */ colCnt = numColsA >> 2U; /* Matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1)*b(1,1) + a(1,2)*b(2,1) + ... + a(m,p)*b(p,n) */ a0V = vld1q_f32(pIn1); a1V = vld1q_f32(pIn1B); a2V = vld1q_f32(pIn1C); a3V = vld1q_f32(pIn1D); a4V = vld1q_f32(pIn1E); a5V = vld1q_f32(pIn1F); a6V = vld1q_f32(pIn1G); a7V = vld1q_f32(pIn1H); pIn1 += 4; pIn1B += 4; pIn1C += 4; pIn1D += 4; pIn1E += 4; pIn1F += 4; pIn1G += 4; pIn1H += 4; temp[0] = *pIn2; pIn2 += numColsB; temp[1] = *pIn2; pIn2 += numColsB; temp[2] = *pIn2; pIn2 += numColsB; temp[3] = *pIn2; pIn2 += numColsB; acc0 = vmlaq_f32(acc0,a0V,temp); acc1 = vmlaq_f32(acc1,a1V,temp); acc2 = vmlaq_f32(acc2,a2V,temp); acc3 = vmlaq_f32(acc3,a3V,temp); acc4 = vmlaq_f32(acc4,a4V,temp); acc5 = vmlaq_f32(acc5,a5V,temp); acc6 = vmlaq_f32(acc6,a6V,temp); acc7 = vmlaq_f32(acc7,a7V,temp); /* Decrement the loop count */ colCnt--; } accum = vpadd_f32(vget_low_f32(acc0), vget_high_f32(acc0)); sum0 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc1), vget_high_f32(acc1)); sum1 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc2), vget_high_f32(acc2)); sum2 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc3), vget_high_f32(acc3)); sum3 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc4), vget_high_f32(acc4)); sum4 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc5), vget_high_f32(acc5)); sum5 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc6), vget_high_f32(acc6)); sum6 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(acc7), vget_high_f32(acc7)); sum7 += accum[0] + accum[1]; /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ colCnt = numColsA & 3; while (colCnt > 0U) { /* c(m,n) = a(1,1)*b(1,1) + a(1,2)*b(2,1) + ... + a(m,p)*b(p,n) */ sum0 += *pIn1++ * (*pIn2); sum1 += *pIn1B++ * (*pIn2); sum2 += *pIn1C++ * (*pIn2); sum3 += *pIn1D++ * (*pIn2); sum4 += *pIn1E++ * (*pIn2); sum5 += *pIn1F++ * (*pIn2); sum6 += *pIn1G++ * (*pIn2); sum7 += *pIn1H++ * (*pIn2); pIn2 += numColsB; /* Decrement the loop counter */ colCnt--; } /* Store the result in the destination buffer */ *px++ = sum0; *pxB++ = sum1; *pxC++ = sum2; *pxD++ = sum3; *pxE++ = sum4; *pxF++ = sum5; *pxG++ = sum6; *pxH++ = sum7; /* Update the pointer pIn2 to point to the starting address of the next column */ j++; pIn2 = pSrcB->pData + j; /* Decrement the column loop counter */ col--; } while (col > 0U); /* Update the pointer pInA to point to the starting address of the next row */ i = i + numColsB; pInA = pInA + GROUPOFROWS*numColsA; /* Decrement the row loop counter */ rowCnt--; } /* i was the index of a group of rows computed by previous loop. Now i is the index of a row since below code is computing row per row and no more group of row per group of rows. */ i = GROUPOFROWS*i; rowCnt = row & 7; while(rowCnt > 0) { /* Output pointer is set to starting address of the row being processed */ px = pOut + i; /* For every row wise process, the column loop counter is to be initiated */ col = numColsB; /* For every row wise process, the pIn2 pointer is set ** to the starting address of the pSrcB data */ pIn2 = pSrcB->pData; j = 0U; /* Column loop */ do { /* Set the variable sum, that acts as accumulator, to zero */ sum = 0.0f; /* Initiate the pointer pIn1 to point to the starting address of the column being processed */ pIn1 = pInA; acc0 = vdupq_n_f32(0.0); /* Compute 4 MACs simultaneously. */ colCnt = numColsA >> 2U; /* Matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1)*b(1,1) + a(1,2)*b(2,1) + ... + a(m,p)*b(p,n) */ a0V = vld1q_f32(pIn1); // load & separate real/imag pSrcA (de-interleave 2) pIn1 += 4; temp[0] = *pIn2; pIn2 += numColsB; temp[1] = *pIn2; pIn2 += numColsB; temp[2] = *pIn2; pIn2 += numColsB; temp[3] = *pIn2; pIn2 += numColsB; acc0 = vmlaq_f32(acc0,a0V,temp); /* Decrement the loop count */ colCnt--; } accum = vpadd_f32(vget_low_f32(acc0), vget_high_f32(acc0)); sum += accum[0] + accum[1]; /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ colCnt = numColsA % 0x4U; while (colCnt > 0U) { /* c(m,n) = a(1,1)*b(1,1) + a(1,2)*b(2,1) + ... + a(m,p)*b(p,n) */ sum += *pIn1++ * (*pIn2); pIn2 += numColsB; /* Decrement the loop counter */ colCnt--; } /* Store the result in the destination buffer */ *px++ = sum; /* Update the pointer pIn2 to point to the starting address of the next column */ j++; pIn2 = pSrcB->pData + j; /* Decrement the column loop counter */ col--; } while (col > 0U); /* Update the pointer pInA to point to the starting address of the next row */ i = i + numColsB; pInA = pInA + numColsA; /* Decrement the row loop counter */ rowCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #else arm_status arm_mat_mult_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst) { float32_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ float32_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ float32_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ float32_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ float32_t *pOut = pDst->pData; /* Output data matrix pointer */ float32_t *px; /* Temporary output data matrix pointer */ float32_t sum; /* Accumulator */ uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ do { /* Output pointer is set to starting address of row being processed */ px = pOut + i; /* For every row wise process, column loop counter is to be initiated */ col = numColsB; /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ pIn2 = pSrcB->pData; /* column loop */ do { /* Set the variable sum, that acts as accumulator, to zero */ sum = 0.0f; /* Initialize pointer pIn1 to point to starting address of column being processed */ pIn1 = pInA; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 MACs at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ /* Perform the multiply-accumulates */ sum += *pIn1++ * *pIn2; pIn2 += numColsB; sum += *pIn1++ * *pIn2; pIn2 += numColsB; sum += *pIn1++ * *pIn2; pIn2 += numColsB; sum += *pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ colCnt--; } /* Loop unrolling: Compute remaining MACs */ colCnt = numColsA % 0x4U; #else /* Initialize cntCnt with number of columns */ colCnt = numColsA; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ /* Perform the multiply-accumulates */ sum += *pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ colCnt--; } /* Store result in destination buffer */ *px++ = sum; /* Decrement column loop counter */ col--; /* Update pointer pIn2 to point to starting address of next column */ pIn2 = pInB + (numColsB - col); } while (col > 0U); /* Update pointer pInA to point to starting address of next row */ i = i + numColsB; pInA = pInA + numColsA; /* Decrement row loop counter */ row--; } while (row > 0U); /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #endif /* #if defined(ARM_MATH_NEON) */ /** * @} end of MatrixMult group */
16,480
C
29.805607
127
0.538653
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/MatrixFunctions.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: MatrixFunctions.c * Description: Combination of all matrix function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_mat_add_f32.c" #include "arm_mat_add_q15.c" #include "arm_mat_add_q31.c" #include "arm_mat_cmplx_mult_f32.c" #include "arm_mat_cmplx_mult_q15.c" #include "arm_mat_cmplx_mult_q31.c" #include "arm_mat_init_f32.c" #include "arm_mat_init_q15.c" #include "arm_mat_init_q31.c" #include "arm_mat_inverse_f32.c" #include "arm_mat_inverse_f64.c" #include "arm_mat_mult_f32.c" #include "arm_mat_mult_fast_q15.c" #include "arm_mat_mult_fast_q31.c" #include "arm_mat_mult_q15.c" #include "arm_mat_mult_q31.c" #include "arm_mat_scale_f32.c" #include "arm_mat_scale_q15.c" #include "arm_mat_scale_q31.c" #include "arm_mat_sub_f32.c" #include "arm_mat_sub_q15.c" #include "arm_mat_sub_q31.c" #include "arm_mat_trans_f32.c" #include "arm_mat_trans_q15.c" #include "arm_mat_trans_q31.c"
1,834
C
32.981481
74
0.654308
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_mult_fast_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_mult_fast_q15.c * Description: Q15 matrix multiplication (fast variant) * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @addtogroup MatrixMult @{ */ /** @brief Q15 matrix multiplication (fast variant). @param[in] pSrcA points to the first input matrix structure @param[in] pSrcB points to the second input matrix structure @param[out] pDst points to output matrix structure @param[in] pState points to the array for storing intermediate results @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior The difference between the function \ref arm_mat_mult_q15() and this fast variant is that the fast variant use a 32-bit rather than a 64-bit accumulator. The result of each 1.15 x 1.15 multiplication is truncated to 2.30 format. These intermediate results are accumulated in a 32-bit register in 2.30 format. Finally, the accumulator is saturated and converted to a 1.15 result. @par The fast version has the same overflow behavior as the standard version but provides less precision since it discards the low 16 bits of each multiplication result. In order to avoid overflows completely the input signals must be scaled down. Scale down one of the input matrices by log2(numColsA) bits to avoid overflows, as a total of numColsA additions are computed internally for each output element. @remark Refer to \ref arm_mat_mult_q15() for a slower implementation of this function which uses 64-bit accumulation to provide higher precision. */ arm_status arm_mat_mult_fast_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst, q15_t * pState) { q31_t sum; /* Accumulator */ q15_t *pSrcBT = pState; /* Input data matrix pointer for transpose */ q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ q15_t *px; /* Temporary output data matrix pointer */ uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ uint16_t numRowsB = pSrcB->numRows; /* Number of rows of input matrix A */ uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ arm_status status; /* Status of matrix multiplication */ #if defined (ARM_MATH_DSP) q31_t in; /* Temporary variable to hold the input value */ q31_t inA1, inB1, inA2, inB2; q31_t sum2, sum3, sum4; q15_t *pInA2, *pInB2, *px2; uint32_t j = 0; #else q15_t in; /* Temporary variable to hold the input value */ q15_t inA1, inB1, inA2, inB2; #endif /* #if defined (ARM_MATH_DSP) */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose */ do { /* The pointer px is set to starting address of column being processed */ px = pSrcBT + i; /* Apply loop unrolling and exchange columns with row elements */ col = numColsB >> 2U; /* First part of the processing with loop unrolling. Compute 4 outputs at a time. ** a second loop below computes the remaining 1 to 3 samples. */ while (col > 0U) { #if defined (ARM_MATH_DSP) /* Read two elements from row */ in = read_q15x2_ia ((q15_t **) &pInB); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN *px = (q15_t) in; #else *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer px to point to next row of transposed matrix */ px += numRowsB; /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #else *px = (q15_t) in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer px to point to next row of transposed matrix */ px += numRowsB; in = read_q15x2_ia ((q15_t **) &pInB); #ifndef ARM_MATH_BIG_ENDIAN *px = (q15_t) in; #else *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ px += numRowsB; #ifndef ARM_MATH_BIG_ENDIAN *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); #else *px = (q15_t) in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ px += numRowsB; #else /* #if defined (ARM_MATH_DSP) */ /* Read one element from row */ in = *pInB++; /* Store one element in destination */ *px = in; /* Update pointer px to point to next row of transposed matrix */ px += numRowsB; in = *pInB++; *px = in; px += numRowsB; in = *pInB++; *px = in; px += numRowsB; in = *pInB++; *px = in; px += numRowsB; #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement column loop counter */ col--; } /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ col = numColsB % 0x4U; while (col > 0U) { /* Read and store input element in destination */ *px = *pInB++; /* Update pointer px to point to next row of transposed matrix */ px += numRowsB; /* Decrement column loop counter */ col--; } i++; /* Decrement row loop counter */ row--; } while (row > 0U); /* Reset variables for usage in following multiplication process */ row = numRowsA; i = 0U; px = pDst->pData; #if defined (ARM_MATH_DSP) /* Process two rows from matrix A at a time and output two rows at a time */ row = row >> 1U; px2 = px + numColsB; #endif /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ while (row > 0U) { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; /* For every row wise process, pIn2 pointer is set to starting address of transposed pSrcB data */ pInB = pSrcBT; #if defined (ARM_MATH_DSP) /* Process two (transposed) columns from matrix B at a time */ col = col >> 1U; j = 0; #endif /* column loop */ while (col > 0U) { /* Set variable sum, that acts as accumulator, to zero */ sum = 0; /* Initiate pointer pInA to point to starting address of column being processed */ pInA = pSrcA->pData + i; #if defined (ARM_MATH_DSP) sum2 = 0; sum3 = 0; sum4 = 0; pInB = pSrcBT + j; pInA2 = pInA + numColsA; pInB2 = pInB + numRowsB; /* Read in two elements at once - alows dual MAC instruction */ colCnt = numColsA >> 1U; #else colCnt = numColsA >> 2U; #endif /* matrix multiplication */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ #if defined (ARM_MATH_DSP) /* read real and imag values from pSrcA and pSrcB buffer */ inA1 = read_q15x2_ia ((q15_t **) &pInA); inB1 = read_q15x2_ia ((q15_t **) &pInB); inA2 = read_q15x2_ia ((q15_t **) &pInA2); inB2 = read_q15x2_ia ((q15_t **) &pInB2); /* Multiply and Accumlates */ sum = __SMLAD(inA1, inB1, sum); sum2 = __SMLAD(inA1, inB2, sum2); sum3 = __SMLAD(inA2, inB1, sum3); sum4 = __SMLAD(inA2, inB2, sum4); #else /* read real and imag values from pSrcA and pSrcB buffer */ inA1 = *pInA++; inB1 = *pInB++; /* Multiply and Accumlates */ sum += inA1 * inB1; inA2 = *pInA++; inB2 = *pInB++; sum += inA2 * inB2; inA1 = *pInA++; inB1 = *pInB++; sum += inA1 * inB1; inA2 = *pInA++; inB2 = *pInB++; sum += inA2 * inB2; #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ colCnt--; } /* process odd column samples */ #if defined (ARM_MATH_DSP) if (numColsA & 1U) { inA1 = *pInA++; inB1 = *pInB++; inA2 = *pInA2++; inB2 = *pInB2++; sum += inA1 * inB1; sum2 += inA1 * inB2; sum3 += inA2 * inB1; sum4 += inA2 * inB2; } #else colCnt = numColsA % 0x4U; while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ sum += (q31_t) *pInA++ * *pInB++; /* Decrement loop counter */ colCnt--; } #endif /* #if defined (ARM_MATH_DSP) */ /* Saturate and store result in destination buffer */ *px++ = (q15_t) (sum >> 15); #if defined (ARM_MATH_DSP) *px++ = (q15_t) (sum2 >> 15); *px2++ = (q15_t) (sum3 >> 15); *px2++ = (q15_t) (sum4 >> 15); j += numRowsB * 2; #endif /* Decrement column loop counter */ col--; } i = i + numColsA; #if defined (ARM_MATH_DSP) i = i + numColsA; px = px2 + (numColsB & 1U); px2 = px + numColsB; #endif /* Decrement row loop counter */ row--; } /* Compute any remaining odd row/column below */ #if defined (ARM_MATH_DSP) /* Compute remaining output column */ if (numColsB & 1U) { /* Avoid redundant computation of last element */ row = numRowsA & (~0x1); /* Point to remaining unfilled column in output matrix */ px = pDst->pData + numColsB-1; pInA = pSrcA->pData; /* row loop */ while (row > 0) { /* point to last column in matrix B */ pInB = pSrcBT + numRowsB * (numColsB-1); /* Set variable sum, that acts as accumulator, to zero */ sum = 0; /* Compute 4 columns at once */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { inA1 = read_q15x2_ia ((q15_t **) &pInA); inA2 = read_q15x2_ia ((q15_t **) &pInA); inB1 = read_q15x2_ia ((q15_t **) &pInB); inB2 = read_q15x2_ia ((q15_t **) &pInB); sum = __SMLAD(inA1, inB1, sum); sum = __SMLAD(inA2, inB2, sum); /* Decrement loop counter */ colCnt--; } colCnt = numColsA & 3U; while (colCnt > 0U) { sum += (q31_t) (*pInA++) * (*pInB++); colCnt--; } /* Store result in destination buffer */ *px = (q15_t) (sum >> 15); px += numColsB; /* Decrement row loop counter */ row--; } } /* Compute remaining output row */ if (numRowsA & 1U) { /* point to last row in output matrix */ px = pDst->pData + (numColsB) * (numRowsA-1); pInB = pSrcBT; col = numColsB; i = 0U; /* col loop */ while (col > 0) { /* point to last row in matrix A */ pInA = pSrcA->pData + (numRowsA-1) * numColsA; /* Set variable sum, that acts as accumulator, to zero */ sum = 0; /* Compute 4 columns at once */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { inA1 = read_q15x2_ia ((q15_t **) &pInA); inA2 = read_q15x2_ia ((q15_t **) &pInA); inB1 = read_q15x2_ia ((q15_t **) &pInB); inB2 = read_q15x2_ia ((q15_t **) &pInB); sum = __SMLAD(inA1, inB1, sum); sum = __SMLAD(inA2, inB2, sum); /* Decrement loop counter */ colCnt--; } colCnt = numColsA % 4U; while (colCnt > 0U) { sum += (q31_t) (*pInA++) * (*pInB++); colCnt--; } /* Store result in destination buffer */ *px++ = (q15_t) (sum >> 15); /* Decrement column loop counter */ col--; } } #endif /* #if defined (ARM_MATH_DSP) */ /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of MatrixMult group */
14,400
C
28.754132
108
0.525208
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_mat_cmplx_mult_f32.c * Description: Floating-point matrix multiplication * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupMatrix */ /** @defgroup CmplxMatrixMult Complex Matrix Multiplication Complex Matrix multiplication is only defined if the number of columns of the first matrix equals the number of rows of the second matrix. Multiplying an <code>M x N</code> matrix with an <code>N x P</code> matrix results in an <code>M x P</code> matrix. @par When matrix size checking is enabled, the functions check: - that the inner dimensions of <code>pSrcA</code> and <code>pSrcB</code> are equal; - that the size of the output matrix equals the outer dimensions of <code>pSrcA</code> and <code>pSrcB</code>. */ /** @addtogroup CmplxMatrixMult @{ */ /** @brief Floating-point Complex matrix multiplication. @param[in] pSrcA points to first input complex matrix structure @param[in] pSrcB points to second input complex matrix structure @param[out] pDst points to output complex matrix structure @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ #if defined(ARM_MATH_NEON) arm_status arm_mat_cmplx_mult_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst) { float32_t *pIn1 = pSrcA->pData; /* input data matrix pointer A */ float32_t *pIn2 = pSrcB->pData; /* input data matrix pointer B */ float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ float32_t *pOut = pDst->pData; /* output data matrix pointer */ float32_t *px; /* Temporary output data matrix pointer */ uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */ float32_t sumReal1, sumImag1; /* accumulator */ float32_t a0, b0, c0, d0; float32_t a1, a1B,b1, b1B, c1, d1; float32_t sumReal2, sumImag2; /* accumulator */ float32x4x2_t a0V, a1V; float32x4_t accR0,accI0, accR1,accI1,tempR, tempI; float32x2_t accum = vdup_n_f32(0); float32_t *pIn1B = pSrcA->pData; uint16_t col, i = 0U, j, rowCnt, row = numRowsA, colCnt; /* loop counters */ arm_status status; /* status of matrix multiplication */ float32_t sumReal1B, sumImag1B; float32_t sumReal2B, sumImag2B; float32_t *pxB; #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ rowCnt = row >> 1; /* Row loop */ while (rowCnt > 0U) { /* Output pointer is set to starting address of the row being processed */ px = pOut + 2 * i; pxB = px + 2 * numColsB; /* For every row wise process, the column loop counter is to be initiated */ col = numColsB; /* For every row wise process, the pIn2 pointer is set ** to the starting address of the pSrcB data */ pIn2 = pSrcB->pData; j = 0U; /* Column loop */ while (col > 0U) { /* Set the variable sum, that acts as accumulator, to zero */ sumReal1 = 0.0f; sumImag1 = 0.0f; sumReal1B = 0.0f; sumImag1B = 0.0f; sumReal2 = 0.0f; sumImag2 = 0.0f; sumReal2B = 0.0f; sumImag2B = 0.0f; /* Initiate the pointer pIn1 to point to the starting address of the column being processed */ pIn1 = pInA; pIn1B = pIn1 + 2*numColsA; accR0 = vdupq_n_f32(0.0); accI0 = vdupq_n_f32(0.0); accR1 = vdupq_n_f32(0.0); accI1 = vdupq_n_f32(0.0); /* Compute 4 MACs simultaneously. */ colCnt = numColsA >> 2; /* Matrix multiplication */ while (colCnt > 0U) { /* Reading real part of complex matrix A */ a0V = vld2q_f32(pIn1); // load & separate real/imag pSrcA (de-interleave 2) a1V = vld2q_f32(pIn1B); // load & separate real/imag pSrcA (de-interleave 2) pIn1 += 8; pIn1B += 8; tempR[0] = *pIn2; tempI[0] = *(pIn2 + 1U); pIn2 += 2 * numColsB; tempR[1] = *pIn2; tempI[1] = *(pIn2 + 1U); pIn2 += 2 * numColsB; tempR[2] = *pIn2; tempI[2] = *(pIn2 + 1U); pIn2 += 2 * numColsB; tempR[3] = *pIn2; tempI[3] = *(pIn2 + 1U); pIn2 += 2 * numColsB; accR0 = vmlaq_f32(accR0,a0V.val[0],tempR); accR0 = vmlsq_f32(accR0,a0V.val[1],tempI); accI0 = vmlaq_f32(accI0,a0V.val[1],tempR); accI0 = vmlaq_f32(accI0,a0V.val[0],tempI); accR1 = vmlaq_f32(accR1,a1V.val[0],tempR); accR1 = vmlsq_f32(accR1,a1V.val[1],tempI); accI1 = vmlaq_f32(accI1,a1V.val[1],tempR); accI1 = vmlaq_f32(accI1,a1V.val[0],tempI); /* Decrement the loop count */ colCnt--; } accum = vpadd_f32(vget_low_f32(accR0), vget_high_f32(accR0)); sumReal1 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(accI0), vget_high_f32(accI0)); sumImag1 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(accR1), vget_high_f32(accR1)); sumReal1B += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(accI1), vget_high_f32(accI1)); sumImag1B += accum[0] + accum[1]; /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ colCnt = numColsA & 3; while (colCnt > 0U) { /* c(m,n) = a(1,1)*b(1,1) + a(1,2)*b(2,1) + ... + a(m,p)*b(p,n) */ a1 = *pIn1; a1B = *pIn1B; c1 = *pIn2; b1 = *(pIn1 + 1U); b1B = *(pIn1B + 1U); d1 = *(pIn2 + 1U); sumReal1 += a1 * c1; sumImag1 += b1 * c1; sumReal1B += a1B * c1; sumImag1B += b1B * c1; pIn1 += 2U; pIn1B += 2U; pIn2 += 2 * numColsB; sumReal2 -= b1 * d1; sumImag2 += a1 * d1; sumReal2B -= b1B * d1; sumImag2B += a1B * d1; /* Decrement the loop counter */ colCnt--; } sumReal1 += sumReal2; sumImag1 += sumImag2; sumReal1B += sumReal2B; sumImag1B += sumImag2B; /* Store the result in the destination buffer */ *px++ = sumReal1; *px++ = sumImag1; *pxB++ = sumReal1B; *pxB++ = sumImag1B; /* Update the pointer pIn2 to point to the starting address of the next column */ j++; pIn2 = pSrcB->pData + 2U * j; /* Decrement the column loop counter */ col--; } /* Update the pointer pInA to point to the starting address of the next 2 row */ i = i + 2*numColsB; pInA = pInA + 4 * numColsA; /* Decrement the row loop counter */ rowCnt--; } rowCnt = row & 1; while (rowCnt > 0U) { /* Output pointer is set to starting address of the row being processed */ px = pOut + 2 * i; /* For every row wise process, the column loop counter is to be initiated */ col = numColsB; /* For every row wise process, the pIn2 pointer is set ** to the starting address of the pSrcB data */ pIn2 = pSrcB->pData; j = 0U; /* Column loop */ while (col > 0U) { /* Set the variable sum, that acts as accumulator, to zero */ sumReal1 = 0.0f; sumImag1 = 0.0f; sumReal2 = 0.0f; sumImag2 = 0.0f; /* Initiate the pointer pIn1 to point to the starting address of the column being processed */ pIn1 = pInA; accR0 = vdupq_n_f32(0.0); accI0 = vdupq_n_f32(0.0); /* Compute 4 MACs simultaneously. */ colCnt = numColsA >> 2; /* Matrix multiplication */ while (colCnt > 0U) { /* Reading real part of complex matrix A */ a0V = vld2q_f32(pIn1); // load & separate real/imag pSrcA (de-interleave 2) pIn1 += 8; tempR[0] = *pIn2; tempI[0] = *(pIn2 + 1U); pIn2 += 2 * numColsB; tempR[1] = *pIn2; tempI[1] = *(pIn2 + 1U); pIn2 += 2 * numColsB; tempR[2] = *pIn2; tempI[2] = *(pIn2 + 1U); pIn2 += 2 * numColsB; tempR[3] = *pIn2; tempI[3] = *(pIn2 + 1U); pIn2 += 2 * numColsB; accR0 = vmlaq_f32(accR0,a0V.val[0],tempR); accR0 = vmlsq_f32(accR0,a0V.val[1],tempI); accI0 = vmlaq_f32(accI0,a0V.val[1],tempR); accI0 = vmlaq_f32(accI0,a0V.val[0],tempI); /* Decrement the loop count */ colCnt--; } accum = vpadd_f32(vget_low_f32(accR0), vget_high_f32(accR0)); sumReal1 += accum[0] + accum[1]; accum = vpadd_f32(vget_low_f32(accI0), vget_high_f32(accI0)); sumImag1 += accum[0] + accum[1]; /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ colCnt = numColsA & 3; while (colCnt > 0U) { /* c(m,n) = a(1,1)*b(1,1) + a(1,2)*b(2,1) + ... + a(m,p)*b(p,n) */ a1 = *pIn1; c1 = *pIn2; b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); sumReal1 += a1 * c1; sumImag1 += b1 * c1; pIn1 += 2U; pIn2 += 2 * numColsB; sumReal2 -= b1 * d1; sumImag2 += a1 * d1; /* Decrement the loop counter */ colCnt--; } sumReal1 += sumReal2; sumImag1 += sumImag2; /* Store the result in the destination buffer */ *px++ = sumReal1; *px++ = sumImag1; /* Update the pointer pIn2 to point to the starting address of the next column */ j++; pIn2 = pSrcB->pData + 2U * j; /* Decrement the column loop counter */ col--; } /* Update the pointer pInA to point to the starting address of the next row */ i = i + numColsB; pInA = pInA + 2 * numColsA; /* Decrement the row loop counter */ rowCnt--; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #else arm_status arm_mat_cmplx_mult_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst) { float32_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ float32_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ float32_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ float32_t *pOut = pDst->pData; /* Output data matrix pointer */ float32_t *px; /* Temporary output data matrix pointer */ uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ float32_t sumReal, sumImag; /* Accumulator */ float32_t a1, b1, c1, d1; uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* loop counters */ arm_status status; /* status of matrix multiplication */ #if defined (ARM_MATH_LOOPUNROLL) float32_t a0, b0, c0, d0; #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || (pSrcB->numCols != pDst->numCols) ) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ /* row loop */ do { /* Output pointer is set to starting address of the row being processed */ px = pOut + 2 * i; /* For every row wise process, the column loop counter is to be initiated */ col = numColsB; /* For every row wise process, the pIn2 pointer is set ** to the starting address of the pSrcB data */ pIn2 = pSrcB->pData; j = 0U; /* column loop */ do { /* Set the variable sum, that acts as accumulator, to zero */ sumReal = 0.0f; sumImag = 0.0f; /* Initiate pointer pIn1 to point to starting address of column being processed */ pIn1 = pInA; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 MACs simultaneously. */ colCnt = numColsA >> 2U; /* matrix multiplication */ while (colCnt > 0U) { /* Reading real part of complex matrix A */ a0 = *pIn1; /* Reading real part of complex matrix B */ c0 = *pIn2; /* Reading imaginary part of complex matrix A */ b0 = *(pIn1 + 1U); /* Reading imaginary part of complex matrix B */ d0 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += a0 * c0; sumImag += b0 * c0; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= b0 * d0; sumImag += a0 * d0; /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ /* read real and imag values from pSrcA and pSrcB buffer */ a1 = *(pIn1 ); c1 = *(pIn2 ); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += a1 * c1; sumImag += b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= b1 * d1; sumImag += a1 * d1; a0 = *(pIn1 ); c0 = *(pIn2 ); b0 = *(pIn1 + 1U); d0 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += a0 * c0; sumImag += b0 * c0; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= b0 * d0; sumImag += a0 * d0; /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ a1 = *(pIn1 ); c1 = *(pIn2 ); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += a1 * c1; sumImag += b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= b1 * d1; sumImag += a1 * d1; /* Decrement loop count */ colCnt--; } /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ colCnt = numColsA % 0x4U; #else /* Initialize blkCnt with number of samples */ colCnt = numColsA; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ a1 = *(pIn1 ); c1 = *(pIn2 ); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ sumReal += a1 * c1; sumImag += b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ sumReal -= b1 * d1; sumImag += a1 * d1; /* Decrement loop counter */ colCnt--; } /* Store result in destination buffer */ *px++ = sumReal; *px++ = sumImag; /* Update pointer pIn2 to point to starting address of next column */ j++; pIn2 = pSrcB->pData + 2U * j; /* Decrement column loop counter */ col--; } while (col > 0U); /* Update pointer pInA to point to starting address of next row */ i = i + numColsB; pInA = pInA + 2 * numColsA; /* Decrement row loop counter */ row--; } while (row > 0U); /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of MatrixMult group */
18,348
C
28.033228
113
0.523163
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/StatisticsFunctions/arm_min_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_min_q7.c * Description: Minimum value of a Q7 vector * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupStats */ /** @addtogroup Min @{ */ /** @brief Minimum value of a Q7 vector. @param[in] pSrc points to the input vector @param[in] blockSize number of samples in input vector @param[out] pResult minimum value returned here @param[out] pIndex index of minimum value returned here @return none */ void arm_min_q7( const q7_t * pSrc, uint32_t blockSize, q7_t * pResult, uint32_t * pIndex) { q7_t minVal, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex; /* Loop counter */ #if defined (ARM_MATH_LOOPUNROLL) uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparision */ out = *pSrc++; #if defined (ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; while (blkCnt > 0U) { /* Initialize minVal to next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = index + 1U; } minVal = *pSrc++; if (out > minVal) { out = minVal; outIndex = index + 2U; } minVal = *pSrc++; if (out > minVal) { out = minVal; outIndex = index + 3U; } minVal = *pSrc++; if (out > minVal) { out = minVal; outIndex = index + 4U; } index += 4U; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = (blockSize - 1U) % 4U; #else /* Initialize blkCnt with number of samples */ blkCnt = (blockSize - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Initialize minVal to the next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = blockSize - blkCnt; } /* Decrement loop counter */ blkCnt--; } /* Store the minimum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; } /** @} end of Min group */
3,590
C
22.94
107
0.572145
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/StatisticsFunctions/arm_rms_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_rms_q31.c * Description: Root Mean Square of the elements of a Q31 vector * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupStats */ /** @addtogroup RMS @{ */ /** @brief Root Mean Square of the elements of a Q31 vector. @param[in] pSrc points to the input vector @param[in] blockSize number of samples in input vector @param[out] pResult root mean square value returned here @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The input is represented in 1.31 format, and intermediate multiplication yields a 2.62 format. The accumulator maintains full precision of the intermediate multiplication results, but provides only a single guard bit. There is no saturation on intermediate additions. If the accumulator overflows, it wraps around and distorts the result. In order to avoid overflows completely, the input signal must be scaled down by log2(blockSize) bits, as a total of blockSize additions are performed internally. Finally, the 2.62 accumulator is right shifted by 31 bits to yield a 1.31 format value. */ void arm_rms_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult) { uint32_t blkCnt; /* Loop counter */ uint64_t sum = 0; /* Temporary result storage (can get never negative. changed type from q63 to uint64 */ q31_t in; /* Temporary variable to store input value */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable, sum. */ sum += ((q63_t) in * in); in = *pSrc++; sum += ((q63_t) in * in); in = *pSrc++; sum += ((q63_t) in * in); in = *pSrc++; sum += ((q63_t) in * in); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable. */ sum += ((q63_t) in * in); /* Decrement loop counter */ blkCnt--; } /* Convert data in 2.62 to 1.31 by 31 right shifts and saturate */ /* Compute Rms and store result in destination vector */ arm_sqrt_q31(clip_q63_to_q31((sum / (q63_t) blockSize) >> 31), pResult); } /** @} end of RMS group */
4,001
C
31.016
142
0.581355
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/StatisticsFunctions/arm_max_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_max_f32.c * Description: Maximum value of a floating-point vector * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" #if defined(ARM_MATH_NEON) #include <limits.h> #endif /** @ingroup groupStats */ /** @defgroup Max Maximum Computes the maximum value of an array of data. The function returns both the maximum value and its position within the array. There are separate functions for floating-point, Q31, Q15, and Q7 data types. */ /** @addtogroup Max @{ */ /** @brief Maximum value of a floating-point vector. @param[in] pSrc points to the input vector @param[in] blockSize number of samples in input vector @param[out] pResult maximum value returned here @param[out] pIndex index of maximum value returned here @return none */ #if defined(ARM_MATH_NEON) void arm_max_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult, uint32_t * pIndex) { float32_t maxVal1, maxVal2, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex, count; /* loop counter */ float32x4_t outV, srcV; float32x2_t outV2; uint32x4_t idxV; uint32x4_t maxIdx={ULONG_MAX,ULONG_MAX,ULONG_MAX,ULONG_MAX}; uint32x4_t index={4,5,6,7}; uint32x4_t delta={4,4,4,4}; uint32x4_t countV={0,1,2,3}; uint32x2_t countV2; /* Initialise the count value. */ count = 0U; /* Initialise the index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparison */ if (blockSize <= 3) { out = *pSrc++; blkCnt = blockSize - 1; while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal1 = *pSrc++; /* compare for the maximum value */ if (out < maxVal1) { /* Update the maximum value and it's index */ out = maxVal1; outIndex = blockSize - blkCnt; } /* Decrement the loop counter */ blkCnt--; } } else { outV = vld1q_f32(pSrc); pSrc += 4; /* Compute 4 outputs at a time */ blkCnt = (blockSize - 4 ) >> 2U; while (blkCnt > 0U) { srcV = vld1q_f32(pSrc); pSrc += 4; idxV = vcgtq_f32(srcV, outV); outV = vbslq_f32(idxV, srcV, outV ); countV = vbslq_u32(idxV, index,countV ); index = vaddq_u32(index,delta); /* Decrement the loop counter */ blkCnt--; } outV2 = vpmax_f32(vget_low_f32(outV),vget_high_f32(outV)); outV2 = vpmax_f32(outV2,outV2); out = outV2[0]; idxV = vceqq_f32(outV, vdupq_n_f32(out)); countV = vbslq_u32(idxV, countV,maxIdx); countV2 = vpmin_u32(vget_low_u32(countV),vget_high_u32(countV)); countV2 = vpmin_u32(countV2,countV2); outIndex = countV2[0]; /* if (blockSize - 1U) is not multiple of 4 */ blkCnt = (blockSize - 4 ) % 4U; while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal1 = *pSrc++; /* compare for the maximum value */ if (out < maxVal1) { /* Update the maximum value and it's index */ out = maxVal1; outIndex = blockSize - blkCnt ; } /* Decrement the loop counter */ blkCnt--; } } /* Store the maximum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; } #else void arm_max_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult, uint32_t * pIndex) { float32_t maxVal, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex; /* Loop counter */ #if defined (ARM_MATH_LOOPUNROLL) uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparision */ out = *pSrc++; #if defined (ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; while (blkCnt > 0U) { /* Initialize maxVal to next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = index + 1U; } maxVal = *pSrc++; if (out < maxVal) { out = maxVal; outIndex = index + 2U; } maxVal = *pSrc++; if (out < maxVal) { out = maxVal; outIndex = index + 3U; } maxVal = *pSrc++; if (out < maxVal) { out = maxVal; outIndex = index + 4U; } index += 4U; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = (blockSize - 1U) % 4U; #else /* Initialize blkCnt with number of samples */ blkCnt = (blockSize - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; } /* Decrement loop counter */ blkCnt--; } /* Store the maximum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of Max group */
6,741
C
23.786765
107
0.57039
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/StatisticsFunctions/arm_std_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_std_f32.c * Description: Standard deviation of the elements of a floating-point vector * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupStats */ /** @defgroup STD Standard deviation Calculates the standard deviation of the elements in the input vector. The underlying algorithm is used: <pre> Result = sqrt((sumOfSquares - sum<sup>2</sup> / blockSize) / (blockSize - 1)) sumOfSquares = pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... + pSrc[blockSize-1] * pSrc[blockSize-1] sum = pSrc[0] + pSrc[1] + pSrc[2] + ... + pSrc[blockSize-1] </pre> There are separate functions for floating point, Q31, and Q15 data types. */ /** @addtogroup STD @{ */ /** @brief Standard deviation of the elements of a floating-point vector. @param[in] pSrc points to the input vector @param[in] blockSize number of samples in input vector @param[out] pResult standard deviation value returned here @return none */ #if defined(ARM_MATH_NEON_EXPERIMENTAL) void arm_std_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult) { float32_t var; arm_var_f32(pSrc,blockSize,&var); arm_sqrt_f32(var, pResult); } #else void arm_std_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult) { uint32_t blkCnt; /* Loop counter */ float32_t sum = 0.0f; /* Temporary result storage */ float32_t sumOfSquares = 0.0f; /* Sum of squares */ float32_t in; /* Temporary variable to store input value */ #ifndef ARM_MATH_CM0_FAMILY float32_t meanOfSquares, mean, squareOfMean; /* Temporary variables */ #else float32_t squareOfSum; /* Square of Sum */ float32_t var; /* Temporary varaince storage */ #endif if (blockSize <= 1U) { *pResult = 0; return; } #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ sumOfSquares += in * in; /* Compute sum and store result in a temporary variable, sum. */ sum += in; in = *pSrc++; sumOfSquares += in * in; sum += in; in = *pSrc++; sumOfSquares += in * in; sum += in; in = *pSrc++; sumOfSquares += in * in; sum += in; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ sumOfSquares += ( in * in); /* Compute sum and store result in a temporary variable, sum. */ sum += in; /* Decrement loop counter */ blkCnt--; } #ifndef ARM_MATH_CM0_FAMILY /* Compute Mean of squares and store result in a temporary variable, meanOfSquares. */ meanOfSquares = sumOfSquares / ((float32_t) blockSize - 1.0f); /* Compute mean of all input values */ mean = sum / (float32_t) blockSize; /* Compute square of mean */ squareOfMean = (mean * mean) * (((float32_t) blockSize) / ((float32_t) blockSize - 1.0f)); /* Compute standard deviation and store result to destination */ arm_sqrt_f32((meanOfSquares - squareOfMean), pResult); #else /* Run the below code for Cortex-M0 */ /* Compute square of sum */ squareOfSum = ((sum * sum) / (float32_t) blockSize); /* Compute variance */ var = ((sumOfSquares - squareOfSum) / (float32_t) (blockSize - 1.0f)); /* Compute standard deviation and store result in destination */ arm_sqrt_f32(var, pResult); #endif /* #ifndef ARM_MATH_CM0_FAMILY */ } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of STD group */
5,339
C
27.253968
104
0.586065
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/StatisticsFunctions/arm_power_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_power_q7.c * Description: Sum of the squares of the elements of a Q7 vector * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupStats */ /** @addtogroup power @{ */ /** @brief Sum of the squares of the elements of a Q7 vector. @param[in] pSrc points to the input vector @param[in] blockSize number of samples in input vector @param[out] pResult sum of the squares value returned here @return none @par Scaling and Overflow Behavior The function is implemented using a 32-bit internal accumulator. The input is represented in 1.7 format. Intermediate multiplication yields a 2.14 format, and this result is added without saturation to an accumulator in 18.14 format. With 17 guard bits in the accumulator, there is no risk of overflow, and the full precision of the intermediate multiplication is preserved. Finally, the return result is in 18.14 format. */ void arm_power_q7( const q7_t * pSrc, uint32_t blockSize, q31_t * pResult) { uint32_t blkCnt; /* Loop counter */ q31_t sum = 0; /* Temporary result storage */ q7_t in; /* Temporary variable to store input value */ #if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) q31_t in32; /* Temporary variable to store packed input value */ q31_t in1, in2; /* Temporary variables to store input value */ #endif #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ #if defined (ARM_MATH_DSP) in32 = read_q7x4_ia ((q7_t **) &pSrc); in1 = __SXTB16(__ROR(in32, 8)); in2 = __SXTB16(in32); /* calculate power and accumulate to accumulator */ sum = __SMLAD(in1, in1, sum); sum = __SMLAD(in2, in2, sum); #else in = *pSrc++; sum += ((q15_t) in * in); in = *pSrc++; sum += ((q15_t) in * in); in = *pSrc++; sum += ((q15_t) in * in); in = *pSrc++; sum += ((q15_t) in * in); #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ in = *pSrc++; sum += ((q15_t) in * in); /* Decrement loop counter */ blkCnt--; } /* Store result in 18.14 format */ *pResult = sum; } /** @} end of power group */
4,084
C
28.817518
107
0.55999
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/StatisticsFunctions/StatisticsFunctions.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: StatisticsFunctions.c * Description: Combination of all statistics function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_max_f32.c" #include "arm_max_q15.c" #include "arm_max_q31.c" #include "arm_max_q7.c" #include "arm_mean_f32.c" #include "arm_mean_q15.c" #include "arm_mean_q31.c" #include "arm_mean_q7.c" #include "arm_min_f32.c" #include "arm_min_q15.c" #include "arm_min_q31.c" #include "arm_min_q7.c" #include "arm_power_f32.c" #include "arm_power_q15.c" #include "arm_power_q31.c" #include "arm_power_q7.c" #include "arm_rms_f32.c" #include "arm_rms_q15.c" #include "arm_rms_q31.c" #include "arm_std_f32.c" #include "arm_std_q15.c" #include "arm_std_q31.c" #include "arm_var_f32.c" #include "arm_var_q15.c" #include "arm_var_q31.c"
1,691
C
30.333333
74
0.642815
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_f32.c * Description: Floating-point FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup FIR Finite Impulse Response (FIR) Filters This set of functions implements Finite Impulse Response (FIR) filters for Q7, Q15, Q31, and floating-point data types. Fast versions of Q15 and Q31 are also provided. The functions operate on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> and <code>pDst</code> points to input and output arrays containing <code>blockSize</code> values. @par Algorithm The FIR filter algorithm is based upon a sequence of multiply-accumulate (MAC) operations. Each filter coefficient <code>b[n]</code> is multiplied by a state variable which equals a previous input sample <code>x[n]</code>. <pre> y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1] </pre> @par \image html FIR.GIF "Finite Impulse Response filter" @par <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>. Coefficients are stored in time reversed order. @par <pre> {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} </pre> @par <code>pState</code> points to a state array of size <code>numTaps + blockSize - 1</code>. Samples in the state buffer are stored in the following order. @par <pre> {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]} </pre> @par Note that the length of the state buffer exceeds the length of the coefficient array by <code>blockSize-1</code>. The increased state buffer length allows circular addressing, which is traditionally used in the FIR filters, to be avoided and yields a significant speed improvement. The state variables are updated after each block of data is processed; the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 4 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numTaps, pCoeffs, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. The code below statically initializes each of the 4 different data type filter instance structures <pre> arm_fir_instance_f32 S = {numTaps, pState, pCoeffs}; arm_fir_instance_q31 S = {numTaps, pState, pCoeffs}; arm_fir_instance_q15 S = {numTaps, pState, pCoeffs}; arm_fir_instance_q7 S = {numTaps, pState, pCoeffs}; </pre> where <code>numTaps</code> is the number of filter coefficients in the filter; <code>pState</code> is the address of the state buffer; <code>pCoeffs</code> is the address of the coefficient buffer. @par Fixed-Point Behavior Care must be taken when using the fixed-point versions of the FIR filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. */ /** @addtogroup FIR @{ */ /** @brief Processing function for floating-point FIR filter. @param[in] S points to an instance of the floating-point FIR filter structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ #if defined(ARM_MATH_NEON) void arm_fir_f32( const arm_fir_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCurnt; /* Points to the current sample of the state */ float32_t *px; /* Temporary pointers for state buffer */ const float32_t *pb; /* Temporary pointers for coefficient buffer */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt; /* Loop counters */ float32x4_t accv0,accv1,samples0,samples1,x0,x1,x2,xa,xb,x,b,accv; uint32x4_t x0_u,x1_u,x2_u,xa_u,xb_u; float32_t acc; /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* Loop unrolling */ blkCnt = blockSize >> 3; while (blkCnt > 0U) { /* Copy 8 samples at a time into state buffers */ samples0 = vld1q_f32(pSrc); vst1q_f32(pStateCurnt,samples0); pStateCurnt += 4; pSrc += 4 ; samples1 = vld1q_f32(pSrc); vst1q_f32(pStateCurnt,samples1); pStateCurnt += 4; pSrc += 4 ; /* Set the accumulators to zero */ accv0 = vdupq_n_f32(0); accv1 = vdupq_n_f32(0); /* Initialize state pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Loop unroling */ i = numTaps >> 2; /* Perform the multiply-accumulates */ x0 = vld1q_f32(px); x1 = vld1q_f32(px + 4); while(i > 0) { /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ x2 = vld1q_f32(px + 8); b = vld1q_f32(pb); xa = x0; xb = x1; accv0 = vmlaq_n_f32(accv0,xa,b[0]); accv1 = vmlaq_n_f32(accv1,xb,b[0]); xa = vextq_f32(x0,x1,1); xb = vextq_f32(x1,x2,1); accv0 = vmlaq_n_f32(accv0,xa,b[1]); accv1 = vmlaq_n_f32(accv1,xb,b[1]); xa = vextq_f32(x0,x1,2); xb = vextq_f32(x1,x2,2); accv0 = vmlaq_n_f32(accv0,xa,b[2]); accv1 = vmlaq_n_f32(accv1,xb,b[2]); xa = vextq_f32(x0,x1,3); xb = vextq_f32(x1,x2,3); accv0 = vmlaq_n_f32(accv0,xa,b[3]); accv1 = vmlaq_n_f32(accv1,xb,b[3]); pb += 4; x0 = x1; x1 = x2; px += 4; i--; } /* Tail */ i = numTaps & 3; x2 = vld1q_f32(px + 8); /* Perform the multiply-accumulates */ switch(i) { case 3: { accv0 = vmlaq_n_f32(accv0,x0,*pb); accv1 = vmlaq_n_f32(accv1,x1,*pb); pb++; xa = vextq_f32(x0,x1,1); xb = vextq_f32(x1,x2,1); accv0 = vmlaq_n_f32(accv0,xa,*pb); accv1 = vmlaq_n_f32(accv1,xb,*pb); pb++; xa = vextq_f32(x0,x1,2); xb = vextq_f32(x1,x2,2); accv0 = vmlaq_n_f32(accv0,xa,*pb); accv1 = vmlaq_n_f32(accv1,xb,*pb); } break; case 2: { accv0 = vmlaq_n_f32(accv0,x0,*pb); accv1 = vmlaq_n_f32(accv1,x1,*pb); pb++; xa = vextq_f32(x0,x1,1); xb = vextq_f32(x1,x2,1); accv0 = vmlaq_n_f32(accv0,xa,*pb); accv1 = vmlaq_n_f32(accv1,xb,*pb); } break; case 1: { accv0 = vmlaq_n_f32(accv0,x0,*pb); accv1 = vmlaq_n_f32(accv1,x1,*pb); } break; default: break; } /* The result is stored in the destination buffer. */ vst1q_f32(pDst,accv0); pDst += 4; vst1q_f32(pDst,accv1); pDst += 4; /* Advance state pointer by 8 for the next 8 samples */ pState = pState + 8; blkCnt--; } /* Tail */ blkCnt = blockSize & 0x7; while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; /* Set the accumulator to zero */ acc = 0.0f; /* Initialize state pointer */ px = pState; /* Initialize Coefficient pointer */ pb = pCoeffs; i = numTaps; /* Perform the multiply-accumulates */ do { /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ acc += *px++ * *pb++; i--; } while (i > 0U); /* The result is stored in the destination buffer. */ *pDst++ = acc; /* Advance state pointer by 1 for the next sample */ pState = pState + 1; blkCnt--; } /* Processing is complete. ** Now copy the last numTaps - 1 samples to the starting of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; /* Copy numTaps number of values */ tapCnt = numTaps - 1U; /* Copy data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ tapCnt--; } } #else void arm_fir_f32( const arm_fir_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCurnt; /* Points to the current sample of the state */ float32_t *px; /* Temporary pointer for state buffer */ const float32_t *pb; /* Temporary pointer for coefficient buffer */ float32_t acc0; /* Accumulator */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) float32_t acc1, acc2, acc3, acc4, acc5, acc6, acc7; /* Accumulators */ float32_t x0, x1, x2, x3, x4, x5, x6, x7; /* Temporary variables to hold state values */ float32_t c0; /* Temporary variable to hold coefficient value */ #endif /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 8 output values simultaneously. * The variables acc0 ... acc7 hold output values that are being computed: * * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 3U; while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; /* Set all accumulators to zero */ acc0 = 0.0f; acc1 = 0.0f; acc2 = 0.0f; acc3 = 0.0f; acc4 = 0.0f; acc5 = 0.0f; acc6 = 0.0f; acc7 = 0.0f; /* Initialize state pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* This is separated from the others to avoid * a call to __aeabi_memmove which would be slower */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; /* Read the first 7 samples from the state buffer: x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2] */ x0 = *px++; x1 = *px++; x2 = *px++; x3 = *px++; x4 = *px++; x5 = *px++; x6 = *px++; /* Loop unrolling: process 8 taps at a time. */ tapCnt = numTaps >> 3U; while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-3] sample */ x7 = *(px++); /* acc0 += b[numTaps-1] * x[n-numTaps] */ acc0 += x0 * c0; /* acc1 += b[numTaps-1] * x[n-numTaps-1] */ acc1 += x1 * c0; /* acc2 += b[numTaps-1] * x[n-numTaps-2] */ acc2 += x2 * c0; /* acc3 += b[numTaps-1] * x[n-numTaps-3] */ acc3 += x3 * c0; /* acc4 += b[numTaps-1] * x[n-numTaps-4] */ acc4 += x4 * c0; /* acc1 += b[numTaps-1] * x[n-numTaps-5] */ acc5 += x5 * c0; /* acc2 += b[numTaps-1] * x[n-numTaps-6] */ acc6 += x6 * c0; /* acc3 += b[numTaps-1] * x[n-numTaps-7] */ acc7 += x7 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-4] sample */ x0 = *(px++); /* Perform the multiply-accumulate */ acc0 += x1 * c0; acc1 += x2 * c0; acc2 += x3 * c0; acc3 += x4 * c0; acc4 += x5 * c0; acc5 += x6 * c0; acc6 += x7 * c0; acc7 += x0 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-5] sample */ x1 = *(px++); /* Perform the multiply-accumulates */ acc0 += x2 * c0; acc1 += x3 * c0; acc2 += x4 * c0; acc3 += x5 * c0; acc4 += x6 * c0; acc5 += x7 * c0; acc6 += x0 * c0; acc7 += x1 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-6] sample */ x2 = *(px++); /* Perform the multiply-accumulates */ acc0 += x3 * c0; acc1 += x4 * c0; acc2 += x5 * c0; acc3 += x6 * c0; acc4 += x7 * c0; acc5 += x0 * c0; acc6 += x1 * c0; acc7 += x2 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-6] sample */ x3 = *(px++); /* Perform the multiply-accumulates */ acc0 += x4 * c0; acc1 += x5 * c0; acc2 += x6 * c0; acc3 += x7 * c0; acc4 += x0 * c0; acc5 += x1 * c0; acc6 += x2 * c0; acc7 += x3 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-6] sample */ x4 = *(px++); /* Perform the multiply-accumulates */ acc0 += x5 * c0; acc1 += x6 * c0; acc2 += x7 * c0; acc3 += x0 * c0; acc4 += x1 * c0; acc5 += x2 * c0; acc6 += x3 * c0; acc7 += x4 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-6] sample */ x5 = *(px++); /* Perform the multiply-accumulates */ acc0 += x6 * c0; acc1 += x7 * c0; acc2 += x0 * c0; acc3 += x1 * c0; acc4 += x2 * c0; acc5 += x3 * c0; acc6 += x4 * c0; acc7 += x5 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-6] sample */ x6 = *(px++); /* Perform the multiply-accumulates */ acc0 += x7 * c0; acc1 += x0 * c0; acc2 += x1 * c0; acc3 += x2 * c0; acc4 += x3 * c0; acc5 += x4 * c0; acc6 += x5 * c0; acc7 += x6 * c0; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = numTaps % 0x8U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch 1 state variable */ x7 = *(px++); /* Perform the multiply-accumulates */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; acc4 += x4 * c0; acc5 += x5 * c0; acc6 += x6 * c0; acc7 += x7 * c0; /* Reuse the present sample states for next sample */ x0 = x1; x1 = x2; x2 = x3; x3 = x4; x4 = x5; x5 = x6; x6 = x7; /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by 8 to process the next group of 8 samples */ pState = pState + 8; /* The results in the 8 accumulators, store in the destination buffer. */ *pDst++ = acc0; *pDst++ = acc1; *pDst++ = acc2; *pDst++ = acc3; *pDst++ = acc4; *pDst++ = acc5; *pDst++ = acc6; *pDst++ = acc7; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining output samples */ blkCnt = blockSize % 0x8U; #else /* Initialize blkCnt with number of taps */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; /* Set the accumulator to zero */ acc0 = 0.0f; /* Initialize state pointer */ px = pState; /* Initialize Coefficient pointer */ pb = pCoeffs; i = numTaps; /* Perform the multiply-accumulates */ do { /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ acc0 += *px++ * *pb++; i--; } while (i > 0U); /* Store result in destination buffer. */ *pDst++ = acc0; /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Calculate remaining number of copies */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } #endif /* #if defined(ARM_MATH_NEON) */ /** * @} end of FIR group */
21,033
C
28.377095
153
0.538535
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_q31.c * Description: Processing function for the Q31 Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF1 @{ */ /** @brief Processing function for the Q31 Biquad cascade filter. @param[in] S points to an instance of the Q31 Biquad cascade structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by 2 bits and lie in the range [-0.25 +0.25). After all 5 multiply-accumulates are performed, the 2.62 accumulator is shifted by <code>postShift</code> bits and the result truncated to 1.31 format by discarding the low 32 bits. @remark Refer to \ref arm_biquad_cascade_df1_fast_q31() for a faster but less precise implementation of this filter. */ void arm_biquad_cascade_df1_q31( const arm_biquad_casd_df1_inst_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { const q31_t *pIn = pSrc; /* Source pointer */ q31_t *pOut = pDst; /* Destination pointer */ q31_t *pState = S->pState; /* pState pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q63_t acc; /* Accumulator */ q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ q31_t Xn1, Xn2, Yn1, Yn2; /* Filter pState variables */ q31_t Xn; /* Temporary input */ uint32_t uShift = ((uint32_t) S->postShift + 1U); uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ uint32_t sample, stage = S->numStages; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q31_t acc_l, acc_h; /* temporary output variables */ #endif do { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; a2 = *pCoeffs++; /* Reading the pState values */ Xn1 = pState[0]; Xn2 = pState[1]; Yn1 = pState[2]; Yn2 = pState[3]; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 output values simultaneously. */ /* Variable acc hold output values that are being computed: * * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* Loop unrolling: Compute 4 outputs at a time */ sample = blockSize >> 2U; while (sample > 0U) { /* Read the first input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = ((q63_t) b0 * Xn) + ((q63_t) b1 * Xn1) + ((q63_t) b2 * Xn2) + ((q63_t) a1 * Yn1) + ((q63_t) a2 * Yn2); /* The result is converted to 1.31 , Yn2 variable is reused */ acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ Yn2 = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn2; /* Read the second input */ Xn2 = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = ((q63_t) b0 * Xn2) + ((q63_t) b1 * Xn) + ((q63_t) b2 * Xn1) + ((q63_t) a1 * Yn2) + ((q63_t) a2 * Yn1); /* The result is converted to 1.31, Yn1 variable is reused */ acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ Yn1 = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn1; /* Read the third input */ Xn1 = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = ((q63_t) b0 * Xn1) + ((q63_t) b1 * Xn2) + ((q63_t) b2 * Xn) + ((q63_t) a1 * Yn1) + ((q63_t) a2 * Yn2); /* The result is converted to 1.31, Yn2 variable is reused */ acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ Yn2 = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn2; /* Read the forth input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = ((q63_t) b0 * Xn) + ((q63_t) b1 * Xn1) + ((q63_t) b2 * Xn2) + ((q63_t) a1 * Yn2) + ((q63_t) a2 * Yn1); /* The result is converted to 1.31, Yn1 variable is reused */ acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ Yn1 = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn1; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = blockSize & 0x3U; #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { /* Read the input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = ((q63_t) b0 * Xn) + ((q63_t) b1 * Xn1) + ((q63_t) b2 * Xn2) + ((q63_t) a1 * Yn1) + ((q63_t) a2 * Yn2); /* The result is converted to 1.31 */ acc = acc >> lShift; /* Store output in destination buffer. */ *pOut++ = (q31_t) acc; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; Yn1 = (q31_t) acc; /* decrement loop counter */ sample--; } /* Store the updated state variables back into the pState array */ *pState++ = Xn1; *pState++ = Xn2; *pState++ = Yn1; *pState++ = Yn2; /* The first stage goes from the input buffer to the output buffer. */ /* Subsequent numStages occur in-place in the output buffer */ pIn = pDst; /* Reset output pointer */ pOut = pDst; /* decrement loop counter */ stage--; } while (stage > 0U); } /** @} end of BiquadCascadeDF1 group */
8,635
C
33.822581
162
0.534453
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_lms_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_lms_q15.c * Description: Processing function for Q15 LMS filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup LMS @{ */ /** @brief Processing function for Q15 LMS filter. @param[in] S points to an instance of the Q15 LMS filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @param[out] pErr points to the block of error data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. @par In this filter, filter coefficients are updated for each sample and the updation of filter cofficients are saturted. */ void arm_lms_q15( const arm_lms_instance_q15 * S, const q15_t * pSrc, q15_t * pRef, q15_t * pOut, q15_t * pErr, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCurnt; /* Points to the current sample of the state */ q15_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ q15_t mu = S->mu; /* Adaptive factor */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t tapCnt, blkCnt; /* Loop counters */ q63_t acc; /* Accumulator */ q15_t e = 0; /* Error of data sample */ q15_t alpha; /* Intermediate constant for taps update */ q31_t coef; /* Temporary variable for coefficient */ q31_t acc_l, acc_h; /* Temporary input */ int32_t lShift = (15 - (int32_t) S->postShift); /* Post shift */ int32_t uShift = (32 - lShift); /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; /* Initialize pState pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Set the accumulator to zero */ acc = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (q63_t) (((q31_t) (*px++) * (*pb++))); /* Decrement the loop counter */ tapCnt--; } /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Converting the result to 1.15 format and saturate the output */ acc = __SSAT(acc, 16U); /* Store the result from accumulator into the destination buffer. */ *pOut++ = (q15_t) acc; /* Compute and store error */ e = *pRef++ - (q15_t) acc; *pErr++ = (q15_t) e; /* Compute alpha i.e. intermediate constant for taps update */ alpha = (q15_t) (((q31_t) e * (mu)) >> 15); /* Initialize pState pointer */ /* Advance state pointer by 1 for the next sample */ px = pState++; /* Initialize coefficient pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ while (tapCnt > 0U) { coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); *pb++ = (q15_t) __SSAT((coef), 16); coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); *pb++ = (q15_t) __SSAT((coef), 16); coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); *pb++ = (q15_t) __SSAT((coef), 16); coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); *pb++ = (q15_t) __SSAT((coef), 16); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); *pb++ = (q15_t) __SSAT((coef), 16); /* Decrement loop counter */ tapCnt--; } /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the pState buffer */ pStateCurnt = S->pState; /* copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; while (tapCnt > 0U) { write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of LMS group */
8,184
C
30.121673
144
0.559873
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_stereo_df2T_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_stereo_df2T_f32.c * Description: Processing function for floating-point transposed direct form II Biquad cascade filter. 2 channels * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF2T @{ */ /** @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. @param[in] S points to an instance of the filter data structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ LOW_OPTIMIZATION_ENTER void arm_biquad_cascade_stereo_df2T_f32( const arm_biquad_cascade_stereo_df2T_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { const float32_t *pIn = pSrc; /* Source pointer */ float32_t *pOut = pDst; /* Destination pointer */ float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t acc1a, acc1b; /* Accumulator */ float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ float32_t Xn1a, Xn1b; /* Temporary input */ float32_t d1a, d2a, d1b, d2b; /* State variables */ uint32_t sample, stage = S->numStages; /* Loop counters */ do { /* Reading the coefficients */ b0 = pCoeffs[0]; b1 = pCoeffs[1]; b2 = pCoeffs[2]; a1 = pCoeffs[3]; a2 = pCoeffs[4]; /* Reading the state values */ d1a = pState[0]; d2a = pState[1]; d1b = pState[2]; d2b = pState[3]; pCoeffs += 5U; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 8 outputs at a time */ sample = blockSize >> 3U; while (sample > 0U) { /* y[n] = b0 * x[n] + d1 */ /* d1 = b1 * x[n] + a1 * y[n] + d2 */ /* d2 = b2 * x[n] + a2 * y[n] */ /* 1 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 2 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 3 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 4 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 5 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 6 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 7 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* 8 */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; *pOut++ = acc1a; *pOut++ = acc1b; d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = blockSize & 0x7U; #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { /* Read the input */ Xn1a = *pIn++; /* Channel a */ Xn1b = *pIn++; /* Channel b */ /* y[n] = b0 * x[n] + d1 */ acc1a = (b0 * Xn1a) + d1a; acc1b = (b0 * Xn1b) + d1b; /* Store the result in the accumulator in the destination buffer. */ *pOut++ = acc1a; *pOut++ = acc1b; /* Every time after the output is computed state should be updated. */ /* d1 = b1 * x[n] + a1 * y[n] + d2 */ d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; /* d2 = b2 * x[n] + a2 * y[n] */ d2a = (b2 * Xn1a) + (a2 * acc1a); d2b = (b2 * Xn1b) + (a2 * acc1b); /* decrement loop counter */ sample--; } /* Store the updated state variables back into the state array */ pState[0] = d1a; pState[1] = d2a; pState[2] = d1b; pState[3] = d2b; pState += 4U; /* The current stage input is given as the output to the next stage */ pIn = pDst; /* Reset the output working pointer */ pOut = pDst; /* Decrement the loop counter */ stage--; } while (stage > 0U); } LOW_OPTIMIZATION_EXIT /** @} end of BiquadCascadeDF2T group */
8,126
C
27.416084
115
0.455698
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_conv_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_conv_q7.c * Description: Convolution of Q7 sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup Conv @{ */ /** @brief Convolution of Q7 sequences. @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. @return none @par Scaling and Overflow Behavior The function is implemented using a 32-bit internal accumulator. Both the inputs are represented in 1.7 format and multiplications yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. This approach provides 17 guard bits and there is no risk of overflow as long as <code>max(srcALen, srcBLen)<131072</code>. The 18.14 result is then truncated to 18.7 format by discarding the low 7 bits and then saturated to 1.7 format. @remark Refer to \ref arm_conv_opt_q7() for a faster implementation of this function. */ void arm_conv_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst) { #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) const q7_t *pIn1; /* InputA pointer */ const q7_t *pIn2; /* InputB pointer */ q7_t *pOut = pDst; /* Output pointer */ const q7_t *px; /* Intermediate inputA pointer */ const q7_t *py; /* Intermediate inputB pointer */ const q7_t *pSrc1, *pSrc2; /* Intermediate pointers */ q31_t sum; /* Accumulators */ uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ uint32_t j, k, count, blkCnt; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q31_t acc0, acc1, acc2, acc3; /* Accumulators */ q31_t input1, input2; /* Temporary input variables */ q15_t in1, in2; /* Temporary input variables */ q7_t x0, x1, x2, x3, c0, c1; /* Temporary variables to hold state and coefficient values */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; /* Initialization of inputB pointer */ pIn2 = pSrcA; /* srcBLen is always considered as shorter or equal to srcALen */ j = srcBLen; srcBLen = srcALen; srcALen = j; } /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ /* The function is internally * divided into three stages according to the number of multiplications that has to be * taken place between inputA samples and inputB samples. In the first stage of the * algorithm, the multiplications increase by one for every iteration. * In the second stage of the algorithm, srcBLen number of multiplications are done. * In the third stage of the algorithm, the multiplications decrease by one * for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ blockSize1 = srcBLen - 1U; blockSize2 = srcALen - (srcBLen - 1U); blockSize3 = blockSize1; /* -------------------------- * Initializations of stage1 * -------------------------*/ /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. The count variable holds the number of MAC operations performed */ count = 1U; /* Working pointer of inputA */ px = pIn1; /* Working pointer of inputB */ py = pIn2; /* ------------------------ * Stage1 process * ----------------------*/ /* The first stage starts here */ while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; while (k > 0U) { /* x[0] , x[1] */ in1 = (q15_t) *px++; in2 = (q15_t) *px++; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* y[srcBLen - 1] , y[srcBLen - 2] */ in1 = (q15_t) *py--; in2 = (q15_t) *py--; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* x[0] * y[srcBLen - 1] */ /* x[1] * y[srcBLen - 2] */ sum = __SMLAD(input1, input2, sum); /* x[2] , x[3] */ in1 = (q15_t) *px++; in2 = (q15_t) *px++; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* y[srcBLen - 3] , y[srcBLen - 4] */ in1 = (q15_t) *py--; in2 = (q15_t) *py--; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* x[2] * y[srcBLen - 3] */ /* x[3] * y[srcBLen - 4] */ sum = __SMLAD(input1, input2, sum); /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = count % 0x4U; #else /* Initialize k with number of samples */ k = count; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += ((q15_t) *px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + count; px = pIn1; /* Increment MAC count */ count++; /* Decrement loop counter */ blockSize1--; } /* -------------------------- * Initializations of stage2 * ------------------------*/ /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ px = pIn1; /* Working pointer of inputB */ pSrc2 = pIn2 + (srcBLen - 1U); py = pSrc2; /* count is index by which the pointer pIn1 to be incremented */ count = 0U; /* ------------------- * Stage2 process * ------------------*/ /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. * So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ if (srcBLen >= 4U) { #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize2 >> 2U; while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* read x[0], x[1], x[2] samples */ x0 = *px++; x1 = *px++; x2 = *px++; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; /* First part of the processing with loop unrolling. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read y[srcBLen - 2] sample */ c1 = *py--; /* Read x[3] sample */ x3 = *px++; /* x[0] and x[1] are packed */ in1 = (q15_t) x0; in2 = (q15_t) x1; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* y[srcBLen - 1] and y[srcBLen - 2] are packed */ in1 = (q15_t) c0; in2 = (q15_t) c1; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLAD(input1, input2, acc0); /* x[1] and x[2] are packed */ in1 = (q15_t) x1; in2 = (q15_t) x2; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc1 += x[1] * y[srcBLen - 1] + x[2] * y[srcBLen - 2] */ acc1 = __SMLAD(input1, input2, acc1); /* x[2] and x[3] are packed */ in1 = (q15_t) x2; in2 = (q15_t) x3; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLAD(input1, input2, acc2); /* Read x[4] sample */ x0 = *px++; /* x[3] and x[4] are packed */ in1 = (q15_t) x3; in2 = (q15_t) x0; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc3 += x[3] * y[srcBLen - 1] + x[4] * y[srcBLen - 2] */ acc3 = __SMLAD(input1, input2, acc3); /* Read y[srcBLen - 3] sample */ c0 = *py--; /* Read y[srcBLen - 4] sample */ c1 = *py--; /* Read x[5] sample */ x1 = *px++; /* x[2] and x[3] are packed */ in1 = (q15_t) x2; in2 = (q15_t) x3; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* y[srcBLen - 3] and y[srcBLen - 4] are packed */ in1 = (q15_t) c0; in2 = (q15_t) c1; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLAD(input1, input2, acc0); /* x[3] and x[4] are packed */ in1 = (q15_t) x3; in2 = (q15_t) x0; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc1 += x[3] * y[srcBLen - 3] + x[4] * y[srcBLen - 4] */ acc1 = __SMLAD(input1, input2, acc1); /* x[4] and x[5] are packed */ in1 = (q15_t) x0; in2 = (q15_t) x1; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4] */ acc2 = __SMLAD(input1, input2, acc2); /* Read x[6] sample */ x2 = *px++; /* x[5] and x[6] are packed */ in1 = (q15_t) x1; in2 = (q15_t) x2; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* acc3 += x[5] * y[srcBLen - 3] + x[6] * y[srcBLen - 4] */ acc3 = __SMLAD(input1, input2, acc3); } while (--k); /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ x3 = *px++; /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ acc0 += ((q15_t) x0 * c0); /* acc1 += x[5] * y[srcBLen - 5] */ acc1 += ((q15_t) x1 * c0); /* acc2 += x[6] * y[srcBLen - 5] */ acc2 += ((q15_t) x2 * c0); /* acc3 += x[7] * y[srcBLen - 5] */ acc3 += ((q15_t) x3 * c0); /* Reuse the present samples for the next MAC */ x0 = x1; x1 = x2; x2 = x3; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = (q7_t) (__SSAT(acc0 >> 7U, 8)); *pOut++ = (q7_t) (__SSAT(acc1 >> 7U, 8)); *pOut++ = (q7_t) (__SSAT(acc2 >> 7U, 8)); *pOut++ = (q7_t) (__SSAT(acc3 >> 7U, 8)); /* Increment the pointer pIn1 index, count by 4 */ count += 4U; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pSrc2; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize2 % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize2; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; while (k > 0U) { /* Reading two inputs of SrcA buffer and packing */ in1 = (q15_t) *px++; in2 = (q15_t) *px++; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* Reading two inputs of SrcB buffer and packing */ in1 = (q15_t) *py--; in2 = (q15_t) *py--; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* Perform the multiply-accumulate */ sum = __SMLAD(input1, input2, sum); /* Reading two inputs of SrcA buffer and packing */ in1 = (q15_t) *px++; in2 = (q15_t) *px++; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* Reading two inputs of SrcB buffer and packing */ in1 = (q15_t) *py--; in2 = (q15_t) *py--; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* Perform the multiply-accumulate */ sum = __SMLAD(input1, input2, sum); /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = srcBLen % 0x4U; #else /* Initialize blkCnt with number of samples */ k = srcBLen; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += ((q15_t) *px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); /* Increment the pointer pIn1 index, count by 1 */ count++; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pSrc2; /* Decrement the loop counter */ blkCnt--; } } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; while (k > 0U) { /* Perform the multiply-accumulate */ sum += ((q15_t) *px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); /* Increment the MAC count */ count++; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pSrc2; /* Decrement loop counter */ blkCnt--; } } /* -------------------------- * Initializations of stage3 * -------------------------*/ /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] */ /* In this stage the MAC operations are decreased by 1 for every iteration. The blockSize3 variable holds the number of MAC operations performed */ /* Working pointer of inputA */ pSrc1 = pIn1 + (srcALen - (srcBLen - 1U)); px = pSrc1; /* Working pointer of inputB */ pSrc2 = pIn2 + (srcBLen - 1U); py = pSrc2; /* ------------------- * Stage3 process * ------------------*/ while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = blockSize3 >> 2U; while (k > 0U) { /* Reading two inputs, x[srcALen - srcBLen + 1] and x[srcALen - srcBLen + 2] of SrcA buffer and packing */ in1 = (q15_t) *px++; in2 = (q15_t) *px++; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* Reading two inputs, y[srcBLen - 1] and y[srcBLen - 2] of SrcB buffer and packing */ in1 = (q15_t) *py--; in2 = (q15_t) *py--; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ sum = __SMLAD(input1, input2, sum); /* Reading two inputs, x[srcALen - srcBLen + 3] and x[srcALen - srcBLen + 4] of SrcA buffer and packing */ in1 = (q15_t) *px++; in2 = (q15_t) *px++; input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* Reading two inputs, y[srcBLen - 3] and y[srcBLen - 4] of SrcB buffer and packing */ in1 = (q15_t) *py--; in2 = (q15_t) *py--; input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ sum = __SMLAD(input1, input2, sum); /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = blockSize3 % 0x4U; #else /* Initialize blkCnt with number of samples */ k = blockSize3; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum += ((q15_t) *px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; py = pSrc2; /* Decrement loop counter */ blockSize3--; } #else /* alternate version for CM0_FAMILY */ const q7_t *pIn1 = pSrcA; /* InputA pointer */ const q7_t *pIn2 = pSrcB; /* InputB pointer */ q31_t sum; /* Accumulator */ uint32_t i, j; /* Loop counters */ /* Loop to calculate convolution for output length number of times */ for (i = 0U; i < (srcALen + srcBLen - 1U); i++) { /* Initialize sum with zero to carry out MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ for (j = 0U; j <= i; j++) { /* Check the array limitations */ if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ sum += ((q15_t) pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ pDst[i] = (q7_t) __SSAT((sum >> 7U), 8U); } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of Conv group */
20,530
C
28.28816
142
0.509888
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_decimate_fast_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_decimate_fast_q15.c * Description: Fast Q15 FIR Decimator * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_decimate @{ */ /** @brief Processing function for the Q15 FIR decimator (fast variant). @param[in] S points to an instance of the Q15 FIR decimator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of input samples to process per call @return none @par Scaling and Overflow Behavior This fast version uses a 32-bit accumulator with 2.30 format. The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around and distorts the result. In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits (log2 is read as log to the base 2). The 2.30 accumulator is then truncated to 2.15 format and saturated to yield the 1.15 result. @remark Refer to \ref arm_fir_decimate_q15() for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. Both the slow and the fast versions use the same instance structure. Use function \ref arm_fir_decimate_init_q15() to initialize the filter structure. */ #if defined (ARM_MATH_DSP) void arm_fir_decimate_fast_q15( const arm_fir_decimate_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCur; /* Points to the current sample of the state */ q15_t *px; /* Temporary pointer for state buffer */ const q15_t *pb; /* Temporary pointer for coefficient buffer */ q31_t x0, x1, c0; /* Temporary variables to hold state and coefficient values */ q31_t sum0; /* Accumulators */ q31_t acc0, acc1; q15_t *px0, *px1; uint32_t blkCntN3; uint32_t numTaps = S->numTaps; /* Number of taps */ uint32_t i, blkCnt, tapCnt, outBlockSize = blockSize / S->M; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q31_t c1; /* Temporary variables to hold state and coefficient values */ #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 2; blkCntN3 = outBlockSize - (2 * blkCnt); while (blkCnt > 0U) { /* Copy 2 * decimation factor number of new input samples into the state buffer */ i = S->M * 2; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulator to zero */ acc0 = 0; acc1 = 0; /* Initialize state pointer for all the samples */ px0 = pState; px1 = pState + S->M; /* Initialize coeff pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] and b[numTaps-2] coefficients */ c0 = read_q15x2_ia ((q15_t **) &pb); /* Read x[n-numTaps-1] and x[n-numTaps-2]sample */ x0 = read_q15x2_ia (&px0); x1 = read_q15x2_ia (&px1); /* Perform the multiply-accumulate */ acc0 = __SMLAD(x0, c0, acc0); acc1 = __SMLAD(x1, c0, acc1); /* Read the b[numTaps-3] and b[numTaps-4] coefficient */ c0 = read_q15x2_ia ((q15_t **) &pb); /* Read x[n-numTaps-2] and x[n-numTaps-3] sample */ x0 = read_q15x2_ia (&px0); x1 = read_q15x2_ia (&px1); /* Perform the multiply-accumulate */ acc0 = __SMLAD(x0, c0, acc0); acc1 = __SMLAD(x1, c0, acc1); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; /* Fetch state variables for acc0, acc1 */ x0 = *px0++; x1 = *px1++; /* Perform the multiply-accumulate */ acc0 = __SMLAD(x0, c0, acc0); acc1 = __SMLAD(x1, c0, acc1); /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M * 2; /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); *pDst++ = (q15_t) (__SSAT((acc1 >> 15), 16)); /* Decrement loop counter */ blkCnt--; } while (blkCntN3 > 0U) { /* Copy decimation factor number of new input samples into the state buffer */ i = S->M; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulator to zero */ sum0 = 0; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] and b[numTaps-2] coefficients */ c0 = read_q15x2_ia ((q15_t **) &pb); /* Read x[n-numTaps-1] and x[n-numTaps-2] sample */ x0 = read_q15x2_ia (&px); /* Read the b[numTaps-3] and b[numTaps-4] coefficients */ c1 = read_q15x2_ia ((q15_t **) &pb); /* Perform the multiply-accumulate */ sum0 = __SMLAD(x0, c0, sum0); /* Read x[n-numTaps-2] and x[n-numTaps-3] sample */ x0 = read_q15x2_ia (&px); /* Perform the multiply-accumulate */ sum0 = __SMLAD(x0, c1, sum0); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; /* Fetch 1 state variable */ x0 = *px++; /* Perform the multiply-accumulate */ sum0 = __SMLAD(x0, c0, sum0); /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M; /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ blkCntN3--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; i = (numTaps - 1U) >> 2U; /* copy data */ while (i > 0U) { write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); /* Decrement loop counter */ i--; } i = (numTaps - 1U) % 0x04U; /* Copy data */ while (i > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ i--; } } #else /* #if defined (ARM_MATH_DSP) */ void arm_fir_decimate_fast_q15( const arm_fir_decimate_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCur; /* Points to the current sample of the state */ q15_t *px; /* Temporary pointer for state buffer */ const q15_t *pb; /* Temporary pointer for coefficient buffer */ q15_t x0, x1, c0; /* Temporary variables to hold state and coefficient values */ q31_t sum0; /* Accumulators */ q31_t acc0, acc1; q15_t *px0, *px1; uint32_t blkCntN3; uint32_t numTaps = S->numTaps; /* Number of taps */ uint32_t i, blkCnt, tapCnt, outBlockSize = blockSize / S->M; /* Loop counters */ /* S->pState buffer contains previous frame (numTaps - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 2; blkCntN3 = outBlockSize - (2 * blkCnt); while (blkCnt > 0U) { /* Copy 2 * decimation factor number of new input samples into the state buffer */ i = S->M * 2; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulator to zero */ acc0 = 0; acc1 = 0; /* Initialize state pointer */ px0 = pState; px1 = pState + S->M; /* Initialize coeff pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the Read b[numTaps-1] coefficients */ c0 = *pb++; /* Read x[n-numTaps-1] for sample 0 and for sample 1 */ x0 = *px0++; x1 = *px1++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *pb++; /* Read x[n-numTaps-2] for sample 0 and sample 1 */ x0 = *px0++; x1 = *px1++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; /* Read the b[numTaps-3] coefficients */ c0 = *pb++; /* Read x[n-numTaps-3] for sample 0 and sample 1 */ x0 = *px0++; x1 = *px1++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *pb++; /* Read x[n-numTaps-4] for sample 0 and sample 1 */ x0 = *px0++; x1 = *px1++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; /* Decrement the loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; /* Fetch 1 state variable */ x0 = *px0++; x1 = *px1++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; /* Decrement the loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M * 2; /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); *pDst++ = (q15_t) (__SSAT((acc1 >> 15), 16)); /* Decrement loop counter */ blkCnt--; } while (blkCntN3 > 0U) { /* Copy decimation factor number of new input samples into the state buffer */ i = S->M; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulator to zero */ sum0 = 0; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; /* Read x[n-numTaps-1] sample */ x0 = *px++; /* Perform the multiply-accumulate */ sum0 += x0 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *pb++; /* Read x[n-numTaps-2] sample */ x0 = *px++; /* Perform the multiply-accumulate */ sum0 += x0 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *pb++; /* Read x[n-numTaps-3] sample */ x0 = *px++; /* Perform the multiply-accumulate */ sum0 += x0 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *pb++; /* Read x[n-numTaps-4] sample */ x0 = *px++; /* Perform the multiply-accumulate */ sum0 += x0 * c0; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; /* Fetch 1 state variable */ x0 = *px++; /* Perform the multiply-accumulate */ sum0 += x0 * c0; /* Decrement the loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M; /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ blkCntN3--; } /* Processing is complete. ** Now copy the last numTaps - 1 samples to the satrt of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; i = (numTaps - 1U) >> 2U; /* copy data */ while (i > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ i--; } i = (numTaps - 1U) % 0x04U; /* copy data */ while (i > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ i--; } } #endif /* #if defined (ARM_MATH_DSP) */ /** @} end of FIR_decimate group */
15,852
C
25.598993
164
0.552296
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_init_f32.c * Description: Floating-point Biquad cascade DirectFormI(DF1) filter initialization function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF1 @{ */ /** @brief Initialization function for the floating-point Biquad cascade filter. @param[in,out] S points to an instance of the floating-point Biquad cascade structure. @param[in] numStages number of 2nd order stages in the filter. @param[in] pCoeffs points to the filter coefficients. @param[in] pState points to the state buffer. @return none @par Coefficient and State Ordering The coefficients are stored in the array <code>pCoeffs</code> in the following order: <pre> {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} </pre> @par where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage, <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage, and so on. The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values. @par The <code>pState</code> is a pointer to state array. Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>. The state variables are arranged in the <code>pState</code> array as: <pre> {x[n-1], x[n-2], y[n-1], y[n-2]} </pre> The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. The state array has a total length of <code>4*numStages</code> values. The state variables are updated after each block of data is processed; the coefficients are untouched. */ void arm_biquad_cascade_df1_init_f32( arm_biquad_casd_df1_inst_f32 * S, uint8_t numStages, const float32_t * pCoeffs, float32_t * pState) { /* Assign filter stages */ S->numStages = numStages; /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(float32_t)); /* Assign state pointer */ S->pState = pState; } /** @} end of BiquadCascadeDF1 group */
3,354
C
35.467391
121
0.614788
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_fast_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_fast_q15.c * Description: Fast processing function for the Q15 Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF1 @{ */ /** @brief Processing function for the Q15 Biquad cascade filter (fast variant). @param[in] S points to an instance of the Q15 Biquad cascade structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process per call @return none @par Scaling and Overflow Behavior This fast version uses a 32-bit accumulator with 2.30 format. The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around and distorts the result. In order to avoid overflows completely the input signal must be scaled down by two bits and lie in the range [-0.25 +0.25). The 2.30 accumulator is then shifted by <code>postShift</code> bits and the result truncated to 1.15 format by discarding the low 16 bits. @remark Refer to \ref arm_biquad_cascade_df1_q15() for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. Both the slow and the fast versions use the same instance structure. Use the function \ref arm_biquad_cascade_df1_init_q15() to initialize the filter structure. */ void arm_biquad_cascade_df1_fast_q15( const arm_biquad_casd_df1_inst_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { const q15_t *pIn = pSrc; /* Source pointer */ q15_t *pOut = pDst; /* Destination pointer */ q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t acc; /* Accumulator */ q31_t in; /* Temporary variable to hold input value */ q31_t out; /* Temporary variable to hold output value */ q31_t b0; /* Temporary variable to hold bo value */ q31_t b1, a1; /* Filter coefficients */ q31_t state_in, state_out; /* Filter state variables */ int32_t shift = (int32_t) (15 - S->postShift); /* Post shift */ uint32_t sample, stage = S->numStages; /* Loop counters */ do { /* Read the b0 and 0 coefficients using SIMD */ b0 = read_q15x2_ia ((q15_t **) &pCoeffs); /* Read the b1 and b2 coefficients using SIMD */ b1 = read_q15x2_ia ((q15_t **) &pCoeffs); /* Read the a1 and a2 coefficients using SIMD */ a1 = read_q15x2_ia ((q15_t **) &pCoeffs); /* Read the input state values from the state buffer: x[n-1], x[n-2] */ state_in = read_q15x2_ia (&pState); /* Read the output state values from the state buffer: y[n-1], y[n-2] */ state_out = read_q15x2_da (&pState); #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 2 output values simultaneously. */ /* Variable acc hold output values that are being computed: * * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* Loop unrolling: Compute 2 outputs at a time */ sample = blockSize >> 1U; while (sample > 0U) { /* Read the input */ in = read_q15x2_ia ((q15_t **) &pIn); /* out = b0 * x[n] + 0 * 0 */ out = __SMUAD(b0, in); /* acc = b1 * x[n-1] + acc += b2 * x[n-2] + out */ acc = __SMLAD(b1, state_in, out); /* acc += a1 * y[n-1] + acc += a2 * y[n-2] */ acc = __SMLAD(a1, state_out, acc); /* The result is converted from 3.29 to 1.31 and then saturation is applied */ out = __SSAT((acc >> shift), 16); /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ #ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else state_in = __PKHBT(state_in >> 16, (in >> 16), 16); state_out = __PKHBT(state_out >> 16, (out), 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* out = b0 * x[n] + 0 * 0 */ out = __SMUADX(b0, in); /* acc0 = b1 * x[n-1] , acc0 += b2 * x[n-2] + out */ acc = __SMLAD(b1, state_in, out); /* acc += a1 * y[n-1] + acc += a2 * y[n-2] */ acc = __SMLAD(a1, state_out, acc); /* The result is converted from 3.29 to 1.31 and then saturation is applied */ out = __SSAT((acc >> shift), 16); /* Store the output in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pOut, __PKHBT(state_out, out, 16)); #else write_q15x2_ia (&pOut, __PKHBT(out, state_out >> 16, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ #ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in >> 16, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else state_in = __PKHBT(state_in >> 16, in, 16); state_out = __PKHBT(state_out >> 16, out, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = (blockSize & 0x1U); #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { /* Read the input */ in = *pIn++; /* out = b0 * x[n] + 0 * 0 */ #ifndef ARM_MATH_BIG_ENDIAN out = __SMUAD(b0, in); #else out = __SMUADX(b0, in); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* acc = b1 * x[n-1], acc += b2 * x[n-2] + out */ acc = __SMLAD(b1, state_in, out); /* acc += a1 * y[n-1] + acc += a2 * y[n-2] */ acc = __SMLAD(a1, state_out, acc); /* The result is converted from 3.29 to 1.31 and then saturation is applied */ out = __SSAT((acc >> shift), 16); /* Store the output in the destination buffer. */ *pOut++ = (q15_t) out; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ #ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else state_in = __PKHBT(state_in >> 16, in, 16); state_out = __PKHBT(state_out >> 16, out, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* decrement loop counter */ sample--; } /* The first stage goes from the input buffer to the output buffer. */ /* Subsequent (numStages - 1) occur in-place in the output buffer */ pIn = pDst; /* Reset the output pointer */ pOut = pDst; /* Store the updated state variables back into the state array */ write_q15x2_ia(&pState, state_in); write_q15x2_ia(&pState, state_out); /* Decrement loop counter */ stage--; } while (stage > 0U); } /** @} end of BiquadCascadeDF1 group */
9,312
C
36.103586
157
0.554768
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_q15.c * Description: Q15 FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR @{ */ /** @brief Processing function for the Q15 FIR filter. @param[in] S points to an instance of the Q15 FIR filter structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using a 64-bit internal accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. @remark Refer to \ref arm_fir_fast_q15() for a faster but less precise implementation of this function. */ void arm_fir_q15( const arm_fir_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCurnt; /* Points to the current sample of the state */ q15_t *px; /* Temporary pointer for state buffer */ const q15_t *pb; /* Temporary pointer for coefficient buffer */ q63_t acc0; /* Accumulators */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t tapCnt, blkCnt; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q63_t acc1, acc2, acc3; /* Accumulators */ q31_t x0, x1, x2, c0; /* Temporary variables to hold state and coefficient values */ #endif /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Typecast q15_t pointer to q31_t pointer for state reading in q31_t */ px = pState; /* Typecast q15_t pointer to q31_t pointer for coefficient reading in q31_t */ pb = pCoeffs; /* Read the first two samples from the state buffer: x[n-N], x[n-N-1] */ x0 = read_q15x2_ia (&px); /* Read the third and forth samples from the state buffer: x[n-N-2], x[n-N-3] */ x2 = read_q15x2_ia (&px); /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numTaps-(numTaps%4) coefficients. */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the first two coefficients using SIMD: b[N] and b[N-1] coefficients */ c0 = read_q15x2_ia ((q15_t **) &pb); /* acc0 += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ acc0 = __SMLALD(x0, c0, acc0); /* acc2 += b[N] * x[n-N-2] + b[N-1] * x[n-N-3] */ acc2 = __SMLALD(x2, c0, acc2); /* pack x[n-N-1] and x[n-N-2] */ #ifndef ARM_MATH_BIG_ENDIAN x1 = __PKHBT(x2, x0, 0); #else x1 = __PKHBT(x0, x2, 0); #endif /* Read state x[n-N-4], x[n-N-5] */ x0 = read_q15x2_ia (&px); /* acc1 += b[N] * x[n-N-1] + b[N-1] * x[n-N-2] */ acc1 = __SMLALDX(x1, c0, acc1); /* pack x[n-N-3] and x[n-N-4] */ #ifndef ARM_MATH_BIG_ENDIAN x1 = __PKHBT(x0, x2, 0); #else x1 = __PKHBT(x2, x0, 0); #endif /* acc3 += b[N] * x[n-N-3] + b[N-1] * x[n-N-4] */ acc3 = __SMLALDX(x1, c0, acc3); /* Read coefficients b[N-2], b[N-3] */ c0 = read_q15x2_ia ((q15_t **) &pb); /* acc0 += b[N-2] * x[n-N-2] + b[N-3] * x[n-N-3] */ acc0 = __SMLALD(x2, c0, acc0); /* Read state x[n-N-6], x[n-N-7] with offset */ x2 = read_q15x2_ia (&px); /* acc2 += b[N-2] * x[n-N-4] + b[N-3] * x[n-N-5] */ acc2 = __SMLALD(x0, c0, acc2); /* acc1 += b[N-2] * x[n-N-3] + b[N-3] * x[n-N-4] */ acc1 = __SMLALDX(x1, c0, acc1); /* pack x[n-N-5] and x[n-N-6] */ #ifndef ARM_MATH_BIG_ENDIAN x1 = __PKHBT(x2, x0, 0); #else x1 = __PKHBT(x0, x2, 0); #endif /* acc3 += b[N-2] * x[n-N-5] + b[N-3] * x[n-N-6] */ acc3 = __SMLALDX(x1, c0, acc3); /* Decrement tap count */ tapCnt--; } /* If the filter length is not a multiple of 4, compute the remaining filter taps. This is always be 2 taps since the filter length is even. */ if ((numTaps & 0x3U) != 0U) { /* Read last two coefficients */ c0 = read_q15x2_ia ((q15_t **) &pb); /* Perform the multiply-accumulates */ acc0 = __SMLALD(x0, c0, acc0); acc2 = __SMLALD(x2, c0, acc2); /* pack state variables */ #ifndef ARM_MATH_BIG_ENDIAN x1 = __PKHBT(x2, x0, 0); #else x1 = __PKHBT(x0, x2, 0); #endif /* Read last state variables */ x0 = read_q15x2 (px); /* Perform the multiply-accumulates */ acc1 = __SMLALDX(x1, c0, acc1); /* pack state variables */ #ifndef ARM_MATH_BIG_ENDIAN x1 = __PKHBT(x0, x2, 0); #else x1 = __PKHBT(x2, x0, 0); #endif /* Perform the multiply-accumulates */ acc3 = __SMLALDX(x1, c0, acc3); } /* The results in the 4 accumulators are in 2.30 format. Convert to 1.15 with saturation. Then store the 4 outputs in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); #else write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 4U; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining output samples */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of taps */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy two samples into state buffer */ *pStateCurnt++ = *pSrc++; /* Set the accumulator to zero */ acc0 = 0; /* Use SIMD to hold states and coefficients */ px = pState; pb = pCoeffs; tapCnt = numTaps >> 1U; do { acc0 += (q31_t) *px++ * *pb++; acc0 += (q31_t) *px++ * *pb++; tapCnt--; } while (tapCnt > 0U); /* The result is in 2.30 format. Convert to 1.15 with saturation. Then store the output in the destination buffer. */ *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Calculate remaining number of copies */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of FIR group */
10,497
C
30.525525
144
0.557397
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_correlate_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_correlate_f32.c * Description: Correlation of floating-point sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup Corr Correlation Correlation is a mathematical operation that is similar to convolution. As with convolution, correlation uses two signals to produce a third signal. The underlying algorithms in correlation and convolution are identical except that one of the inputs is flipped in convolution. Correlation is commonly used to measure the similarity between two signals. It has applications in pattern recognition, cryptanalysis, and searching. The CMSIS library provides correlation functions for Q7, Q15, Q31 and floating-point data types. Fast versions of the Q15 and Q31 functions are also provided. @par Algorithm Let <code>a[n]</code> and <code>b[n]</code> be sequences of length <code>srcALen</code> and <code>srcBLen</code> samples respectively. The convolution of the two signals is denoted by <pre> c[n] = a[n] * b[n] </pre> In correlation, one of the signals is flipped in time <pre> c[n] = a[n] * b[-n] </pre> @par and this is mathematically defined as \image html CorrelateEquation.gif @par The <code>pSrcA</code> points to the first input vector of length <code>srcALen</code> and <code>pSrcB</code> points to the second input vector of length <code>srcBLen</code>. The result <code>c[n]</code> is of length <code>2 * max(srcALen, srcBLen) - 1</code> and is defined over the interval <code>n=0, 1, 2, ..., (2 * max(srcALen, srcBLen) - 2)</code>. The output result is written to <code>pDst</code> and the calling function must allocate <code>2 * max(srcALen, srcBLen) - 1</code> words for the result. @note The <code>pDst</code> should be initialized to all zeros before being used. @par Fixed-Point Behavior Correlation requires summing up a large number of intermediate products. As such, the Q7, Q15, and Q31 functions run a risk of overflow and saturation. Refer to the function specific documentation below for further details of the particular algorithm used. @par Fast Versions Fast versions are supported for Q31 and Q15. Cycles for Fast versions are less compared to Q31 and Q15 of correlate and the design requires the input signals should be scaled down to avoid intermediate overflows. @par Opt Versions Opt versions are supported for Q15 and Q7. Design uses internal scratch buffer for getting good optimisation. These versions are optimised in cycles and consumes more memory (Scratch memory) compared to Q15 and Q7 versions of correlate */ /** @addtogroup Corr @{ */ /** @brief Correlation of floating-point sequences. @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1. @return none */ void arm_correlate_f32( const float32_t * pSrcA, uint32_t srcALen, const float32_t * pSrcB, uint32_t srcBLen, float32_t * pDst) { #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) const float32_t *pIn1; /* InputA pointer */ const float32_t *pIn2; /* InputB pointer */ float32_t *pOut = pDst; /* Output pointer */ const float32_t *px; /* Intermediate inputA pointer */ const float32_t *py; /* Intermediate inputB pointer */ const float32_t *pSrc1; float32_t sum; uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ uint32_t j, k, count, blkCnt; /* Loop counters */ uint32_t outBlockSize; /* Loop counter */ int32_t inc = 1; /* Destination address modifier */ #if defined (ARM_MATH_LOOPUNROLL) || defined (ARM_MATH_NEON) float32_t acc0, acc1, acc2, acc3; /* Accumulators */ float32_t x0, x1, x2, x3, c0; /* temporary variables for holding input and coefficient values */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ /* But CORR(x, y) is reverse of CORR(y, x) */ /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */ /* and the destination pointer modifier, inc is set to -1 */ /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */ /* But to improve the performance, * we assume zeroes in the output instead of zero padding either of the the inputs*/ /* If srcALen > srcBLen, * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */ /* If srcALen < srcBLen, * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */ if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; /* Number of output samples is calculated */ outBlockSize = (2U * srcALen) - 1U; /* When srcALen > srcBLen, zero padding has to be done to srcB * to make their lengths equal. * Instead, (outBlockSize - (srcALen + srcBLen - 1)) * number of output samples are made zero */ j = outBlockSize - (srcALen + (srcBLen - 1U)); /* Updating the pointer position to non zero value */ pOut += j; } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; /* Initialization of inputB pointer */ pIn2 = pSrcA; /* srcBLen is always considered as shorter or equal to srcALen */ j = srcBLen; srcBLen = srcALen; srcALen = j; /* CORR(x, y) = Reverse order(CORR(y, x)) */ /* Hence set the destination pointer to point to the last output sample */ pOut = pDst + ((srcALen + srcBLen) - 2U); /* Destination address modifier is set to -1 */ inc = -1; } /* The function is internally * divided into three stages according to the number of multiplications that has to be * taken place between inputA samples and inputB samples. In the first stage of the * algorithm, the multiplications increase by one for every iteration. * In the second stage of the algorithm, srcBLen number of multiplications are done. * In the third stage of the algorithm, the multiplications decrease by one * for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ blockSize1 = srcBLen - 1U; blockSize2 = srcALen - (srcBLen - 1U); blockSize3 = blockSize1; /* -------------------------- * Initializations of stage1 * -------------------------*/ /* sum = x[0] * y[srcBlen - 1] * sum = x[0] * y[srcBlen-2] + x[1] * y[srcBlen - 1] * .... * sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen - 1] * y[srcBLen - 1] */ /* In this stage the MAC operations are increased by 1 for every iteration. The count variable holds the number of MAC operations performed */ count = 1U; /* Working pointer of inputA */ px = pIn1; /* Working pointer of inputB */ pSrc1 = pIn2 + (srcBLen - 1U); py = pSrc1; /* ------------------------ * Stage1 process * ----------------------*/ /* The first stage starts here */ while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; #if defined(ARM_MATH_NEON) float32x4_t x,y; float32x4_t res = vdupq_n_f32(0) ; float32x2_t accum = vdup_n_f32(0); while (k > 0U) { x = vld1q_f32(px); y = vld1q_f32(py); res = vmlaq_f32(res,x, y); px += 4; py += 4; /* Decrement the loop counter */ k--; } accum = vpadd_f32(vget_low_f32(res), vget_high_f32(res)); sum += accum[0] + accum[1]; k = count & 0x3; #else /* First part of the processing with loop unrolling. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ while (k > 0U) { /* x[0] * y[srcBLen - 4] */ sum += *px++ * *py++; /* x[1] * y[srcBLen - 3] */ sum += *px++ * *py++; /* x[2] * y[srcBLen - 2] */ sum += *px++ * *py++; /* x[3] * y[srcBLen - 1] */ sum += *px++ * *py++; /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = count % 0x4U; #endif /* #if defined(ARM_MATH_NEON) */ #else /* Initialize k with number of samples */ k = count; #endif /* #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) */ while (k > 0U) { /* Perform the multiply-accumulate */ /* x[0] * y[srcBLen - 1] */ sum += *px++ * *py++; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut = sum; /* Destination pointer is updated according to the address modifier, inc */ pOut += inc; /* Update the inputA and inputB pointers for next MAC calculation */ py = pSrc1 - count; px = pIn1; /* Increment MAC count */ count++; /* Decrement loop counter */ blockSize1--; } /* -------------------------- * Initializations of stage2 * ------------------------*/ /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1] * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1] * .... * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1] */ /* Working pointer of inputA */ px = pIn1; /* Working pointer of inputB */ py = pIn2; /* count is index by which the pointer pIn1 to be incremented */ count = 0U; /* ------------------- * Stage2 process * ------------------*/ /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. * So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ if (srcBLen >= 4U) { #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize2 >> 2U; #if defined(ARM_MATH_NEON) float32x4_t c; float32x4_t x1v; float32x4_t x2v; uint32x4_t x1v_u; uint32x4_t x2v_u; float32x4_t x; uint32x4_t x_u; float32x4_t res = vdupq_n_f32(0) ; #endif /* #if defined(ARM_MATH_NEON) */ while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0.0f; acc1 = 0.0f; acc2 = 0.0f; acc3 = 0.0f; #if defined(ARM_MATH_NEON) /* Compute 4 MACs simultaneously. */ k = srcBLen >> 2U; res = vdupq_n_f32(0) ; x1v = vld1q_f32(px); px += 4; do { x2v = vld1q_f32(px); c = vld1q_f32(py); py += 4; x = x1v; res = vmlaq_n_f32(res,x,c[0]); x = vextq_f32(x1v,x2v,1); res = vmlaq_n_f32(res,x,c[1]); x = vextq_f32(x1v,x2v,2); res = vmlaq_n_f32(res,x,c[2]); x = vextq_f32(x1v,x2v,3); res = vmlaq_n_f32(res,x,c[3]); x1v = x2v; px+=4; x2v = vld1q_f32(px); } while (--k); /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen & 0x3; while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *(py++); res = vmlaq_n_f32(res,x1v,c0); /* Reuse the present samples for the next MAC */ x1v[0] = x1v[1]; x1v[1] = x1v[2]; x1v[2] = x1v[3]; x1v[3] = *(px++); /* Decrement the loop counter */ k--; } px-=1; acc0 = res[0]; acc1 = res[1]; acc2 = res[2]; acc3 = res[3]; #else /* read x[0], x[1], x[2] samples */ x0 = *px++; x1 = *px++; x2 = *px++; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; /* First part of the processing with loop unrolling. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ do { /* Read y[0] sample */ c0 = *(py++); /* Read x[3] sample */ x3 = *(px++); /* Perform the multiply-accumulate */ /* acc0 += x[0] * y[0] */ acc0 += x0 * c0; /* acc1 += x[1] * y[0] */ acc1 += x1 * c0; /* acc2 += x[2] * y[0] */ acc2 += x2 * c0; /* acc3 += x[3] * y[0] */ acc3 += x3 * c0; /* Read y[1] sample */ c0 = *(py++); /* Read x[4] sample */ x0 = *(px++); /* Perform the multiply-accumulate */ /* acc0 += x[1] * y[1] */ acc0 += x1 * c0; /* acc1 += x[2] * y[1] */ acc1 += x2 * c0; /* acc2 += x[3] * y[1] */ acc2 += x3 * c0; /* acc3 += x[4] * y[1] */ acc3 += x0 * c0; /* Read y[2] sample */ c0 = *(py++); /* Read x[5] sample */ x1 = *(px++); /* Perform the multiply-accumulate */ /* acc0 += x[2] * y[2] */ acc0 += x2 * c0; /* acc1 += x[3] * y[2] */ acc1 += x3 * c0; /* acc2 += x[4] * y[2] */ acc2 += x0 * c0; /* acc3 += x[5] * y[2] */ acc3 += x1 * c0; /* Read y[3] sample */ c0 = *(py++); /* Read x[6] sample */ x2 = *(px++); /* Perform the multiply-accumulate */ /* acc0 += x[3] * y[3] */ acc0 += x3 * c0; /* acc1 += x[4] * y[3] */ acc1 += x0 * c0; /* acc2 += x[5] * y[3] */ acc2 += x1 * c0; /* acc3 += x[6] * y[3] */ acc3 += x2 * c0; } while (--k); /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; while (k > 0U) { /* Read y[4] sample */ c0 = *(py++); /* Read x[7] sample */ x3 = *(px++); /* Perform the multiply-accumulate */ /* acc0 += x[4] * y[4] */ acc0 += x0 * c0; /* acc1 += x[5] * y[4] */ acc1 += x1 * c0; /* acc2 += x[6] * y[4] */ acc2 += x2 * c0; /* acc3 += x[7] * y[4] */ acc3 += x3 * c0; /* Reuse the present samples for the next MAC */ x0 = x1; x1 = x2; x2 = x3; /* Decrement the loop counter */ k--; } #endif /* #if defined(ARM_MATH_NEON) */ /* Store the result in the accumulator in the destination buffer. */ *pOut = acc0; /* Destination pointer is updated according to the address modifier, inc */ pOut += inc; *pOut = acc1; pOut += inc; *pOut = acc2; pOut += inc; *pOut = acc3; pOut += inc; /* Increment the pointer pIn1 index, count by 4 */ count += 4U; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pIn2; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize2 % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize2; #endif /* #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) */ while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; #if defined(ARM_MATH_NEON) float32x4_t x,y; float32x4_t res = vdupq_n_f32(0) ; float32x2_t accum = vdup_n_f32(0); while (k > 0U) { x = vld1q_f32(px); y = vld1q_f32(py); res = vmlaq_f32(res,x, y); px += 4; py += 4; /* Decrement the loop counter */ k--; } accum = vpadd_f32(vget_low_f32(res), vget_high_f32(res)); sum += accum[0] + accum[1]; #else /* First part of the processing with loop unrolling. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py++; sum += *px++ * *py++; sum += *px++ * *py++; sum += *px++ * *py++; /* Decrement loop counter */ k--; } #endif /* #if defined(ARM_MATH_NEON) */ /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; #else /* Initialize blkCnt with number of samples */ k = srcBLen; #endif /* #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py++; /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut = sum; /* Destination pointer is updated according to the address modifier, inc */ pOut += inc; /* Increment the pointer pIn1 index, count by 1 */ count++; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pIn2; /* Decrement the loop counter */ blkCnt--; } } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; /* Loop over srcBLen */ k = srcBLen; while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py++; /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut = sum; /* Destination pointer is updated according to the address modifier, inc */ pOut += inc; /* Increment the pointer pIn1 index, count by 1 */ count++; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pIn2; /* Decrement the loop counter */ blkCnt--; } } /* -------------------------- * Initializations of stage3 * -------------------------*/ /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1] * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1] * .... * sum += x[srcALen-2] * y[0] + x[srcALen-1] * y[1] * sum += x[srcALen-1] * y[0] */ /* In this stage the MAC operations are decreased by 1 for every iteration. The count variable holds the number of MAC operations performed */ count = srcBLen - 1U; /* Working pointer of inputA */ pSrc1 = pIn1 + (srcALen - (srcBLen - 1U)); px = pSrc1; /* Working pointer of inputB */ py = pIn2; /* ------------------- * Stage3 process * ------------------*/ while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; #if defined(ARM_MATH_NEON) float32x4_t x,y; float32x4_t res = vdupq_n_f32(0) ; float32x2_t accum = vdup_n_f32(0); while (k > 0U) { x = vld1q_f32(px); y = vld1q_f32(py); res = vmlaq_f32(res,x, y); px += 4; py += 4; /* Decrement the loop counter */ k--; } accum = vpadd_f32(vget_low_f32(res), vget_high_f32(res)); sum += accum[0] + accum[1]; #else /* First part of the processing with loop unrolling. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen - srcBLen + 4] * y[3] */ sum += *px++ * *py++; /* sum += x[srcALen - srcBLen + 3] * y[2] */ sum += *px++ * *py++; /* sum += x[srcALen - srcBLen + 2] * y[1] */ sum += *px++ * *py++; /* sum += x[srcALen - srcBLen + 1] * y[0] */ sum += *px++ * *py++; /* Decrement loop counter */ k--; } #endif /* #if defined (ARM_MATH_NEON) */ /* Loop unrolling: Compute remaining outputs */ k = count % 0x4U; #else /* Initialize blkCnt with number of samples */ k = count; #endif /* #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py++; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut = sum; /* Destination pointer is updated according to the address modifier, inc */ pOut += inc; /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; py = pIn2; /* Decrement MAC count */ count--; /* Decrement the loop counter */ blockSize3--; } #else /* alternate version for CM0_FAMILY */ const float32_t *pIn1 = pSrcA; /* inputA pointer */ const float32_t *pIn2 = pSrcB + (srcBLen - 1U); /* inputB pointer */ float32_t sum; /* Accumulator */ uint32_t i = 0U, j; /* Loop counters */ uint32_t inv = 0U; /* Reverse order flag */ uint32_t tot = 0U; /* Length */ /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ /* But CORR(x, y) is reverse of CORR(y, x) */ /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */ /* and a varaible, inv is set to 1 */ /* If lengths are not equal then zero pad has to be done to make the two * inputs of same length. But to improve the performance, we assume zeroes * in the output instead of zero padding either of the the inputs*/ /* If srcALen > srcBLen, (srcALen - srcBLen) zeroes has to included in the * starting of the output buffer */ /* If srcALen < srcBLen, (srcALen - srcBLen) zeroes has to included in the * ending of the output buffer */ /* Once the zero padding is done the remaining of the output is calcualted * using convolution but with the shorter signal time shifted. */ /* Calculate the length of the remaining sequence */ tot = ((srcALen + srcBLen) - 2U); if (srcALen > srcBLen) { /* Calculating the number of zeros to be padded to the output */ j = srcALen - srcBLen; /* Initialise the pointer after zero padding */ pDst += j; } else if (srcALen < srcBLen) { /* Initialization to inputB pointer */ pIn1 = pSrcB; /* Initialization to the end of inputA pointer */ pIn2 = pSrcA + (srcALen - 1U); /* Initialisation of the pointer after zero padding */ pDst = pDst + tot; /* Swapping the lengths */ j = srcALen; srcALen = srcBLen; srcBLen = j; /* Setting the reverse flag */ inv = 1; } /* Loop to calculate convolution for output length number of times */ for (i = 0U; i <= tot; i++) { /* Initialize sum with zero to carry out MAC operations */ sum = 0.0f; /* Loop to perform MAC operations according to convolution equation */ for (j = 0U; j <= i; j++) { /* Check the array limitations */ if ((((i - j) < srcBLen) && (j < srcALen))) { /* z[i] += x[i-j] * y[j] */ sum += pIn1[j] * pIn2[-((int32_t) i - j)]; } } /* Store the output in the destination buffer */ if (inv == 1) *pDst-- = sum; else *pDst++ = sum; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of Corr group */
25,889
C
27.959732
198
0.546294
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_q7.c * Description: Q7 FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR @{ */ /** @brief Processing function for Q7 FIR filter. @param[in] S points to an instance of the Q7 FIR filter structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using a 32-bit internal accumulator. Both coefficients and state variables are represented in 1.7 format and multiplications yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. The accumulator is converted to 18.7 format by discarding the low 7 bits. Finally, the result is truncated to 1.7 format. */ void arm_fir_q7( const arm_fir_instance_q7 * S, const q7_t * pSrc, q7_t * pDst, uint32_t blockSize) { q7_t *pState = S->pState; /* State pointer */ const q7_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q7_t *pStateCurnt; /* Points to the current sample of the state */ q7_t *px; /* Temporary pointer for state buffer */ const q7_t *pb; /* Temporary pointer for coefficient buffer */ q31_t acc0; /* Accumulators */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q31_t acc1, acc2, acc3; /* Accumulators */ q7_t x0, x1, x2, x3, c0; /* Temporary variables to hold state */ #endif /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Initialize state pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Read the first 3 samples from the state buffer: * x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2] */ x0 = *px++; x1 = *px++; x2 = *px++; /* Loop unrolling. Process 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numTaps-4 coefficients. */ while (tapCnt > 0U) { /* Read the b[numTaps] coefficient */ c0 = *pb; /* Read x[n-numTaps-3] sample */ x3 = *px; /* acc0 += b[numTaps] * x[n-numTaps] */ acc0 += ((q15_t) x0 * c0); /* acc1 += b[numTaps] * x[n-numTaps-1] */ acc1 += ((q15_t) x1 * c0); /* acc2 += b[numTaps] * x[n-numTaps-2] */ acc2 += ((q15_t) x2 * c0); /* acc3 += b[numTaps] * x[n-numTaps-3] */ acc3 += ((q15_t) x3 * c0); /* Read the b[numTaps-1] coefficient */ c0 = *(pb + 1U); /* Read x[n-numTaps-4] sample */ x0 = *(px + 1U); /* Perform the multiply-accumulates */ acc0 += ((q15_t) x1 * c0); acc1 += ((q15_t) x2 * c0); acc2 += ((q15_t) x3 * c0); acc3 += ((q15_t) x0 * c0); /* Read the b[numTaps-2] coefficient */ c0 = *(pb + 2U); /* Read x[n-numTaps-5] sample */ x1 = *(px + 2U); /* Perform the multiply-accumulates */ acc0 += ((q15_t) x2 * c0); acc1 += ((q15_t) x3 * c0); acc2 += ((q15_t) x0 * c0); acc3 += ((q15_t) x1 * c0); /* Read the b[numTaps-3] coefficients */ c0 = *(pb + 3U); /* Read x[n-numTaps-6] sample */ x2 = *(px + 3U); /* Perform the multiply-accumulates */ acc0 += ((q15_t) x3 * c0); acc1 += ((q15_t) x0 * c0); acc2 += ((q15_t) x1 * c0); acc3 += ((q15_t) x2 * c0); /* update coefficient pointer */ pb += 4U; px += 4U; /* Decrement loop counter */ tapCnt--; } /* If the filter length is not a multiple of 4, compute the remaining filter taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch 1 state variable */ x3 = *(px++); /* Perform the multiply-accumulates */ acc0 += ((q15_t) x0 * c0); acc1 += ((q15_t) x1 * c0); acc2 += ((q15_t) x2 * c0); acc3 += ((q15_t) x3 * c0); /* Reuse the present sample states for next sample */ x0 = x1; x1 = x2; x2 = x3; /* Decrement loop counter */ tapCnt--; } /* The results in the 4 accumulators are in 2.62 format. Convert to 1.31 Then store the 4 outputs in the destination buffer. */ acc0 = __SSAT((acc0 >> 7U), 8); *pDst++ = acc0; acc1 = __SSAT((acc1 >> 7U), 8); *pDst++ = acc1; acc2 = __SSAT((acc2 >> 7U), 8); *pDst++ = acc2; acc3 = __SSAT((acc3 >> 7U), 8); *pDst++ = acc3; /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 4U; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining output samples */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of taps */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; /* Set the accumulator to zero */ acc0 = 0; /* Initialize state pointer */ px = pState; /* Initialize Coefficient pointer */ pb = pCoeffs; i = numTaps; /* Perform the multiply-accumulates */ do { acc0 += (q15_t) * (px++) * (*(pb++)); i--; } while (i > 0U); /* The result is in 2.14 format. Convert to 1.7 Then store the output in the destination buffer. */ *pDst++ = __SSAT((acc0 >> 7U), 8); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Calculate remaining number of copies */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ tapCnt--; } } /** @} end of FIR group */
9,486
C
28.280864
144
0.544697
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_sparse_q7.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_sparse_q7.c * Description: Q7 sparse FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_Sparse @{ */ /** @brief Processing function for the Q7 sparse FIR filter. @param[in] S points to an instance of the Q7 sparse FIR structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @param[in] pScratchOut points to a temporary buffer of size blockSize @param[in] blockSize number of input samples to process @return none @par Scaling and Overflow Behavior The function is implemented using a 32-bit internal accumulator. Both coefficients and state variables are represented in 1.7 format and multiplications yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. The accumulator is then converted to 18.7 format by discarding the low 7 bits. Finally, the result is truncated to 1.7 format. */ void arm_fir_sparse_q7( arm_fir_sparse_instance_q7 * S, const q7_t * pSrc, q7_t * pDst, q7_t * pScratchIn, q31_t * pScratchOut, uint32_t blockSize) { q7_t *pState = S->pState; /* State pointer */ const q7_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q7_t *px; /* Scratch buffer pointer */ q7_t *py = pState; /* Temporary pointers for state buffer */ q7_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ q7_t *pOut = pDst; /* Destination pointer */ int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ uint32_t delaySize = S->maxDelay + blockSize; /* state length */ uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ int32_t readIndex; /* Read index of the state buffer */ uint32_t tapCnt, blkCnt; /* loop counters */ q31_t *pScr2 = pScratchOut; /* Working pointer for scratch buffer of output values */ q31_t in; q7_t coeff = *pCoeffs++; /* Read the coefficient value */ #if defined (ARM_MATH_LOOPUNROLL) q7_t in1, in2, in3, in4; #endif /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ arm_circularWrite_q7(py, (int32_t) delaySize, &S->stateIndex, 1, pSrc, 1, blockSize); /* Loop over the number of taps. */ tapCnt = numTaps; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_q7(py, (int32_t) delaySize, &readIndex, 1, pb, pb, (int32_t) blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform multiplication and store in the scratch buffer */ *pScratchOut++ = ((q31_t) *px++ * coeff); *pScratchOut++ = ((q31_t) *px++ * coeff); *pScratchOut++ = ((q31_t) *px++ * coeff); *pScratchOut++ = ((q31_t) *px++ * coeff); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiplication and store in the scratch buffer */ *pScratchOut++ = ((q31_t) *px++ * coeff); /* Decrement loop counter */ blkCnt--; } /* Load the coefficient value and * increment the coefficient buffer for the next set of state values */ coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Loop over the number of taps. */ tapCnt = (uint32_t) numTaps - 2U; while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_q7(py, (int32_t) delaySize, &readIndex, 1, pb, pb, (int32_t) blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ in = *pScratchOut + ((q31_t) * px++ * coeff); *pScratchOut++ = in; in = *pScratchOut + ((q31_t) * px++ * coeff); *pScratchOut++ = in; in = *pScratchOut + ((q31_t) * px++ * coeff); *pScratchOut++ = in; in = *pScratchOut + ((q31_t) * px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ in = *pScratchOut + ((q31_t) *px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ blkCnt--; } /* Load the coefficient value and * increment the coefficient buffer for the next set of state values */ coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Decrement loop counter */ tapCnt--; } /* Compute last tap without the final read of pTapDelay */ /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_q7(py, (int32_t) delaySize, &readIndex, 1, pb, pb, (int32_t) blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ in = *pScratchOut + ((q31_t) *px++ * coeff); *pScratchOut++ = in; in = *pScratchOut + ((q31_t) *px++ * coeff); *pScratchOut++ = in; in = *pScratchOut + ((q31_t) *px++ * coeff); *pScratchOut++ = in; in = *pScratchOut + ((q31_t) *px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ in = *pScratchOut + ((q31_t) *px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ blkCnt--; } /* All the output values are in pScratchOut buffer. Convert them into 1.15 format, saturate and store in the destination buffer. */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { in1 = (q7_t) __SSAT(*pScr2++ >> 7, 8); in2 = (q7_t) __SSAT(*pScr2++ >> 7, 8); in3 = (q7_t) __SSAT(*pScr2++ >> 7, 8); in4 = (q7_t) __SSAT(*pScr2++ >> 7, 8); write_q7x4_ia (&pOut, __PACKq7(in1, in2, in3, in4)); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { *pOut++ = (q7_t) __SSAT(*pScr2++ >> 7, 8); /* Decrement loop counter */ blkCnt--; } } /** @} end of FIR_Sparse group */
10,316
C
29.166667
144
0.592284
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_iir_lattice_init_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_iir_lattice_init_q15.c * Description: Q15 IIR lattice filter initialization function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup IIR_Lattice @{ */ /** @brief Initialization function for the Q15 IIR lattice filter. @param[in] S points to an instance of the Q15 IIR lattice structure @param[in] numStages number of stages in the filter @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1 @param[in] pState points to state buffer. The array is of length numStages+blockSize @param[in] blockSize number of samples to process @return none */ void arm_iir_lattice_init_q15( arm_iir_lattice_instance_q15 * S, uint16_t numStages, q15_t * pkCoeffs, q15_t * pvCoeffs, q15_t * pState, uint32_t blockSize) { /* Assign filter taps */ S->numStages = numStages; /* Assign reflection coefficient pointer */ S->pkCoeffs = pkCoeffs; /* Assign ladder coefficient pointer */ S->pvCoeffs = pvCoeffs; /* Clear state buffer and size is always blockSize + numStages */ memset(pState, 0, (numStages + blockSize) * sizeof(q15_t)); /* Assign state pointer */ S->pState = pState; } /** @} end of IIR_Lattice group */
2,325
C
28.820512
98
0.650753
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_conv_partial_opt_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_conv_partial_opt_q15.c * Description: Partial convolution of Q15 sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup PartialConv @{ */ /** @brief Partial convolution of Q15 sequences. @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the location where the output result is written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] @remark Refer to \ref arm_conv_partial_fast_q15() for a faster but less precise version of this function. */ arm_status arm_conv_partial_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex, uint32_t numPoints, q15_t * pScratch1, q15_t * pScratch2) { q15_t *pOut = pDst; /* Output pointer */ q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ q63_t acc0; /* Accumulator */ q31_t x1; /* Temporary variables to hold state and coefficient values */ q31_t y1; /* State variables */ const q15_t *pIn1; /* InputA pointer */ const q15_t *pIn2; /* InputB pointer */ const q15_t *px; /* Intermediate inputA pointer */ q15_t *py; /* Intermediate inputB pointer */ uint32_t j, k, blkCnt; /* Loop counter */ uint32_t tapCnt; /* Loop count */ arm_status status; /* Status variable */ #if defined (ARM_MATH_LOOPUNROLL) q63_t acc1, acc2, acc3; /* Accumulator */ q31_t x2, x3; /* Temporary variables to hold state and coefficient values */ q31_t y2; /* State variables */ #endif /* Check for range of output samples to be calculated */ if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; /* Initialization of inputB pointer */ pIn2 = pSrcA; /* srcBLen is always considered as shorter or equal to srcALen */ j = srcBLen; srcBLen = srcALen; srcALen = j; } /* Temporary pointer for scratch2 */ py = pScratch2; /* pointer to take end of scratch2 buffer */ pScr2 = pScratch2 + srcBLen - 1; /* points to smaller length sequence */ px = pIn2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; /* Copy smaller length input sequence in reverse order into second scratch buffer */ while (k > 0U) { /* copy second buffer in reversal manner */ *pScr2-- = *px++; *pScr2-- = *px++; *pScr2-- = *px++; *pScr2-- = *px++; /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = srcBLen % 0x4U; #else /* Initialize k with number of samples */ k = srcBLen; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ *pScr2-- = *px++; /* Decrement loop counter */ k--; } /* Initialze temporary scratch pointer */ pScr1 = pScratch1; /* Assuming scratch1 buffer is aligned by 32-bit */ /* Fill (srcBLen - 1U) zeros in scratch buffer */ arm_fill_q15(0, pScr1, (srcBLen - 1U)); /* Update temporary scratch pointer */ pScr1 += (srcBLen - 1U); /* Copy bigger length sequence(srcALen) samples in scratch1 buffer */ /* Copy (srcALen) samples in scratch buffer */ arm_copy_q15(pIn1, pScr1, srcALen); /* Update pointers */ pScr1 += srcALen; /* Fill (srcBLen - 1U) zeros at end of scratch buffer */ arm_fill_q15(0, pScr1, (srcBLen - 1U)); /* Update pointer */ pScr1 += (srcBLen - 1U); /* Initialization of pIn2 pointer */ pIn2 = py; pScratch1 += firstIndex; pOut = pDst + firstIndex; /* Actual convolution process starts here */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (numPoints) >> 2; while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; /* Clear Accumlators */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Read two samples from scratch1 buffer */ x1 = read_q15x2_ia (&pScr1); /* Read next two samples from scratch1 buffer */ x2 = read_q15x2_ia (&pScr1); tapCnt = (srcBLen) >> 2U; while (tapCnt > 0U) { /* Read four samples from smaller buffer */ y1 = read_q15x2_ia ((q15_t **) &pIn2); y2 = read_q15x2_ia ((q15_t **) &pIn2); /* multiply and accumlate */ acc0 = __SMLALD(x1, y1, acc0); acc2 = __SMLALD(x2, y1, acc2); /* pack input data */ #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); #else x3 = __PKHBT(x1, x2, 0); #endif /* multiply and accumlate */ acc1 = __SMLALDX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ x1 = read_q15x2_ia (&pScr1); /* multiply and accumlate */ acc0 = __SMLALD(x2, y2, acc0); acc2 = __SMLALD(x1, y2, acc2); /* pack input data */ #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x1, x2, 0); #else x3 = __PKHBT(x2, x1, 0); #endif acc3 = __SMLALDX(x3, y1, acc3); acc1 = __SMLALDX(x3, y2, acc1); x2 = read_q15x2_ia (&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); #else x3 = __PKHBT(x1, x2, 0); #endif acc3 = __SMLALDX(x3, y2, acc3); /* Decrement loop counter */ tapCnt--; } /* Update scratch pointer for remaining samples of smaller length sequence */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ tapCnt = (srcBLen) & 3U; while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2); acc1 += (*pScr1++ * *pIn2); acc2 += (*pScr1++ * *pIn2); acc3 += (*pScr1++ * *pIn2++); pScr1 -= 3U; /* Decrement loop counter */ tapCnt--; } blkCnt--; /* Store the results in the accumulators in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); #else write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Initialization of inputB pointer */ pIn2 = py; pScratch1 += 4U; } /* Loop unrolling: Compute remaining outputs */ blkCnt = numPoints & 0x3; #else /* Initialize blkCnt with number of samples */ blkCnt = numPoints; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Calculate convolution for remaining samples of Bigger length sequence */ while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; /* Clear Accumlators */ acc0 = 0; tapCnt = (srcBLen) >> 1U; while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ x1 = read_q15x2_ia (&pScr1); /* Read two samples from smaller buffer */ y1 = read_q15x2_ia ((q15_t **) &pIn2); acc0 = __SMLALD(x1, y1, acc0); /* Decrement the loop counter */ tapCnt--; } tapCnt = (srcBLen) & 1U; /* apply same above for remaining samples of smaller length sequence */ while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2++); /* Decrement loop counter */ tapCnt--; } blkCnt--; /* The result is in 2.30 format. Convert to 1.15 with saturation. ** Then store the output in the destination buffer. */ *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16)); /* Initialization of inputB pointer */ pIn2 = py; pScratch1 += 1U; } /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; } /* Return to application */ return (status); } /** @} end of PartialConv group */
11,114
C
27.72093
117
0.547058
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_32x64_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_32x64_q31.c * Description: High precision Q31 Biquad cascade filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup BiquadCascadeDF1_32x64 High Precision Q31 Biquad Cascade Filter This function implements a high precision Biquad cascade filter which operates on Q31 data values. The filter coefficients are in 1.31 format and the state variables are in 1.63 format. The double precision state variables reduce quantization noise in the filter and provide a cleaner output. These filters are particularly useful when implementing filters in which the singularities are close to the unit circle. This is common for low pass or high pass filters with very low cutoff frequencies. The function operates on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> and <code>pDst</code> points to input and output arrays containing <code>blockSize</code> Q31 values. @par Algorithm Each Biquad stage implements a second order filter using the difference equation: <pre> y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] </pre> A Direct Form I algorithm is used with 5 coefficients and 4 state variables per stage. \image html Biquad.gif "Single Biquad filter stage" Coefficients <code>b0, b1 and b2 </code> multiply the input signal <code>x[n]</code> and are referred to as the feedforward coefficients. Coefficients <code>a1</code> and <code>a2</code> multiply the output signal <code>y[n]</code> and are referred to as the feedback coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools use the difference equation <pre> y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2] </pre> In this case the feedback coefficients <code>a1</code> and <code>a2</code> must be negated when used with the CMSIS DSP Library. @par Higher order filters are realized as a cascade of second order sections. <code>numStages</code> refers to the number of second order stages used. For example, an 8th order filter would be realized with <code>numStages=4</code> second order stages. \image html BiquadCascade.gif "8th order filter using a cascade of Biquad stages" A 9th order filter would be realized with <code>numStages=5</code> second order stages with the coefficients for one of the stages configured as a first order filter (<code>b2=0</code> and <code>a2=0</code>). @par The <code>pState</code> points to state variables array. Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code> and each state variable in 1.63 format to improve precision. The state variables are arranged in the array as: <pre> {x[n-1], x[n-2], y[n-1], y[n-2]} </pre> @par The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. The state array has a total length of <code>4*numStages</code> values of data in 1.63 format. The state variables are updated after each block of data is processed, the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. @par Init Function There is also an associated initialization function which performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numStages, pCoeffs, postShift, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. For example, to statically initialize the filter instance structure use <pre> arm_biquad_cas_df1_32x64_ins_q31 S1 = {numStages, pState, pCoeffs, postShift}; </pre> where <code>numStages</code> is the number of Biquad stages in the filter; <code>pState</code> is the address of the state buffer; <code>pCoeffs</code> is the address of the coefficient buffer; <code>postShift</code> shift to be applied which is described in detail below. @par Fixed-Point Behavior Care must be taken while using Biquad Cascade 32x64 filter function. Following issues must be considered: - Scaling of coefficients - Filter gain - Overflow and saturation @par Filter coefficients are represented as fractional values and restricted to lie in the range <code>[-1 +1)</code>. The processing function has an additional scaling parameter <code>postShift</code> which allows the filter coefficients to exceed the range <code>[+1 -1)</code>. At the output of the filter's accumulator is a shift register which shifts the result by <code>postShift</code> bits. \image html BiquadPostshift.gif "Fixed-point Biquad with shift by postShift bits after accumulator" This essentially scales the filter coefficients by <code>2^postShift</code>. For example, to realize the coefficients <pre> {1.5, -0.8, 1.2, 1.6, -0.9} </pre> set the Coefficient array to: <pre> {0.75, -0.4, 0.6, 0.8, -0.45} </pre> and set <code>postShift=1</code> @par The second thing to keep in mind is the gain through the filter. The frequency response of a Biquad filter is a function of its coefficients. It is possible for the gain through the filter to exceed 1.0 meaning that the filter increases the amplitude of certain frequencies. This means that an input signal with amplitude < 1.0 may result in an output > 1.0 and these are saturated or overflowed based on the implementation of the filter. To avoid this behavior the filter needs to be scaled down such that its peak gain < 1.0 or the input signal must be scaled down so that the combination of input and filter are never overflowed. @par The third item to consider is the overflow and saturation behavior of the fixed-point Q31 version. This is described in the function specific documentation below. */ /** @addtogroup BiquadCascadeDF1_32x64 @{ */ /** @brief Processing function for the Q31 Biquad cascade 32x64 filter. @param[in] S points to an instance of the high precision Q31 Biquad cascade filter @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Details The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by 2 bits and lie in the range [-0.25 +0.25). After all 5 multiply-accumulates are performed, the 2.62 accumulator is shifted by <code>postShift</code> bits and the result truncated to 1.31 format by discarding the low 32 bits. @par Two related functions are provided in the CMSIS DSP library. - \ref arm_biquad_cascade_df1_q31() implements a Biquad cascade with 32-bit coefficients and state variables with a Q63 accumulator. - \ref arm_biquad_cascade_df1_fast_q31() implements a Biquad cascade with 32-bit coefficients and state variables with a Q31 accumulator. */ void arm_biquad_cas_df1_32x64_q31( const arm_biquad_cas_df1_32x64_ins_q31 * S, q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { q31_t *pIn = pSrc; /* input pointer initialization */ q31_t *pOut = pDst; /* output pointer initialization */ q63_t *pState = S->pState; /* state pointer initialization */ const q31_t *pCoeffs = S->pCoeffs; /* coeff pointer initialization */ q63_t acc; /* accumulator */ q31_t Xn1, Xn2; /* Input Filter state variables */ q63_t Yn1, Yn2; /* Output Filter state variables */ q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ q31_t Xn; /* temporary input */ int32_t shift = (int32_t) S->postShift + 1; /* Shift to be applied to the output */ uint32_t sample, stage = S->numStages; /* loop counters */ q31_t acc_l, acc_h; /* temporary output */ uint32_t uShift = ((uint32_t) S->postShift + 1U); uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ do { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; a2 = *pCoeffs++; /* Reading the state values */ Xn1 = (q31_t) (pState[0]); Xn2 = (q31_t) (pState[1]); Yn1 = pState[2]; Yn2 = pState[3]; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 output values simultaneously. */ /* Variable acc hold output value that is being computed and stored in destination buffer * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* Loop unrolling: Compute 4 outputs at a time */ sample = blockSize >> 2U; while (sample > 0U) { /* Read the input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ acc = (q63_t) Xn * b0; /* acc += b1 * x[n-1] */ acc += (q63_t) Xn1 * b1; /* acc += b[2] * x[n-2] */ acc += (q63_t) Xn2 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn1, a1); /* acc += a2 * y[n-2] */ acc += mult32x64(Yn2, a2); /* The result is converted to 1.63 , Yn2 variable is reused */ Yn2 = acc << shift; /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *pOut = acc_h; /* Read the second input into Xn2, to reuse the value */ Xn2 = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc += b1 * x[n-1] */ acc = (q63_t) Xn * b1; /* acc = b0 * x[n] */ acc += (q63_t) Xn2 * b0; /* acc += b[2] * x[n-2] */ acc += (q63_t) Xn1 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn2, a1); /* acc += a2 * y[n-2] */ acc += mult32x64(Yn1, a2); /* The result is converted to 1.63, Yn1 variable is reused */ Yn1 = acc << shift; /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Read the third input into Xn1, to reuse the value */ Xn1 = *pIn++; /* The result is converted to 1.31 */ /* Store the output in the destination buffer. */ *(pOut + 1U) = acc_h; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ acc = (q63_t) Xn1 * b0; /* acc += b1 * x[n-1] */ acc += (q63_t) Xn2 * b1; /* acc += b[2] * x[n-2] */ acc += (q63_t) Xn * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn1, a1); /* acc += a2 * y[n-2] */ acc += mult32x64(Yn2, a2); /* The result is converted to 1.63, Yn2 variable is reused */ Yn2 = acc << shift; /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *(pOut + 2U) = acc_h; /* Read the fourth input into Xn, to reuse the value */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ acc = (q63_t) Xn * b0; /* acc += b1 * x[n-1] */ acc += (q63_t) Xn1 * b1; /* acc += b[2] * x[n-2] */ acc += (q63_t) Xn2 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn2, a1); /* acc += a2 * y[n-2] */ acc += mult32x64(Yn1, a2); /* The result is converted to 1.63, Yn1 variable is reused */ Yn1 = acc << shift; /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *(pOut + 3U) = acc_h; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; /* update output pointer */ pOut += 4U; /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = blockSize & 0x3U; #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { /* Read the input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ acc = (q63_t) Xn * b0; /* acc += b1 * x[n-1] */ acc += (q63_t) Xn1 * b1; /* acc += b[2] * x[n-2] */ acc += (q63_t) Xn2 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn1, a1); /* acc += a2 * y[n-2] */ acc += mult32x64(Yn2, a2); /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; /* The result is converted to 1.63, Yn1 variable is reused */ Yn1 = acc << shift; /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *pOut++ = acc_h; /* Yn1 = acc << shift; */ /* Store the output in the destination buffer in 1.31 format. */ /* *pOut++ = (q31_t) (acc >> (32 - shift)); */ /* decrement loop counter */ sample--; } /* The first stage output is given as input to the second stage. */ pIn = pDst; /* Reset to destination buffer working pointer */ pOut = pDst; /* Store the updated state variables back into the pState array */ *pState++ = (q63_t) Xn1; *pState++ = (q63_t) Xn2; *pState++ = Yn1; *pState++ = Yn2; } while (--stage); } /** @} end of BiquadCascadeDF1_32x64 group */
18,494
C
39.294118
180
0.565481
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_iir_lattice_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_iir_lattice_q31.c * Description: Q31 IIR Lattice filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup IIR_Lattice @{ */ /** @brief Processing function for the Q31 IIR lattice filter. @param[in] S points to an instance of the Q31 IIR lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by 2*log2(numStages) bits. After all multiply-accumulates are performed, the 2.62 accumulator is saturated to 1.32 format and then truncated to 1.31 format. */ void arm_iir_lattice_q31( const arm_iir_lattice_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { q31_t *pState = S->pState; /* State pointer */ q31_t *pStateCur; /* State current pointer */ q31_t fcurr, fnext = 0, gcurr = 0, gnext; /* Temporary variables for lattice stages */ q63_t acc; /* Accumlator */ q31_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ uint32_t numStages = S->numStages; /* Number of stages */ uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ /* initialise loop count */ blkCnt = blockSize; #if defined (ARM_MATH_DSP) /* Sample processing */ while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; /* Initialize Ladder coeff pointer */ pv = &S->pvCoeffs[0]; /* Initialize Reflection coeff pointer */ pk = &S->pkCoeffs[0]; /* Initialize state read pointer */ px1 = pState; /* Initialize state write pointer */ px2 = pState; /* Set accumulator to zero */ acc = 0; /* Process sample for first tap */ gcurr = *px1++; /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); /* write gN-1(n-1) into state for next sample processing */ *px2++ = gnext; /* y(n) += gN(n) * vN */ acc += ((q63_t) gnext * *pv++); /* Update f values for next coefficient processing */ fcurr = fnext; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numStages - 1U) >> 2U; while (tapCnt > 0U) { /* Process sample for 2nd, 6th ...taps */ /* Read gN-2(n-1) from state buffer */ gcurr = *px1++; /* fN-2(n) = fN-1(n) - kN-1 * gN-2(n-1) */ fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); /* gN-1(n) = kN-1 * fN-2(n) + gN-2(n-1) */ gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); /* y(n) += gN-1(n) * vN-1 */ /* process for gN-5(n) * vN-5, gN-9(n) * vN-9 ... */ acc += ((q63_t) gnext * *pv++); /* write gN-1(n) into state for next sample processing */ *px2++ = gnext; /* Process sample for 3nd, 7th ...taps */ /* Read gN-3(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 3rd, 7th .. taps */ /* fN-3(n) = fN-2(n) - kN-2 * gN-3(n-1) */ fcurr = __QSUB(fnext, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); /* gN-2(n) = kN-2 * fN-3(n) + gN-3(n-1) */ gnext = __QADD(gcurr, (q31_t) (((q63_t) fcurr * (*pk++)) >> 31)); /* y(n) += gN-2(n) * vN-2 */ /* process for gN-6(n) * vN-6, gN-10(n) * vN-10 ... */ acc += ((q63_t) gnext * *pv++); /* write gN-2(n) into state for next sample processing */ *px2++ = gnext; /* Process sample for 4th, 8th ...taps */ /* Read gN-4(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 4th, 8th .. taps */ /* fN-4(n) = fN-3(n) - kN-3 * gN-4(n-1) */ fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); /* gN-3(n) = kN-3 * fN-4(n) + gN-4(n-1) */ gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); /* y(n) += gN-3(n) * vN-3 */ /* process for gN-7(n) * vN-7, gN-11(n) * vN-11 ... */ acc += ((q63_t) gnext * *pv++); /* write gN-3(n) into state for next sample processing */ *px2++ = gnext; /* Process sample for 5th, 9th ...taps */ /* Read gN-5(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 5th, 9th .. taps */ /* fN-5(n) = fN-4(n) - kN-4 * gN-1(n-1) */ fcurr = __QSUB(fnext, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); /* gN-4(n) = kN-4 * fN-5(n) + gN-5(n-1) */ gnext = __QADD(gcurr, (q31_t) (((q63_t) fcurr * (*pk++)) >> 31)); /* y(n) += gN-4(n) * vN-4 */ /* process for gN-8(n) * vN-8, gN-12(n) * vN-12 ... */ acc += ((q63_t) gnext * *pv++); /* write gN-4(n) into state for next sample processing */ *px2++ = gnext; /* Decrement loop counter */ tapCnt--; } fnext = fcurr; /* Loop unrolling: Compute remaining taps */ tapCnt = (numStages - 1U) % 0x4U; #else /* Initialize blkCnt with number of samples */ tapCnt = (numStages - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { gcurr = *px1++; /* Process sample for last taps */ fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); /* Output samples for last taps */ acc += ((q63_t) gnext * *pv++); *px2++ = gnext; fcurr = fnext; /* Decrement loop counter */ tapCnt--; } /* y(n) += g0(n) * v0 */ acc += ((q63_t) fnext * *pv++); *px2++ = fnext; /* write out into pDst */ *pDst++ = (q31_t) (acc >> 31U); /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy last S->numStages samples to start of the buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; /* Copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numStages >> 2U; while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numStages % 0x4U; #else /* Initialize blkCnt with number of samples */ tapCnt = (numStages - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #else /* #if defined (ARM_MATH_DSP) */ /* Sample processing */ while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; /* Initialize Ladder coeff pointer */ pv = &S->pvCoeffs[0]; /* Initialize Reflection coeff pointer */ pk = &S->pkCoeffs[0]; /* Initialize state read pointer */ px1 = pState; /* Initialize state write pointer */ px2 = pState; /* Set accumulator to zero */ acc = 0; tapCnt = numStages; while (tapCnt > 0U) { gcurr = *px1++; /* Process sample */ /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ fnext = clip_q63_to_q31(((q63_t) fcurr - ((q31_t) (((q63_t) gcurr * (*pk )) >> 31)))); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ gnext = clip_q63_to_q31(((q63_t) gcurr + ((q31_t) (((q63_t) fnext * (*pk++)) >> 31)))); /* Output samples */ /* y(n) += gN(n) * vN */ acc += ((q63_t) gnext * *pv++); /* write gN-1(n-1) into state for next sample processing */ *px2++ = gnext; /* Update f values for next coefficient processing */ fcurr = fnext; tapCnt--; } /* y(n) += g0(n) * v0 */ acc += ((q63_t) fnext * *pv++); *px2++ = fnext; /* write out into pDst */ *pDst++ = (q31_t) (acc >> 31U); /* Advance the state pointer by 1 to process the next group of samples */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy last S->numStages samples to start of the buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; tapCnt = numStages; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #endif /* #if defined (ARM_MATH_DSP) */ } /** @} end of IIR_Lattice group */
10,489
C
28.383753
162
0.528172
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_lms_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_lms_f32.c * Description: Processing function for the floating-point LMS filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup LMS Least Mean Square (LMS) Filters LMS filters are a class of adaptive filters that are able to "learn" an unknown transfer functions. LMS filters use a gradient descent method in which the filter coefficients are updated based on the instantaneous error signal. Adaptive filters are often used in communication systems, equalizers, and noise removal. The CMSIS DSP Library contains LMS filter functions that operate on Q15, Q31, and floating-point data types. The library also contains normalized LMS filters in which the filter coefficient adaptation is indepedent of the level of the input signal. An LMS filter consists of two components as shown below. The first component is a standard transversal or FIR filter. The second component is a coefficient update mechanism. The LMS filter has two input signals. The "input" feeds the FIR filter while the "reference input" corresponds to the desired output of the FIR filter. That is, the FIR filter coefficients are updated so that the output of the FIR filter matches the reference input. The filter coefficient update mechanism is based on the difference between the FIR filter output and the reference input. This "error signal" tends towards zero as the filter adapts. The LMS processing functions accept the input and reference input signals and generate the filter output and error signal. \image html LMS.gif "Internal structure of the Least Mean Square filter" The functions operate on blocks of data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> points to input signal, <code>pRef</code> points to reference signal, <code>pOut</code> points to output signal and <code>pErr</code> points to error signal. All arrays contain <code>blockSize</code> values. The functions operate on a block-by-block basis. Internally, the filter coefficients <code>b[n]</code> are updated on a sample-by-sample basis. The convergence of the LMS filter is slower compared to the normalized LMS algorithm. @par Algorithm The output signal <code>y[n]</code> is computed by a standard FIR filter: <pre> y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1] </pre> @par The error signal equals the difference between the reference signal <code>d[n]</code> and the filter output: <pre> e[n] = d[n] - y[n]. </pre> @par After each sample of the error signal is computed, the filter coefficients <code>b[k]</code> are updated on a sample-by-sample basis: <pre> b[k] = b[k] + e[n] * mu * x[n-k], for k=0, 1, ..., numTaps-1 </pre> where <code>mu</code> is the step size and controls the rate of coefficient convergence. @par In the APIs, <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>. Coefficients are stored in time reversed order. @par <pre> {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} </pre> @par <code>pState</code> points to a state array of size <code>numTaps + blockSize - 1</code>. Samples in the state buffer are stored in the order: @par <pre> {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]} </pre> @par Note that the length of the state buffer exceeds the length of the coefficient array by <code>blockSize-1</code> samples. The increased state buffer length allows circular addressing, which is traditionally used in FIR filters, to be avoided and yields a significant speed improvement. The state variables are updated after each block of data is processed. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter and coefficient and state arrays cannot be shared among instances. There are separate instance structure declarations for each of the 3 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numTaps, pCoeffs, mu, postShift (not for f32), pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. The code below statically initializes each of the 3 different data type filter instance structures <pre> arm_lms_instance_f32 S = {numTaps, pState, pCoeffs, mu}; arm_lms_instance_q31 S = {numTaps, pState, pCoeffs, mu, postShift}; arm_lms_instance_q15 S = {numTaps, pState, pCoeffs, mu, postShift}; </pre> where <code>numTaps</code> is the number of filter coefficients in the filter; <code>pState</code> is the address of the state buffer; <code>pCoeffs</code> is the address of the coefficient buffer; <code>mu</code> is the step size parameter; and <code>postShift</code> is the shift applied to coefficients. @par Fixed-Point Behavior Care must be taken when using the Q15 and Q31 versions of the LMS filter. The following issues must be considered: - Scaling of coefficients - Overflow and saturation @par Scaling of Coefficients Filter coefficients are represented as fractional values and coefficients are restricted to lie in the range <code>[-1 +1)</code>. The fixed-point functions have an additional scaling parameter <code>postShift</code>. At the output of the filter's accumulator is a shift register which shifts the result by <code>postShift</code> bits. This essentially scales the filter coefficients by <code>2^postShift</code> and allows the filter coefficients to exceed the range <code>[+1 -1)</code>. The value of <code>postShift</code> is set by the user based on the expected gain through the system being modeled. @par Overflow and Saturation Overflow and saturation behavior of the fixed-point Q15 and Q31 versions are described separately as part of the function specific documentation below. */ /** @addtogroup LMS @{ */ /** @brief Processing function for floating-point LMS filter. @param[in] S points to an instance of the floating-point LMS filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @param[out] pErr points to the block of error data @param[in] blockSize number of samples to process @return none */ #if defined(ARM_MATH_NEON) void arm_lms_f32( const arm_lms_instance_f32 * S, const float32_t * pSrc, float32_t * pRef, float32_t * pOut, float32_t * pErr, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCurnt; /* Points to the current sample of the state */ float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ float32_t mu = S->mu; /* Adaptive factor */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t tapCnt, blkCnt; /* Loop counters */ float32_t sum, e, d; /* accumulator, error, reference data sample */ float32_t w = 0.0f; /* weight factor */ float32x4_t tempV, sumV, xV, bV; float32x2_t tempV2; e = 0.0f; d = 0.0f; /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); blkCnt = blockSize; while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; /* Initialize pState pointer */ px = pState; /* Initialize coeff pointer */ pb = (pCoeffs); /* Set the accumulator to zero */ sum = 0.0f; sumV = vdupq_n_f32(0.0); /* Process 4 taps at a time. */ tapCnt = numTaps >> 2; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ xV = vld1q_f32(px); bV = vld1q_f32(pb); sumV = vmlaq_f32(sumV, xV, bV); px += 4; pb += 4; /* Decrement the loop counter */ tapCnt--; } tempV2 = vpadd_f32(vget_low_f32(sumV),vget_high_f32(sumV)); sum = tempV2[0] + tempV2[1]; /* If the filter length is not a multiple of 4, compute the remaining filter taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum += (*px++) * (*pb++); /* Decrement the loop counter */ tapCnt--; } /* The result in the accumulator, store in the destination buffer. */ *pOut++ = sum; /* Compute and store error */ d = (float32_t) (*pRef++); e = d - sum; *pErr++ = e; /* Calculation of Weighting factor for the updating filter coefficients */ w = e * mu; /* Initialize pState pointer */ px = pState; /* Initialize coeff pointer */ pb = (pCoeffs); /* Process 4 taps at a time. */ tapCnt = numTaps >> 2; /* Update filter coefficients */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ xV = vld1q_f32(px); bV = vld1q_f32(pb); px += 4; bV = vmlaq_n_f32(bV,xV,w); vst1q_f32(pb,bV); pb += 4; /* Decrement the loop counter */ tapCnt--; } /* If the filter length is not a multiple of 4, compute the remaining filter taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb = *pb + (w * (*px++)); pb++; /* Decrement the loop counter */ tapCnt--; } /* Advance state pointer by 1 for the next sample */ pState = pState + 1; /* Decrement the loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the pState buffer */ pStateCurnt = S->pState; /* Process 4 taps at a time for (numTaps - 1U) samples copy */ tapCnt = (numTaps - 1U) >> 2U; /* copy data */ while (tapCnt > 0U) { tempV = vld1q_f32(pState); vst1q_f32(pStateCurnt,tempV); pState += 4; pStateCurnt += 4; /* Decrement the loop counter */ tapCnt--; } /* Calculate remaining number of copies */ tapCnt = (numTaps - 1U) % 0x4U; /* Copy the remaining q31_t data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ tapCnt--; } } #else void arm_lms_f32( const arm_lms_instance_f32 * S, const float32_t * pSrc, float32_t * pRef, float32_t * pOut, float32_t * pErr, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCurnt; /* Points to the current sample of the state */ float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ float32_t mu = S->mu; /* Adaptive factor */ float32_t acc, e; /* Accumulator, error */ float32_t w; /* Weight factor */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t tapCnt, blkCnt; /* Loop counters */ /* Initializations of error, difference, Coefficient update */ e = 0.0f; w = 0.0f; /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; /* Initialize pState pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Set the accumulator to zero */ acc = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (*px++) * (*pb++); acc += (*px++) * (*pb++); acc += (*px++) * (*pb++); acc += (*px++) * (*pb++); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (*px++) * (*pb++); /* Decrement the loop counter */ tapCnt--; } /* Store the result from accumulator into the destination buffer. */ *pOut++ = acc; /* Compute and store error */ e = (float32_t) *pRef++ - acc; *pErr++ = e; /* Calculation of Weighting factor for updating filter coefficients */ w = e * mu; /* Initialize pState pointer */ /* Advance state pointer by 1 for the next sample */ px = pState++; /* Initialize coefficient pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb += w * (*px++); pb++; *pb += w * (*px++); pb++; *pb += w * (*px++); pb++; *pb += w * (*px++); pb++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb += w * (*px++); pb++; /* Decrement loop counter */ tapCnt--; } /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the pState buffer */ pStateCurnt = S->pState; /* copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of LMS group */
17,964
C
32.642322
188
0.60354
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/FilteringFunctions.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: FilteringFunctions.c * Description: Combination of all filtering function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_biquad_cascade_df1_32x64_init_q31.c" #include "arm_biquad_cascade_df1_32x64_q31.c" #include "arm_biquad_cascade_df1_f32.c" #include "arm_biquad_cascade_df1_fast_q15.c" #include "arm_biquad_cascade_df1_fast_q31.c" #include "arm_biquad_cascade_df1_init_f32.c" #include "arm_biquad_cascade_df1_init_q15.c" #include "arm_biquad_cascade_df1_init_q31.c" #include "arm_biquad_cascade_df1_q15.c" #include "arm_biquad_cascade_df1_q31.c" #include "arm_biquad_cascade_df2T_f32.c" #include "arm_biquad_cascade_df2T_f64.c" #include "arm_biquad_cascade_df2T_init_f32.c" #include "arm_biquad_cascade_df2T_init_f64.c" #include "arm_biquad_cascade_stereo_df2T_f32.c" #include "arm_biquad_cascade_stereo_df2T_init_f32.c" #include "arm_conv_f32.c" #include "arm_conv_fast_opt_q15.c" #include "arm_conv_fast_q15.c" #include "arm_conv_fast_q31.c" #include "arm_conv_opt_q15.c" #include "arm_conv_opt_q7.c" #include "arm_conv_partial_f32.c" #include "arm_conv_partial_fast_opt_q15.c" #include "arm_conv_partial_fast_q15.c" #include "arm_conv_partial_fast_q31.c" #include "arm_conv_partial_opt_q15.c" #include "arm_conv_partial_opt_q7.c" #include "arm_conv_partial_q15.c" #include "arm_conv_partial_q31.c" #include "arm_conv_partial_q7.c" #include "arm_conv_q15.c" #include "arm_conv_q31.c" #include "arm_conv_q7.c" #include "arm_correlate_f32.c" #include "arm_correlate_fast_opt_q15.c" #include "arm_correlate_fast_q15.c" #include "arm_correlate_fast_q31.c" #include "arm_correlate_opt_q15.c" #include "arm_correlate_opt_q7.c" #include "arm_correlate_q15.c" #include "arm_correlate_q31.c" #include "arm_correlate_q7.c" #include "arm_fir_decimate_f32.c" #include "arm_fir_decimate_fast_q15.c" #include "arm_fir_decimate_fast_q31.c" #include "arm_fir_decimate_init_f32.c" #include "arm_fir_decimate_init_q15.c" #include "arm_fir_decimate_init_q31.c" #include "arm_fir_decimate_q15.c" #include "arm_fir_decimate_q31.c" #include "arm_fir_f32.c" #include "arm_fir_fast_q15.c" #include "arm_fir_fast_q31.c" #include "arm_fir_init_f32.c" #include "arm_fir_init_q15.c" #include "arm_fir_init_q31.c" #include "arm_fir_init_q7.c" #include "arm_fir_interpolate_f32.c" #include "arm_fir_interpolate_init_f32.c" #include "arm_fir_interpolate_init_q15.c" #include "arm_fir_interpolate_init_q31.c" #include "arm_fir_interpolate_q15.c" #include "arm_fir_interpolate_q31.c" #include "arm_fir_lattice_f32.c" #include "arm_fir_lattice_init_f32.c" #include "arm_fir_lattice_init_q15.c" #include "arm_fir_lattice_init_q31.c" #include "arm_fir_lattice_q15.c" #include "arm_fir_lattice_q31.c" #include "arm_fir_q15.c" #include "arm_fir_q31.c" #include "arm_fir_q7.c" #include "arm_fir_sparse_f32.c" #include "arm_fir_sparse_init_f32.c" #include "arm_fir_sparse_init_q15.c" #include "arm_fir_sparse_init_q31.c" #include "arm_fir_sparse_init_q7.c" #include "arm_fir_sparse_q15.c" #include "arm_fir_sparse_q31.c" #include "arm_fir_sparse_q7.c" #include "arm_iir_lattice_f32.c" #include "arm_iir_lattice_init_f32.c" #include "arm_iir_lattice_init_q15.c" #include "arm_iir_lattice_init_q31.c" #include "arm_iir_lattice_q15.c" #include "arm_iir_lattice_q31.c" #include "arm_lms_f32.c" #include "arm_lms_init_f32.c" #include "arm_lms_init_q15.c" #include "arm_lms_init_q31.c" #include "arm_lms_norm_f32.c" #include "arm_lms_norm_init_f32.c" #include "arm_lms_norm_init_q15.c" #include "arm_lms_norm_init_q31.c" #include "arm_lms_norm_q15.c" #include "arm_lms_norm_q31.c" #include "arm_lms_q15.c" #include "arm_lms_q31.c"
4,539
C
34.46875
74
0.705221
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df2T_init_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_init_f32.c * Description: Initialization function for floating-point transposed direct form II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF2T @{ */ /** @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. @param[in,out] S points to an instance of the filter data structure. @param[in] numStages number of 2nd order stages in the filter. @param[in] pCoeffs points to the filter coefficients. @param[in] pState points to the state buffer. @return none @par Coefficient and State Ordering The coefficients are stored in the array <code>pCoeffs</code> in the following order in the not Neon version. <pre> {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} </pre> @par where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage, <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage, and so on. The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values. For Neon version, this array is bigger. If numstages = 4x + y, then the array has size: 32*x + 5*y and it must be initialized using the function arm_biquad_cascade_df2T_compute_coefs_f32 which is taking the standard array coefficient as parameters. But, an array of 8*numstages is a good approximation. Then, the initialization can be done with: <pre> arm_biquad_cascade_df2T_init_f32(&SNeon, nbCascade, neonCoefs, stateNeon); arm_biquad_cascade_df2T_compute_coefs_f32(&SNeon,nbCascade,coefs); </pre> @par In this example, neonCoefs is a bigger array of size 8 * numStages. coefs is the standard array: <pre> {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} </pre> @par The <code>pState</code> is a pointer to state array. Each Biquad stage has 2 state variables <code>d1,</code> and <code>d2</code>. The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on. The state array has a total length of <code>2*numStages</code> values. The state variables are updated after each block of data is processed; the coefficients are untouched. */ #if defined(ARM_MATH_NEON) /* Must be called after initializing the biquad instance. pCoeffs has size 5 * nbCascade Whereas the pCoeffs for the init has size (4*4 + 4*4)* nbCascade So this pCoeffs is the one which would be used for the not Neon version. The pCoeffs passed in init is bigger than the one for the not Neon version. */ void arm_biquad_cascade_df2T_compute_coefs_f32( arm_biquad_cascade_df2T_instance_f32 * S, uint8_t numStages, float32_t * pCoeffs) { uint8_t cnt; float32_t *pDstCoeffs; float32_t b0[4],b1[4],b2[4],a1[4],a2[4]; pDstCoeffs = S->pCoeffs; cnt = numStages >> 2; while(cnt > 0) { for(int i=0;i<4;i++) { b0[i] = pCoeffs[0]; b1[i] = pCoeffs[1]; b2[i] = pCoeffs[2]; a1[i] = pCoeffs[3]; a2[i] = pCoeffs[4]; pCoeffs += 5; } /* Vec 1 */ *pDstCoeffs++ = 0; *pDstCoeffs++ = b0[1]; *pDstCoeffs++ = b0[2]; *pDstCoeffs++ = b0[3]; /* Vec 2 */ *pDstCoeffs++ = 0; *pDstCoeffs++ = 0; *pDstCoeffs++ = b0[1] * b0[2]; *pDstCoeffs++ = b0[2] * b0[3]; /* Vec 3 */ *pDstCoeffs++ = 0; *pDstCoeffs++ = 0; *pDstCoeffs++ = 0; *pDstCoeffs++ = b0[1] * b0[2] * b0[3]; /* Vec 4 */ *pDstCoeffs++ = b0[0]; *pDstCoeffs++ = b0[0] * b0[1]; *pDstCoeffs++ = b0[0] * b0[1] * b0[2]; *pDstCoeffs++ = b0[0] * b0[1] * b0[2] * b0[3]; /* Vec 5 */ *pDstCoeffs++ = b1[0]; *pDstCoeffs++ = b1[1]; *pDstCoeffs++ = b1[2]; *pDstCoeffs++ = b1[3]; /* Vec 6 */ *pDstCoeffs++ = b2[0]; *pDstCoeffs++ = b2[1]; *pDstCoeffs++ = b2[2]; *pDstCoeffs++ = b2[3]; /* Vec 7 */ *pDstCoeffs++ = a1[0]; *pDstCoeffs++ = a1[1]; *pDstCoeffs++ = a1[2]; *pDstCoeffs++ = a1[3]; /* Vec 8 */ *pDstCoeffs++ = a2[0]; *pDstCoeffs++ = a2[1]; *pDstCoeffs++ = a2[2]; *pDstCoeffs++ = a2[3]; cnt--; } cnt = numStages & 0x3; while(cnt > 0) { *pDstCoeffs++ = *pCoeffs++; *pDstCoeffs++ = *pCoeffs++; *pDstCoeffs++ = *pCoeffs++; *pDstCoeffs++ = *pCoeffs++; *pDstCoeffs++ = *pCoeffs++; cnt--; } } #endif void arm_biquad_cascade_df2T_init_f32( arm_biquad_cascade_df2T_instance_f32 * S, uint8_t numStages, const float32_t * pCoeffs, float32_t * pState) { /* Assign filter stages */ S->numStages = numStages; /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 2 * numStages */ memset(pState, 0, (2U * (uint32_t) numStages) * sizeof(float32_t)); /* Assign state pointer */ S->pState = pState; } /** @} end of BiquadCascadeDF2T group */
6,435
C
29.35849
121
0.565346
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_lattice_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_lattice_f32.c * Description: Processing function for floating-point FIR Lattice filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup FIR_Lattice Finite Impulse Response (FIR) Lattice Filters This set of functions implements Finite Impulse Response (FIR) lattice filters for Q15, Q31 and floating-point data types. Lattice filters are used in a variety of adaptive filter applications. The filter structure is feedforward and the net impulse response is finite length. The functions operate on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> and <code>pDst</code> point to input and output arrays containing <code>blockSize</code> values. @par Algorithm \image html FIRLattice.gif "Finite Impulse Response Lattice filter" The following difference equation is implemented: @par <pre> f0[n] = g0[n] = x[n] fm[n] = fm-1[n] + km * gm-1[n-1] for m = 1, 2, ...M gm[n] = km * fm-1[n] + gm-1[n-1] for m = 1, 2, ...M y[n] = fM[n] </pre> @par <code>pCoeffs</code> points to tha array of reflection coefficients of size <code>numStages</code>. Reflection Coefficients are stored in the following order. @par <pre> {k1, k2, ..., kM} </pre> where M is number of stages @par <code>pState</code> points to a state array of size <code>numStages</code>. The state variables (g values) hold previous inputs and are stored in the following order. <pre> {g0[n], g1[n], g2[n] ...gM-1[n]} </pre> The state variables are updated after each block of data is processed; the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 3 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numStages, pCoeffs, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros and then manually initialize the instance structure as follows: <pre> arm_fir_lattice_instance_f32 S = {numStages, pState, pCoeffs}; arm_fir_lattice_instance_q31 S = {numStages, pState, pCoeffs}; arm_fir_lattice_instance_q15 S = {numStages, pState, pCoeffs}; </pre> @par where <code>numStages</code> is the number of stages in the filter; <code>pState</code> is the address of the state buffer; <code>pCoeffs</code> is the address of the coefficient buffer. @par Fixed-Point Behavior Care must be taken when using the fixed-point versions of the FIR Lattice filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. */ /** @addtogroup FIR_Lattice @{ */ /** @brief Processing function for the floating-point FIR lattice filter. @param[in] S points to an instance of the floating-point FIR lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ void arm_fir_lattice_f32( const arm_fir_lattice_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *px; /* Temporary state pointer */ const float32_t *pk; /* Temporary coefficient pointer */ uint32_t numStages = S->numStages; /* Number of stages in the filter */ uint32_t blkCnt, stageCnt; /* Loop counters */ float32_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ #if defined (ARM_MATH_LOOPUNROLL) float32_t fcurr1, fnext1, gnext1; /* Temporary variables for second sample in loop unrolling */ float32_t fcurr2, fnext2, gnext2; /* Temporary variables for third sample in loop unrolling */ float32_t fcurr3, fnext3, gnext3; /* Temporary variables for fourth sample in loop unrolling */ #endif gcurr0 = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Read two samples from input buffer */ /* f0(n) = x(n) */ fcurr0 = *pSrc++; fcurr1 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* Read g0(n-1) from state buffer */ gcurr0 = *px; /* Process first sample for first tap */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (gcurr0 * (*pk)) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (fcurr0 * (*pk)) + gcurr0; /* Process second sample for first tap */ fnext1 = (fcurr0 * (*pk)) + fcurr1; gnext1 = (fcurr1 * (*pk)) + fcurr0; /* Read next two samples from input buffer */ /* f0(n+2) = x(n+2) */ fcurr2 = *pSrc++; fcurr3 = *pSrc++; /* Process third sample for first tap */ fnext2 = (fcurr1 * (*pk)) + fcurr2; gnext2 = (fcurr2 * (*pk)) + fcurr1; /* Process fourth sample for first tap */ fnext3 = (fcurr2 * (*pk )) + fcurr3; gnext3 = (fcurr3 * (*pk++)) + fcurr2; /* Copy only last input sample into the state buffer which will be used for next samples processing */ *px++ = fcurr3; /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; fcurr1 = fnext1; fcurr2 = fnext2; fcurr3 = fnext3; /* Loop unrolling. Process 4 taps at a time . */ stageCnt = (numStages - 1U) >> 2U; /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numStages-3 coefficients. */ /* Process 2nd, 3rd, 4th and 5th taps ... here */ while (stageCnt > 0U) { /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = gnext3; /* Process first sample for 2nd, 6th .. tap */ /* Sample processing for K2, K6.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext0 = (gcurr0 * (*pk)) + fcurr0; /* Process second sample for 2nd, 6th .. tap */ /* for sample 2 processing */ fnext1 = (gnext0 * (*pk)) + fcurr1; /* Process third sample for 2nd, 6th .. tap */ fnext2 = (gnext1 * (*pk)) + fcurr2; /* Process fourth sample for 2nd, 6th .. tap */ fnext3 = (gnext2 * (*pk)) + fcurr3; /* g2(n) = f1(n) * K2 + g1(n-1) */ /* Calculation of state values for next stage */ gnext3 = (fcurr3 * (*pk)) + gnext2; gnext2 = (fcurr2 * (*pk)) + gnext1; gnext1 = (fcurr1 * (*pk)) + gnext0; gnext0 = (fcurr0 * (*pk++)) + gcurr0; /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g2(n) in state buffer */ *px++ = gnext3; /* Sample processing for K3, K7.... */ /* Process first sample for 3rd, 7th .. tap */ /* f3(n) = f2(n) + K3 * g2(n-1) */ fcurr0 = (gcurr0 * (*pk)) + fnext0; /* Process second sample for 3rd, 7th .. tap */ fcurr1 = (gnext0 * (*pk)) + fnext1; /* Process third sample for 3rd, 7th .. tap */ fcurr2 = (gnext1 * (*pk)) + fnext2; /* Process fourth sample for 3rd, 7th .. tap */ fcurr3 = (gnext2 * (*pk)) + fnext3; /* Calculation of state values for next stage */ /* g3(n) = f2(n) * K3 + g2(n-1) */ gnext3 = (fnext3 * (*pk)) + gnext2; gnext2 = (fnext2 * (*pk)) + gnext1; gnext1 = (fnext1 * (*pk)) + gnext0; gnext0 = (fnext0 * (*pk++)) + gcurr0; /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g3(n) in state buffer */ *px++ = gnext3; /* Sample processing for K4, K8.... */ /* Process first sample for 4th, 8th .. tap */ /* f4(n) = f3(n) + K4 * g3(n-1) */ fnext0 = (gcurr0 * (*pk)) + fcurr0; /* Process second sample for 4th, 8th .. tap */ /* for sample 2 processing */ fnext1 = (gnext0 * (*pk)) + fcurr1; /* Process third sample for 4th, 8th .. tap */ fnext2 = (gnext1 * (*pk)) + fcurr2; /* Process fourth sample for 4th, 8th .. tap */ fnext3 = (gnext2 * (*pk)) + fcurr3; /* g4(n) = f3(n) * K4 + g3(n-1) */ /* Calculation of state values for next stage */ gnext3 = (fcurr3 * (*pk)) + gnext2; gnext2 = (fcurr2 * (*pk)) + gnext1; gnext1 = (fcurr1 * (*pk)) + gnext0; gnext0 = (fcurr0 * (*pk++)) + gcurr0; /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g4(n) in state buffer */ *px++ = gnext3; /* Sample processing for K5, K9.... */ /* Process first sample for 5th, 9th .. tap */ /* f5(n) = f4(n) + K5 * g4(n-1) */ fcurr0 = (gcurr0 * (*pk)) + fnext0; /* Process second sample for 5th, 9th .. tap */ fcurr1 = (gnext0 * (*pk)) + fnext1; /* Process third sample for 5th, 9th .. tap */ fcurr2 = (gnext1 * (*pk)) + fnext2; /* Process fourth sample for 5th, 9th .. tap */ fcurr3 = (gnext2 * (*pk)) + fnext3; /* Calculation of state values for next stage */ /* g5(n) = f4(n) * K5 + g4(n-1) */ gnext3 = (fnext3 * (*pk)) + gnext2; gnext2 = (fnext2 * (*pk)) + gnext1; gnext1 = (fnext1 * (*pk)) + gnext0; gnext0 = (fnext0 * (*pk++)) + gcurr0; stageCnt--; } /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ stageCnt = (numStages - 1U) % 0x4U; while (stageCnt > 0U) { gcurr0 = *px; /* save g value in state buffer */ *px++ = gnext3; /* Process four samples for last three taps here */ fnext0 = (gcurr0 * (*pk)) + fcurr0; fnext1 = (gnext0 * (*pk)) + fcurr1; fnext2 = (gnext1 * (*pk)) + fcurr2; fnext3 = (gnext2 * (*pk)) + fcurr3; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext3 = (fcurr3 * (*pk)) + gnext2; gnext2 = (fcurr2 * (*pk)) + gnext1; gnext1 = (fcurr1 * (*pk)) + gnext0; gnext0 = (fcurr0 * (*pk++)) + gcurr0; /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; fcurr1 = fnext1; fcurr2 = fnext2; fcurr3 = fnext3; stageCnt--; } /* The results in the 4 accumulators, store in the destination buffer. */ /* y(n) = fN(n) */ *pDst++ = fcurr0; *pDst++ = fcurr1; *pDst++ = fcurr2; *pDst++ = fcurr3; blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* read g2(n) from state buffer */ gcurr0 = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (gcurr0 * (*pk)) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (fcurr0 * (*pk++)) + gcurr0; /* save g1(n) in state buffer */ *px++ = fcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext0 = (gcurr0 * (*pk)) + fcurr0; /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext0 = (fcurr0 * (*pk++)) + gcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = fcurr0; blkCnt--; } } /** @} end of FIR_Lattice group */
14,615
C
31.193833
139
0.560862
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_conv_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_conv_f32.c * Description: Convolution of floating-point sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup Conv Convolution Convolution is a mathematical operation that operates on two finite length vectors to generate a finite length output vector. Convolution is similar to correlation and is frequently used in filtering and data analysis. The CMSIS DSP library contains functions for convolving Q7, Q15, Q31, and floating-point data types. The library also provides fast versions of the Q15 and Q31 functions. @par Algorithm Let <code>a[n]</code> and <code>b[n]</code> be sequences of length <code>srcALen</code> and <code>srcBLen</code> samples respectively. Then the convolution <pre> c[n] = a[n] * b[n] </pre> @par is defined as \image html ConvolutionEquation.gif @par Note that <code>c[n]</code> is of length <code>srcALen + srcBLen - 1</code> and is defined over the interval <code>n=0, 1, 2, ..., srcALen + srcBLen - 2</code>. <code>pSrcA</code> points to the first input vector of length <code>srcALen</code> and <code>pSrcB</code> points to the second input vector of length <code>srcBLen</code>. The output result is written to <code>pDst</code> and the calling function must allocate <code>srcALen+srcBLen-1</code> words for the result. @par Conceptually, when two signals <code>a[n]</code> and <code>b[n]</code> are convolved, the signal <code>b[n]</code> slides over <code>a[n]</code>. For each offset \c n, the overlapping portions of a[n] and b[n] are multiplied and summed together. @par Note that convolution is a commutative operation: <pre> a[n] * b[n] = b[n] * a[n]. </pre> @par This means that switching the A and B arguments to the convolution functions has no effect. @par Fixed-Point Behavior Convolution requires summing up a large number of intermediate products. As such, the Q7, Q15, and Q31 functions run a risk of overflow and saturation. Refer to the function specific documentation below for further details of the particular algorithm used. @par Fast Versions Fast versions are supported for Q31 and Q15. Cycles for Fast versions are less compared to Q31 and Q15 of conv and the design requires the input signals should be scaled down to avoid intermediate overflows. @par Opt Versions Opt versions are supported for Q15 and Q7. Design uses internal scratch buffer for getting good optimisation. These versions are optimised in cycles and consumes more memory (Scratch memory) compared to Q15 and Q7 versions */ /** @addtogroup Conv @{ */ /** @brief Convolution of floating-point sequences. @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. @return none */ void arm_conv_f32( const float32_t * pSrcA, uint32_t srcALen, const float32_t * pSrcB, uint32_t srcBLen, float32_t * pDst) { #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) const float32_t *pIn1; /* InputA pointer */ const float32_t *pIn2; /* InputB pointer */ float32_t *pOut = pDst; /* Output pointer */ const float32_t *px; /* Intermediate inputA pointer */ const float32_t *py; /* Intermediate inputB pointer */ const float32_t *pSrc1, *pSrc2; /* Intermediate pointers */ float32_t sum; /* Accumulators */ uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ uint32_t j, k, count, blkCnt; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) float32_t acc0, acc1, acc2, acc3; /* Accumulators */ float32_t x0, x1, x2, x3, c0; /* Temporary variables to hold state and coefficient values */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; /* Initialization of inputB pointer */ pIn2 = pSrcA; /* srcBLen is always considered as shorter or equal to srcALen */ j = srcBLen; srcBLen = srcALen; srcALen = j; } /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ /* The function is internally * divided into three stages according to the number of multiplications that has to be * taken place between inputA samples and inputB samples. In the first stage of the * algorithm, the multiplications increase by one for every iteration. * In the second stage of the algorithm, srcBLen number of multiplications are done. * In the third stage of the algorithm, the multiplications decrease by one * for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ blockSize1 = srcBLen - 1U; blockSize2 = srcALen - (srcBLen - 1U); blockSize3 = blockSize1; /* -------------------------- * Initializations of stage1 * -------------------------*/ /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. The count variable holds the number of MAC operations performed */ count = 1U; /* Working pointer of inputA */ px = pIn1; /* Working pointer of inputB */ py = pIn2; /* ------------------------ * Stage1 process * ----------------------*/ #if defined(ARM_MATH_NEON) float32x4_t vec1; float32x4_t vec2; float32x4_t res = vdupq_n_f32(0) ; float32x2_t accum = vdup_n_f32(0); #endif /* #if defined(ARM_MATH_NEON) */ /* The first stage starts here */ while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; #if defined(ARM_MATH_NEON) res = vdupq_n_f32(0) ; accum = vdup_n_f32(0); /* Compute 4 MACs simultaneously. */ k = count >> 2U; /* First part of the processing. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ while (k > 0U) { vec1 = vld1q_f32(px); vec2 = vld1q_f32(py-3); vec2 = vrev64q_f32(vec2); vec2 = vcombine_f32(vget_high_f32(vec2), vget_low_f32(vec2)); res = vmlaq_f32(res,vec1, vec2); /* Increment pointers */ px += 4; py -= 4; /* Decrement the loop counter */ k--; } accum = vpadd_f32(vget_low_f32(res), vget_high_f32(res)); sum += accum[0] + accum[1]; /* If the count is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = count & 3; #else while (k > 0U) { /* x[0] * y[srcBLen - 1] */ sum += *px++ * *py--; /* x[1] * y[srcBLen - 2] */ sum += *px++ * *py--; /* x[2] * y[srcBLen - 3] */ sum += *px++ * *py--; /* x[3] * y[srcBLen - 4] */ sum += *px++ * *py--; /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = count % 0x4U; #endif /* #if defined(ARM_MATH_NEON) */ #else /* Initialize k with number of samples */ k = count; #endif /* #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = sum; /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + count; px = pIn1; /* Increment MAC count */ count++; /* Decrement loop counter */ blockSize1--; } /* -------------------------- * Initializations of stage2 * ------------------------*/ /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ px = pIn1; /* Working pointer of inputB */ pSrc2 = pIn2 + (srcBLen - 1U); py = pSrc2; /* count is index by which the pointer pIn1 to be incremented */ count = 0U; /* ------------------- * Stage2 process * ------------------*/ /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. * So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ if (srcBLen >= 4U) { #if defined(ARM_MATH_NEON) float32x4_t c; float32x4_t x1v; float32x4_t x2v; uint32x4_t x1v_u; uint32x4_t x2v_u; uint32x4_t x_u; float32x4_t x; float32x4_t res = vdupq_n_f32(0) ; #endif /* #if defined(ARM_MATH_NEON) */ #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize2 >> 2U; while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0.0f; acc1 = 0.0f; acc2 = 0.0f; acc3 = 0.0f; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; #if defined(ARM_MATH_NEON) res = vdupq_n_f32(0) ; x1v = vld1q_f32(px); x2v = vld1q_f32(px+4); do { c = vld1q_f32(py-3); px += 4; x = x1v; res = vmlaq_n_f32(res,x,c[3]); x = vextq_f32(x1v,x2v,1); res = vmlaq_n_f32(res,x,c[2]); x = vextq_f32(x1v,x2v,2); res = vmlaq_n_f32(res,x,c[1]); x = vextq_f32(x1v,x2v,3); res = vmlaq_n_f32(res,x,c[0]); py -= 4; x1v = x2v ; x2v = vld1q_f32(px+4); } while (--k); /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen & 0x3; x1v = vld1q_f32(px); px += 4; while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *(py--); res = vmlaq_n_f32(res,x1v,c0); /* Reuse the present samples for the next MAC */ x1v[0] = x1v[1]; x1v[1] = x1v[2]; x1v[2] = x1v[3]; x1v[3] = *(px++); /* Decrement the loop counter */ k--; } acc0 = res[0]; acc1 = res[1]; acc2 = res[2]; acc3 = res[3]; #else /* read x[0], x[1], x[2] samples */ x0 = *px++; x1 = *px++; x2 = *px++; /* First part of the processing with loop unrolling. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read x[3] sample */ x3 = *(px); /* Perform the multiply-accumulate */ /* acc0 += x[0] * y[srcBLen - 1] */ acc0 += x0 * c0; /* acc1 += x[1] * y[srcBLen - 1] */ acc1 += x1 * c0; /* acc2 += x[2] * y[srcBLen - 1] */ acc2 += x2 * c0; /* acc3 += x[3] * y[srcBLen - 1] */ acc3 += x3 * c0; /* Read y[srcBLen - 2] sample */ c0 = *py--; /* Read x[4] sample */ x0 = *(px + 1U); /* Perform the multiply-accumulate */ /* acc0 += x[1] * y[srcBLen - 2] */ acc0 += x1 * c0; /* acc1 += x[2] * y[srcBLen - 2] */ acc1 += x2 * c0; /* acc2 += x[3] * y[srcBLen - 2] */ acc2 += x3 * c0; /* acc3 += x[4] * y[srcBLen - 2] */ acc3 += x0 * c0; /* Read y[srcBLen - 3] sample */ c0 = *py--; /* Read x[5] sample */ x1 = *(px + 2U); /* Perform the multiply-accumulate */ /* acc0 += x[2] * y[srcBLen - 3] */ acc0 += x2 * c0; /* acc1 += x[3] * y[srcBLen - 2] */ acc1 += x3 * c0; /* acc2 += x[4] * y[srcBLen - 2] */ acc2 += x0 * c0; /* acc3 += x[5] * y[srcBLen - 2] */ acc3 += x1 * c0; /* Read y[srcBLen - 4] sample */ c0 = *py--; /* Read x[6] sample */ x2 = *(px + 3U); px += 4U; /* Perform the multiply-accumulate */ /* acc0 += x[3] * y[srcBLen - 4] */ acc0 += x3 * c0; /* acc1 += x[4] * y[srcBLen - 4] */ acc1 += x0 * c0; /* acc2 += x[5] * y[srcBLen - 4] */ acc2 += x1 * c0; /* acc3 += x[6] * y[srcBLen - 4] */ acc3 += x2 * c0; } while (--k); /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ x3 = *px++; /* Perform the multiply-accumulate */ /* acc0 += x[4] * y[srcBLen - 5] */ acc0 += x0 * c0; /* acc1 += x[5] * y[srcBLen - 5] */ acc1 += x1 * c0; /* acc2 += x[6] * y[srcBLen - 5] */ acc2 += x2 * c0; /* acc3 += x[7] * y[srcBLen - 5] */ acc3 += x3 * c0; /* Reuse the present samples for the next MAC */ x0 = x1; x1 = x2; x2 = x3; /* Decrement the loop counter */ k--; } #endif /* #if defined(ARM_MATH_NEON) */ /* Store the result in the accumulator in the destination buffer. */ *pOut++ = acc0; *pOut++ = acc1; *pOut++ = acc2; *pOut++ = acc3; /* Increment the pointer pIn1 index, count by 4 */ count += 4U; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pSrc2; /* Decrement the loop counter */ blkCnt--; } /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ blkCnt = blockSize2 % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize2; #endif /* #if defined (ARM_MATH_LOOPUNROLL) || defined (ARM_MATH_NEON)*/ while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; #if defined(ARM_MATH_NEON) || defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; #if defined (ARM_MATH_NEON) float32x4_t res = vdupq_n_f32(0) ; float32x4_t x = vdupq_n_f32(0) ; float32x4_t y = vdupq_n_f32(0) ; float32x2_t accum = vdup_n_f32(0) ; /* First part of the processing. Compute 4 MACs at a time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ while (k > 0U) { x = vld1q_f32(px); y = vld1q_f32(py-3); y = vrev64q_f32(y); y = vcombine_f32(vget_high_f32(y), vget_low_f32(y)); res = vmlaq_f32(res,x,y); px += 4 ; py -= 4 ; /* Decrement the loop counter */ k--; } accum = vpadd_f32(vget_low_f32(res), vget_high_f32(res)); sum += accum[0] + accum[1]; /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. ** No loop unrolling is used. */ k = srcBLen & 0x3U; #else while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; sum += *px++ * *py--; sum += *px++ * *py--; sum += *px++ * *py--; /* Decrement loop counter */ k--; } /* Loop unrolling: Compute remaining outputs */ k = srcBLen % 0x4U; #endif /* if defined (ARM_MATH_NEON) */ #else /* Initialize blkCnt with number of samples */ k = srcBLen; #endif /* #if defined(ARM_MATH_NEON) || defined (ARM_MATH_LOOPUNROLL) */ while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = sum; /* Increment the MAC count */ count++; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pSrc2; /* Decrement the loop counter */ blkCnt--; } } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; /* srcBLen number of MACS should be performed */ k = srcBLen; while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = sum; /* Increment the MAC count */ count++; /* Update the inputA and inputB pointers for next MAC calculation */ px = pIn1 + count; py = pSrc2; /* Decrement the loop counter */ blkCnt--; } } /* -------------------------- * Initializations of stage3 * -------------------------*/ /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] */ /* In this stage the MAC operations are decreased by 1 for every iteration. The blockSize3 variable holds the number of MAC operations performed */ /* Working pointer of inputA */ pSrc1 = pIn1 + (srcALen - (srcBLen - 1U)); px = pSrc1; /* Working pointer of inputB */ pSrc2 = pIn2 + (srcBLen - 1U); py = pSrc2; /* ------------------- * Stage3 process * ------------------*/ while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; #if defined (ARM_MATH_LOOPUNROLL) || defined(ARM_MATH_NEON) /* Loop unrolling: Compute 4 outputs at a time */ k = blockSize3 >> 2U; #if defined(ARM_MATH_NEON) float32x4_t res = vdupq_n_f32(0) ; float32x4_t x = vdupq_n_f32(0) ; float32x4_t y = vdupq_n_f32(0) ; float32x2_t accum = vdup_n_f32(0) ; while (k > 0U) { x = vld1q_f32(px); y = vld1q_f32(py-3); y = vrev64q_f32(y); y = vcombine_f32(vget_high_f32(y), vget_low_f32(y)); res = vmlaq_f32(res,x,y); px += 4 ; py -= 4 ; /* Decrement the loop counter */ k--; } accum = vpadd_f32(vget_low_f32(res), vget_high_f32(res)); sum += accum[0] + accum[1]; #else while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ sum += *px++ * *py--; /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ sum += *px++ * *py--; /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ sum += *px++ * *py--; /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ sum += *px++ * *py--; /* Decrement loop counter */ k--; } #endif /* #if defined (ARM_MATH_NEON) */ /* Loop unrolling: Compute remaining outputs */ k = blockSize3 % 0x4U; #else /* Initialize blkCnt with number of samples */ k = blockSize3; #endif /* #if defined (ARM_MATH_NEON) || defined (ARM_MATH_LOOPUNROLL)*/ while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum += *px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ *pOut++ = sum; /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; py = pSrc2; /* Decrement the loop counter */ blockSize3--; } #else /* alternate version for CM0_FAMILY */ const float32_t *pIn1 = pSrcA; /* InputA pointer */ const float32_t *pIn2 = pSrcB; /* InputB pointer */ float32_t sum; /* Accumulator */ uint32_t i, j; /* Loop counters */ /* Loop to calculate convolution for output length number of times */ for (i = 0U; i < (srcALen + srcBLen - 1U); i++) { /* Initialize sum with zero to carry out MAC operations */ sum = 0.0f; /* Loop to perform MAC operations according to convolution equation */ for (j = 0U; j <= i; j++) { /* Check the array limitations */ if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ sum += ( pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ pDst[i] = sum; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of Conv group */
23,230
C
27.434516
179
0.530564
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_lattice_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_lattice_q31.c * Description: Q31 FIR lattice filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_Lattice @{ */ /** @brief Processing function for the Q31 FIR lattice filter. @param[in] S points to an instance of the Q31 FIR lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior In order to avoid overflows the input signal must be scaled down by 2*log2(numStages) bits. */ void arm_fir_lattice_q31( const arm_fir_lattice_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { q31_t *pState = S->pState; /* State pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *px; /* Temporary state pointer */ const q31_t *pk; /* Temporary coefficient pointer */ uint32_t numStages = S->numStages; /* Number of stages in the filter */ uint32_t blkCnt, stageCnt; /* Loop counters */ q31_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) #if defined (ARM_MATH_LOOPUNROLL) q31_t fcurr1, fnext1, gnext1; /* Temporary variables for second sample in loop unrolling */ q31_t fcurr2, fnext2, gnext2; /* Temporary variables for third sample in loop unrolling */ q31_t fcurr3, fnext3, gnext3; /* Temporary variables for fourth sample in loop unrolling */ #endif gcurr0 = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Read two samples from input buffer */ /* f0(n) = x(n) */ fcurr0 = *pSrc++; fcurr1 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* Read g0(n-1) from state buffer */ gcurr0 = *px; /* Process first sample for first tap */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Process second sample for first tap */ fnext1 = (q31_t) (((q63_t) fcurr0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + fcurr0; /* Read next two samples from input buffer */ /* f0(n+2) = x(n+2) */ fcurr2 = *pSrc++; fcurr3 = *pSrc++; /* Process third sample for first tap */ fnext2 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + fcurr1; /* Process fourth sample for first tap */ fnext3 = (q31_t) (((q63_t) fcurr2 * (*pk )) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk++)) >> 32U); gnext3 = (gnext3 << 1U) + fcurr2; /* Copy only last input sample into the state buffer which will be used for next samples processing */ *px++ = fcurr3; /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; fcurr1 = fnext1; fcurr2 = fnext2; fcurr3 = fnext3; /* Loop unrolling. Process 4 taps at a time . */ stageCnt = (numStages - 1U) >> 2U; /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numStages-3 coefficients. */ /* Process 2nd, 3rd, 4th and 5th taps ... here */ while (stageCnt > 0U) { /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = gnext3; /* Process first sample for 2nd, 6th .. tap */ /* Sample processing for K2, K6.... */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* Process second sample for 2nd, 6th .. tap */ /* for sample 2 processing */ fnext1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; /* Process third sample for 2nd, 6th .. tap */ fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; /* Process fourth sample for 2nd, 6th .. tap */ fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; /* g1(n) = f0(n) * K1 + g0(n-1) */ /* Calculation of state values for next stage */ gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = gnext3; /* Sample processing for K3, K7.... */ /* Process first sample for 3rd, 7th .. tap */ /* f3(n) = f2(n) + K3 * g2(n-1) */ fcurr0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fcurr0 = (fcurr0 << 1U) + fnext0; /* Process second sample for 3rd, 7th .. tap */ fcurr1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); fcurr1 = (fcurr1 << 1U) + fnext1; /* Process third sample for 3rd, 7th .. tap */ fcurr2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); fcurr2 = (fcurr2 << 1U) + fnext2; /* Process fourth sample for 3rd, 7th .. tap */ fcurr3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); fcurr3 = (fcurr3 << 1U) + fnext3; /* Calculation of state values for next stage */ /* g3(n) = f2(n) * K3 + g2(n-1) */ gnext3 = (q31_t) (((q63_t) fnext3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; gnext2 = (q31_t) (((q63_t) fnext2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; gnext1 = (q31_t) (((q63_t) fnext1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; gnext0 = (q31_t) (((q63_t) fnext0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = gnext3; /* Sample processing for K4, K8.... */ /* Process first sample for 4th, 8th .. tap */ /* f4(n) = f3(n) + K4 * g3(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* Process second sample for 4th, 8th .. tap */ /* for sample 2 processing */ fnext1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; /* Process third sample for 4th, 8th .. tap */ fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; /* Process fourth sample for 4th, 8th .. tap */ fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; /* g4(n) = f3(n) * K4 + g3(n-1) */ /* Calculation of state values for next stage */ gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g4(n) in state buffer */ *px++ = gnext3; /* Sample processing for K5, K9.... */ /* Process first sample for 5th, 9th .. tap */ /* f5(n) = f4(n) + K5 * g4(n-1) */ fcurr0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fcurr0 = (fcurr0 << 1U) + fnext0; /* Process second sample for 5th, 9th .. tap */ fcurr1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); fcurr1 = (fcurr1 << 1U) + fnext1; /* Process third sample for 5th, 9th .. tap */ fcurr2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); fcurr2 = (fcurr2 << 1U) + fnext2; /* Process fourth sample for 5th, 9th .. tap */ fcurr3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); fcurr3 = (fcurr3 << 1U) + fnext3; /* Calculation of state values for next stage */ /* g5(n) = f4(n) * K5 + g4(n-1) */ gnext3 = (q31_t) (((q63_t) fnext3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; gnext2 = (q31_t) (((q63_t) fnext2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; gnext1 = (q31_t) (((q63_t) fnext1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; gnext0 = (q31_t) (((q63_t) fnext0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; stageCnt--; } /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ stageCnt = (numStages - 1U) % 0x4U; while (stageCnt > 0U) { gcurr0 = *px; /* save g value in state buffer */ *px++ = gnext3; /* Process four samples for last three taps here */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; fnext1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; fcurr1 = fnext1; fcurr2 = fnext2; fcurr3 = fnext3; stageCnt--; } /* The results in the 4 accumulators, store in the destination buffer. */ /* y(n) = fN(n) */ *pDst++ = fcurr0; *pDst++ = fcurr1; *pDst++ = fcurr2; *pDst++ = fcurr3; blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* read g2(n) from state buffer */ gcurr0 = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* save g1(n) in state buffer */ *px++ = fcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = fcurr0; blkCnt--; } #else /* alternate version for CM0_FAMILY */ blkCnt = blockSize; while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* read g0(n-1) from state buffer */ gcurr0 = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext << 1U) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* save f0(n) in state buffer */ *px++ = fcurr0; /* f1(n) is saved in fcurr for next stage processing */ fcurr0 = fnext0; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g1(n-1) from state buffer */ gcurr0 = *px; /* save g0(n-1) in state buffer */ *px++ = gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = fcurr0; blkCnt--; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of FIR_Lattice group */
15,127
C
28.897233
116
0.506512
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_iir_lattice_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_iir_lattice_f32.c * Description: Floating-point IIR Lattice filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup IIR_Lattice Infinite Impulse Response (IIR) Lattice Filters This set of functions implements lattice filters for Q15, Q31 and floating-point data types. Lattice filters are used in a variety of adaptive filter applications. The filter structure has feedforward and feedback components and the net impulse response is infinite length. The functions operate on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> and <code>pDst</code> point to input and output arrays containing <code>blockSize</code> values. @par Algorithm \image html IIRLattice.gif "Infinite Impulse Response Lattice filter" @par <pre> fN(n) = x(n) fm-1(n) = fm(n) - km * gm-1(n-1) for m = N, N-1, ..., 1 gm(n) = km * fm-1(n) + gm-1(n-1) for m = N, N-1, ..., 1 y(n) = vN * gN(n) + vN-1 * gN-1(n) + ...+ v0 * g0(n) </pre> @par <code>pkCoeffs</code> points to array of reflection coefficients of size <code>numStages</code>. Reflection Coefficients are stored in time-reversed order. @par <pre> {kN, kN-1, ..., k1} </pre> @par <code>pvCoeffs</code> points to the array of ladder coefficients of size <code>(numStages+1)</code>. Ladder coefficients are stored in time-reversed order. <pre> {vN, vN-1, ..., v0} </pre> @par <code>pState</code> points to a state array of size <code>numStages + blockSize</code>. The state variables shown in the figure above (the g values) are stored in the <code>pState</code> array. The state variables are updated after each block of data is processed; the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 3 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numStages, pkCoeffs, pvCoeffs, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros and then manually initialize the instance structure as follows: <pre> arm_iir_lattice_instance_f32 S = {numStages, pState, pkCoeffs, pvCoeffs}; arm_iir_lattice_instance_q31 S = {numStages, pState, pkCoeffs, pvCoeffs}; arm_iir_lattice_instance_q15 S = {numStages, pState, pkCoeffs, pvCoeffs}; </pre> @par where <code>numStages</code> is the number of stages in the filter; <code>pState</code> points to the state buffer array; <code>pkCoeffs</code> points to array of the reflection coefficients; <code>pvCoeffs</code> points to the array of ladder coefficients. @par Fixed-Point Behavior Care must be taken when using the fixed-point versions of the IIR lattice filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. */ /** @addtogroup IIR_Lattice @{ */ /** @brief Processing function for the floating-point IIR lattice filter. @param[in] S points to an instance of the floating-point IIR lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ void arm_iir_lattice_f32( const arm_iir_lattice_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ float32_t *pStateCur; /* State current pointer */ float32_t acc; /* Accumlator */ float32_t fnext1, fnext2, gcurr1, gnext; /* Temporary variables for lattice stages */ float32_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ uint32_t numStages = S->numStages; /* Number of stages */ uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ #if defined (ARM_MATH_LOOPUNROLL) float32_t gcurr2; /* Temporary variables for lattice stages */ float32_t k1, k2; float32_t v1, v2, v3, v4; #endif /* initialise loop count */ blkCnt = blockSize; /* Sample processing */ while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fnext2 = *pSrc++; /* Initialize Ladder coeff pointer */ pv = &S->pvCoeffs[0]; /* Initialize Reflection coeff pointer */ pk = &S->pkCoeffs[0]; /* Initialize state read pointer */ px1 = pState; /* Initialize state write pointer */ px2 = pState; /* Set accumulator to zero */ acc = 0.0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numStages) >> 2U; while (tapCnt > 0U) { /* Read gN-1(n-1) from state buffer */ gcurr1 = *px1; /* read reflection coefficient kN */ k1 = *pk; /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ fnext1 = fnext2 - (k1 * gcurr1); /* read ladder coefficient vN */ v1 = *pv; /* read next reflection coefficient kN-1 */ k2 = *(pk + 1U); /* Read gN-2(n-1) from state buffer */ gcurr2 = *(px1 + 1U); /* read next ladder coefficient vN-1 */ v2 = *(pv + 1U); /* fN-2(n) = fN-1(n) - kN-1 * gN-2(n-1) */ fnext2 = fnext1 - (k2 * gcurr2); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ gnext = gcurr1 + (k1 * fnext1); /* read reflection coefficient kN-2 */ k1 = *(pk + 2U); /* write gN(n) into state for next sample processing */ *px2++ = gnext; /* Read gN-3(n-1) from state buffer */ gcurr1 = *(px1 + 2U); /* y(n) += gN(n) * vN */ acc += (gnext * v1); /* fN-3(n) = fN-2(n) - kN-2 * gN-3(n-1) */ fnext1 = fnext2 - (k1 * gcurr1); /* gN-1(n) = kN-1 * fN-2(n) + gN-2(n-1) */ gnext = gcurr2 + (k2 * fnext2); /* Read gN-4(n-1) from state buffer */ gcurr2 = *(px1 + 3U); /* y(n) += gN-1(n) * vN-1 */ acc += (gnext * v2); /* read reflection coefficient kN-3 */ k2 = *(pk + 3U); /* write gN-1(n) into state for next sample processing */ *px2++ = gnext; /* fN-4(n) = fN-3(n) - kN-3 * gN-4(n-1) */ fnext2 = fnext1 - (k2 * gcurr2); /* gN-2(n) = kN-2 * fN-3(n) + gN-3(n-1) */ gnext = gcurr1 + (k1 * fnext1); /* read ladder coefficient vN-2 */ v3 = *(pv + 2U); /* y(n) += gN-2(n) * vN-2 */ acc += (gnext * v3); /* write gN-2(n) into state for next sample processing */ *px2++ = gnext; /* update pointer */ pk += 4U; /* gN-3(n) = kN-3 * fN-4(n) + gN-4(n-1) */ gnext = (fnext2 * k2) + gcurr2; /* read next ladder coefficient vN-3 */ v4 = *(pv + 3U); /* y(n) += gN-4(n) * vN-4 */ acc += (gnext * v4); /* write gN-3(n) into state for next sample processing */ *px2++ = gnext; /* update pointers */ px1 += 4U; pv += 4U; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numStages % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numStages; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { gcurr1 = *px1++; /* Process sample for last taps */ fnext1 = fnext2 - ((*pk) * gcurr1); gnext = (fnext1 * (*pk++)) + gcurr1; /* Output samples for last taps */ acc += (gnext * (*pv++)); *px2++ = gnext; fnext2 = fnext1; /* Decrement loop counter */ tapCnt--; } /* y(n) += g0(n) * v0 */ acc += (fnext2 * (*pv)); *px2++ = fnext2; /* write out into pDst */ *pDst++ = acc; /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy last S->numStages samples to start of the buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; /* Copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numStages >> 2U; while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numStages % 0x4U; #else /* Initialize blkCnt with number of samples */ tapCnt = numStages; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of IIR_Lattice group */
11,556
C
31.554929
154
0.575718
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_sparse_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_sparse_q15.c * Description: Q15 sparse FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_Sparse @{ */ /** @brief Processing function for the Q15 sparse FIR filter. @param[in] S points to an instance of the Q15 sparse FIR structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @param[in] pScratchOut points to a temporary buffer of size blockSize @param[in] blockSize number of input samples to process per call @return none @par Scaling and Overflow Behavior The function is implemented using an internal 32-bit accumulator. The 1.15 x 1.15 multiplications yield a 2.30 result and these are added to a 2.30 accumulator. Thus the full precision of the multiplications is maintained but there is only a single guard bit in the accumulator. If the accumulator result overflows it will wrap around rather than saturate. After all multiply-accumulates are performed, the 2.30 accumulator is truncated to 2.15 format and then saturated to 1.15 format. In order to avoid overflows the input signal or coefficients must be scaled down by log2(numTaps) bits. */ void arm_fir_sparse_q15( arm_fir_sparse_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, q15_t * pScratchIn, q31_t * pScratchOut, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *px; /* Temporary pointers for scratch buffer */ q15_t *py = pState; /* Temporary pointers for state buffer */ q15_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ q15_t *pOut = pDst; /* Working pointer for output */ int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ uint32_t delaySize = S->maxDelay + blockSize; /* state length */ uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ int32_t readIndex; /* Read index of the state buffer */ uint32_t tapCnt, blkCnt; /* loop counters */ q31_t *pScr2 = pScratchOut; /* Working pointer for scratch buffer of output values */ q15_t coeff = *pCoeffs++; /* Read the first coefficient value */ #if defined (ARM_MATH_LOOPUNROLL) q31_t in1, in2; /* Temporary variables */ #endif /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ arm_circularWrite_q15(py, (int32_t) delaySize, &S->stateIndex, 1,pSrc, 1, blockSize); /* Loop over the number of taps. */ tapCnt = numTaps; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_q15(py, (int32_t) delaySize, &readIndex, 1, pb, pb, (int32_t) blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform multiplication and store in the scratch buffer */ *pScratchOut++ = ((q31_t) *px++ * coeff); *pScratchOut++ = ((q31_t) *px++ * coeff); *pScratchOut++ = ((q31_t) *px++ * coeff); *pScratchOut++ = ((q31_t) *px++ * coeff); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiplication and store in the scratch buffer */ *pScratchOut++ = ((q31_t) *px++ * coeff); /* Decrement loop counter */ blkCnt--; } /* Load the coefficient value and * increment the coefficient buffer for the next set of state values */ coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Loop over the number of taps. */ tapCnt = (uint32_t) numTaps - 2U; while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_q15(py, (int32_t) delaySize, &readIndex, 1, pb, pb, (int32_t) blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pScratchOut++ += (q31_t) *px++ * coeff; *pScratchOut++ += (q31_t) *px++ * coeff; *pScratchOut++ += (q31_t) *px++ * coeff; *pScratchOut++ += (q31_t) *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pScratchOut++ += (q31_t) *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Load the coefficient value and * increment the coefficient buffer for the next set of state values */ coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Decrement loop counter */ tapCnt--; } /* Compute last tap without the final read of pTapDelay */ /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_q15(py, (int32_t) delaySize, &readIndex, 1, pb, pb, (int32_t) blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pScratchOut++ += (q31_t) *px++ * coeff; *pScratchOut++ += (q31_t) *px++ * coeff; *pScratchOut++ += (q31_t) *px++ * coeff; *pScratchOut++ += (q31_t) *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pScratchOut++ += (q31_t) *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* All the output values are in pScratchOut buffer. Convert them into 1.15 format, saturate and store in the destination buffer. */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { in1 = *pScr2++; in2 = *pScr2++; #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in1 >> 15, 16), (q15_t) __SSAT(in2 >> 15, 16), 16)); #else write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in2 >> 15, 16), (q15_t) __SSAT(in1 >> 15, 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ in1 = *pScr2++; in2 = *pScr2++; #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in1 >> 15, 16), (q15_t) __SSAT(in2 >> 15, 16), 16)); #else write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in2 >> 15, 16), (q15_t) __SSAT(in1 >> 15, 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { *pOut++ = (q15_t) __SSAT(*pScr2++ >> 15, 16); /* Decrement loop counter */ blkCnt--; } } /** @} end of FIR_Sparse group */
10,592
C
29.973684
148
0.597432
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_lattice_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_lattice_q15.c * Description: Q15 FIR lattice filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_Lattice @{ */ /** @brief Processing function for Q15 FIR lattice filter. @param[in] S points to an instance of the Q15 FIR lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ void arm_fir_lattice_q15( const arm_fir_lattice_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *px; /* Temporary state pointer */ const q15_t *pk; /* Temporary coefficient pointer */ uint32_t numStages = S->numStages; /* Number of stages in the filter */ uint32_t blkCnt, stageCnt; /* Loop counters */ q31_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) #if defined (ARM_MATH_LOOPUNROLL) q31_t fcurr1, fnext1, gnext1; /* Temporary variables for second sample in loop unrolling */ q31_t fcurr2, fnext2, gnext2; /* Temporary variables for third sample in loop unrolling */ q31_t fcurr3, fnext3, gnext3; /* Temporary variables for fourth sample in loop unrolling */ #endif gcurr0 = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Read two samples from input buffer */ /* f0(n) = x(n) */ fcurr0 = *pSrc++; fcurr1 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* Read g0(n-1) from state buffer */ gcurr0 = *px; /* Process first sample for first tap */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (q31_t) ((fcurr0 * (*pk)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Process second sample for first tap */ fnext1 = (q31_t) ((fcurr0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + fcurr0; gnext1 = __SSAT(gnext1, 16); /* Read next two samples from input buffer */ /* f0(n+2) = x(n+2) */ fcurr2 = *pSrc++; fcurr3 = *pSrc++; /* Process third sample for first tap */ fnext2 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + fcurr1; gnext2 = __SSAT(gnext2, 16); /* Process fourth sample for first tap */ fnext3 = (q31_t) ((fcurr2 * (*pk )) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); gnext3 = (q31_t) ((fcurr3 * (*pk++)) >> 15U) + fcurr2; gnext3 = __SSAT(gnext3, 16); /* Copy only last input sample into the state buffer which will be used for next samples processing */ *px++ = (q15_t) fcurr3; /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; fcurr1 = fnext1; fcurr2 = fnext2; fcurr3 = fnext3; /* Loop unrolling. Process 4 taps at a time . */ stageCnt = (numStages - 1U) >> 2U; /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numStages-3 coefficients. */ /* Process 2nd, 3rd, 4th and 5th taps ... here */ while (stageCnt > 0U) { /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = (q15_t) gnext3; /* Process first sample for 2nd, 6th .. tap */ /* Sample processing for K2, K6.... */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* Process second sample for 2nd, 6th .. tap */ /* for sample 2 processing */ fnext1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); /* Process third sample for 2nd, 6th .. tap */ fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); /* Process fourth sample for 2nd, 6th .. tap */ fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ /* Calculation of state values for next stage */ gnext3 = (q31_t) ((fcurr3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); gnext0 = (q31_t) ((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = (q15_t) gnext3; /* Sample processing for K3, K7.... */ /* Process first sample for 3rd, 7th .. tap */ /* f3(n) = f2(n) + K3 * g2(n-1) */ fcurr0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fnext0; fcurr0 = __SSAT(fcurr0, 16); /* Process second sample for 3rd, 7th .. tap */ fcurr1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fnext1; fcurr1 = __SSAT(fcurr1, 16); /* Process third sample for 3rd, 7th .. tap */ fcurr2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fnext2; fcurr2 = __SSAT(fcurr2, 16); /* Process fourth sample for 3rd, 7th .. tap */ fcurr3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fnext3; fcurr3 = __SSAT(fcurr3, 16); /* Calculation of state values for next stage */ /* g3(n) = f2(n) * K3 + g2(n-1) */ gnext3 = (q31_t) ((fnext3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); gnext2 = (q31_t) ((fnext2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); gnext1 = (q31_t) ((fnext1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); gnext0 = (q31_t) ((fnext0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = (q15_t) gnext3; /* Sample processing for K4, K8.... */ /* Process first sample for 4th, 8th .. tap */ /* f4(n) = f3(n) + K4 * g3(n-1) */ fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* Process second sample for 4th, 8th .. tap */ /* for sample 2 processing */ fnext1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); /* Process third sample for 4th, 8th .. tap */ fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); /* Process fourth sample for 4th, 8th .. tap */ fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); /* g4(n) = f3(n) * K4 + g3(n-1) */ /* Calculation of state values for next stage */ gnext3 = (q31_t) ((fcurr3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); gnext0 = (q31_t) ((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g4(n) in state buffer */ *px++ = (q15_t) gnext3; /* Sample processing for K5, K9.... */ /* Process first sample for 5th, 9th .. tap */ /* f5(n) = f4(n) + K5 * g4(n-1) */ fcurr0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fnext0; fcurr0 = __SSAT(fcurr0, 16); /* Process second sample for 5th, 9th .. tap */ fcurr1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fnext1; fcurr1 = __SSAT(fcurr1, 16); /* Process third sample for 5th, 9th .. tap */ fcurr2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fnext2; fcurr2 = __SSAT(fcurr2, 16); /* Process fourth sample for 5th, 9th .. tap */ fcurr3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fnext3; fcurr3 = __SSAT(fcurr3, 16); /* Calculation of state values for next stage */ /* g5(n) = f4(n) * K5 + g4(n-1) */ gnext3 = (q31_t) ((fnext3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); gnext2 = (q31_t) ((fnext2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); gnext1 = (q31_t) ((fnext1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); gnext0 = (q31_t) ((fnext0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); stageCnt--; } /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ stageCnt = (numStages - 1U) % 0x4U; while (stageCnt > 0U) { gcurr0 = *px; /* save g value in state buffer */ *px++ = (q15_t) gnext3; /* Process four samples for last three taps here */ fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); fnext1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext3 = (q31_t) ((fcurr3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); gnext0 = (q31_t) ((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; fcurr1 = fnext1; fcurr2 = fnext2; fcurr3 = fnext3; stageCnt--; } /* The results in the 4 accumulators, store in the destination buffer. */ /* y(n) = fN(n) */ #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pDst, __PKHBT(fcurr0, fcurr1, 16)); write_q15x2_ia (&pDst, __PKHBT(fcurr2, fcurr3, 16)); #else write_q15x2_ia (&pDst, __PKHBT(fcurr1, fcurr0, 16)); write_q15x2_ia (&pDst, __PKHBT(fcurr3, fcurr2, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* read g2(n) from state buffer */ gcurr0 = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = (((q31_t) gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = (((q31_t) fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* save g1(n) in state buffer */ *px++ = (q15_t) fcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr0 = *px; /* save g1(n) in state buffer */ *px++ = (q15_t) gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext0 = (((q31_t) gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext0 = (((q31_t) fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = __SSAT(fcurr0, 16); blkCnt--; } #else /* alternate version for CM0_FAMILY */ blkCnt = blockSize; while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pk = pCoeffs; /* read g0(n-1) from state buffer */ gcurr0 = *px; /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ fnext0 = ((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ gnext0 = ((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* save f0(n) in state buffer */ *px++ = (q15_t) fcurr0; /* f1(n) is saved in fcurr for next stage processing */ fcurr0 = fnext0; stageCnt = (numStages - 1U); /* stage loop */ while (stageCnt > 0U) { /* read g1(n-1) from state buffer */ gcurr0 = *px; /* save g0(n-1) in state buffer */ *px++ = (q15_t) gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ fnext0 = ((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g2(n) = f1(n) * K2 + g1(n-1) */ gnext0 = ((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; stageCnt--; } /* y(n) = fN(n) */ *pDst++ = __SSAT(fcurr0, 16); blkCnt--; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of FIR_Lattice group */
15,012
C
28.61144
110
0.515987
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df2T_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_f32.c * Description: Processing function for floating-point transposed direct form II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF2T @{ */ /** @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. @param[in] S points to an instance of the filter data structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ #if defined(ARM_MATH_NEON) void arm_biquad_cascade_df2T_f32( const arm_biquad_cascade_df2T_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { const float32_t *pIn = pSrc; /* source pointer */ float32_t *pOut = pDst; /* destination pointer */ float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* coefficient pointer */ float32_t acc1; /* accumulator */ float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ float32_t Xn1; /* temporary input */ float32_t d1, d2; /* state variables */ uint32_t sample, stageCnt,stage = S->numStages; /* loop counters */ float32_t Xn2, Xn3, Xn4; /* Input State variables */ float32_t acc2, acc3, acc4; /* accumulator */ float32_t p0, p1, p2, p3, p4, A1; float32x4_t XnV, YnV; float32x4x2_t dV; float32x4_t zeroV = vdupq_n_f32(0.0); float32x4_t t1,t2,t3,t4,b1V,b2V,a1V,a2V,s; /* Loop unrolling. Compute 4 outputs at a time */ stageCnt = stage >> 2; while (stageCnt > 0U) { /* Reading the coefficients */ t1 = vld1q_f32(pCoeffs); pCoeffs += 4; t2 = vld1q_f32(pCoeffs); pCoeffs += 4; t3 = vld1q_f32(pCoeffs); pCoeffs += 4; t4 = vld1q_f32(pCoeffs); pCoeffs += 4; b1V = vld1q_f32(pCoeffs); pCoeffs += 4; b2V = vld1q_f32(pCoeffs); pCoeffs += 4; a1V = vld1q_f32(pCoeffs); pCoeffs += 4; a2V = vld1q_f32(pCoeffs); pCoeffs += 4; /* Reading the state values */ dV = vld2q_f32(pState); sample = blockSize; while (sample > 0U) { /* y[n] = b0 * x[n] + d1 */ /* d1 = b1 * x[n] + a1 * y[n] + d2 */ /* d2 = b2 * x[n] + a2 * y[n] */ XnV = vdupq_n_f32(*pIn++); s = dV.val[0]; YnV = s; s = vextq_f32(zeroV,dV.val[0],3); YnV = vmlaq_f32(YnV, t1, s); s = vextq_f32(zeroV,dV.val[0],2); YnV = vmlaq_f32(YnV, t2, s); s = vextq_f32(zeroV,dV.val[0],1); YnV = vmlaq_f32(YnV, t3, s); YnV = vmlaq_f32(YnV, t4, XnV); s = vextq_f32(XnV,YnV,3); dV.val[0] = vmlaq_f32(dV.val[1], s, b1V); dV.val[0] = vmlaq_f32(dV.val[0], YnV, a1V); dV.val[1] = vmulq_f32(s, b2V); dV.val[1] = vmlaq_f32(dV.val[1], YnV, a2V); *pOut++ = YnV[3]; sample--; } /* Store the updated state variables back into the state array */ vst2q_f32(pState,dV); pState += 8; /* The current stage input is given as the output to the next stage */ pIn = pDst; /*Reset the output working pointer */ pOut = pDst; /* decrement the loop counter */ stageCnt--; } /* Tail */ stageCnt = stage & 3; while (stageCnt > 0U) { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; a2 = *pCoeffs++; /*Reading the state values */ d1 = pState[0]; d2 = pState[1]; sample = blockSize; while (sample > 0U) { /* Read the input */ Xn1 = *pIn++; /* y[n] = b0 * x[n] + d1 */ acc1 = (b0 * Xn1) + d1; /* Store the result in the accumulator in the destination buffer. */ *pOut++ = acc1; /* Every time after the output is computed state should be updated. */ /* d1 = b1 * x[n] + a1 * y[n] + d2 */ d1 = ((b1 * Xn1) + (a1 * acc1)) + d2; /* d2 = b2 * x[n] + a2 * y[n] */ d2 = (b2 * Xn1) + (a2 * acc1); /* decrement the loop counter */ sample--; } /* Store the updated state variables back into the state array */ *pState++ = d1; *pState++ = d2; /* The current stage input is given as the output to the next stage */ pIn = pDst; /*Reset the output working pointer */ pOut = pDst; /* decrement the loop counter */ stageCnt--; } } #else LOW_OPTIMIZATION_ENTER void arm_biquad_cascade_df2T_f32( const arm_biquad_cascade_df2T_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { const float32_t *pIn = pSrc; /* Source pointer */ float32_t *pOut = pDst; /* Destination pointer */ float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t acc1; /* Accumulator */ float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ float32_t Xn1; /* Temporary input */ float32_t d1, d2; /* State variables */ uint32_t sample, stage = S->numStages; /* Loop counters */ do { /* Reading the coefficients */ b0 = pCoeffs[0]; b1 = pCoeffs[1]; b2 = pCoeffs[2]; a1 = pCoeffs[3]; a2 = pCoeffs[4]; /* Reading the state values */ d1 = pState[0]; d2 = pState[1]; pCoeffs += 5U; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 16 outputs at a time */ sample = blockSize >> 4U; while (sample > 0U) { /* y[n] = b0 * x[n] + d1 */ /* d1 = b1 * x[n] + a1 * y[n] + d2 */ /* d2 = b2 * x[n] + a2 * y[n] */ /* 1 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 2 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 3 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 4 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 5 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 6 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 7 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 8 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 9 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 10 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 11 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 12 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 13 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 14 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 15 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 16 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = blockSize & 0xFU; #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* decrement loop counter */ sample--; } /* Store the updated state variables back into the state array */ pState[0] = d1; pState[1] = d2; pState += 2U; /* The current stage input is given as the output to the next stage */ pIn = pDst; /* Reset the output working pointer */ pOut = pDst; /* decrement loop counter */ stage--; } while (stage > 0U); } LOW_OPTIMIZATION_EXIT #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of BiquadCascadeDF2T group */
11,514
C
20.975191
108
0.453795
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_init_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_init_q15.c * Description: Q15 FIR filter initialization function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR @{ */ /** @brief Initialization function for the Q15 FIR filter. @param[in,out] S points to an instance of the Q15 FIR filter structure. @param[in] numTaps number of filter coefficients in the filter. Must be even and greater than or equal to 4. @param[in] pCoeffs points to the filter coefficients buffer. @param[in] pState points to the state buffer. @param[in] blockSize number of samples processed per call. @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : <code>numTaps</code> is not greater than or equal to 4 and even @par Details <code>pCoeffs</code> points to the array of filter coefficients stored in time reversed order: <pre> {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} </pre> Note that <code>numTaps</code> must be even and greater than or equal to 4. To implement an odd length filter simply increase <code>numTaps</code> by 1 and set the last coefficient to zero. For example, to implement a filter with <code>numTaps=3</code> and coefficients <pre> {0.3, -0.8, 0.3} </pre> set <code>numTaps=4</code> and use the coefficients: <pre> {0.3, -0.8, 0.3, 0}. </pre> Similarly, to implement a two point filter <pre> {0.3, -0.3} </pre> set <code>numTaps=4</code> and use the coefficients: <pre> {0.3, -0.3, 0, 0}. </pre> <code>pState</code> points to the array of state variables. <code>pState</code> is of length <code>numTaps+blockSize</code>, when running on Cortex-M4 and Cortex-M3 and is of length <code>numTaps+blockSize-1</code>, when running on Cortex-M0 where <code>blockSize</code> is the number of input samples processed by each call to <code>arm_fir_q15()</code>. */ arm_status arm_fir_init_q15( arm_fir_instance_q15 * S, uint16_t numTaps, const q15_t * pCoeffs, q15_t * pState, uint32_t blockSize) { arm_status status; #if defined (ARM_MATH_DSP) /* The Number of filter coefficients in the filter must be even and at least 4 */ if (numTaps & 0x1U) { status = ARM_MATH_ARGUMENT_ERROR; } else { /* Assign filter taps */ S->numTaps = numTaps; /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; /* Clear the state buffer. The size is always (blockSize + numTaps ) */ memset(pState, 0, (numTaps + (blockSize)) * sizeof(q15_t)); /* Assign state pointer */ S->pState = pState; status = ARM_MATH_SUCCESS; } return (status); #else /* Assign filter taps */ S->numTaps = numTaps; /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; /* Clear state buffer. The size is always (blockSize + numTaps - 1) */ memset(pState, 0, (numTaps + (blockSize - 1U)) * sizeof(q15_t)); /* Assign state pointer */ S->pState = pState; status = ARM_MATH_SUCCESS; return (status); #endif /* #if defined (ARM_MATH_DSP) */ } /** @} end of FIR group */
4,319
C
30.304348
315
0.604307
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_lms_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_lms_q31.c * Description: Processing function for the Q31 LMS filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup LMS @{ */ /** @brief Processing function for Q31 LMS filter. @param[in] S points to an instance of the Q31 LMS filter structure. @param[in] pSrc points to the block of input data. @param[in] pRef points to the block of reference data. @param[out] pOut points to the block of output data. @param[out] pErr points to the block of error data. @param[in] blockSize number of samples to process. @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clips. In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. The reference signal should not be scaled down. After all multiply-accumulates are performed, the 2.62 accumulator is shifted and saturated to 1.31 format to yield the final result. The output signal and error signal are in 1.31 format. @par In this filter, filter coefficients are updated for each sample and the updation of filter cofficients are saturted. */ void arm_lms_q31( const arm_lms_instance_q31 * S, const q31_t * pSrc, q31_t * pRef, q31_t * pOut, q31_t * pErr, uint32_t blockSize) { q31_t *pState = S->pState; /* State pointer */ q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *pStateCurnt; /* Points to the current sample of the state */ q31_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ q31_t mu = S->mu; /* Adaptive factor */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t tapCnt, blkCnt; /* Loop counters */ q63_t acc; /* Accumulator */ q31_t e = 0; /* Error of data sample */ q31_t alpha; /* Intermediate constant for taps update */ q31_t coef; /* Temporary variable for coef */ q31_t acc_l, acc_h; /* Temporary input */ uint32_t uShift = ((uint32_t) S->postShift + 1U); uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; /* Initialize pState pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Set the accumulator to zero */ acc = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] */ acc += ((q63_t) (*px++)) * (*pb++); /* acc += b[N-1] * x[n-N-1] */ acc += ((q63_t) (*px++)) * (*pb++); /* acc += b[N-2] * x[n-N-2] */ acc += ((q63_t) (*px++)) * (*pb++); /* acc += b[N-3] * x[n-N-3] */ acc += ((q63_t) (*px++)) * (*pb++); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += ((q63_t) (*px++)) * (*pb++); /* Decrement the loop counter */ tapCnt--; } /* Converting the result to 1.31 format */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; acc = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Store the result from accumulator into the destination buffer. */ *pOut++ = (q31_t) acc; /* Compute and store error */ e = *pRef++ - (q31_t) acc; *pErr++ = e; /* Compute alpha i.e. intermediate constant for taps update */ alpha = (q31_t) (((q63_t) e * mu) >> 31); /* Initialize pState pointer */ /* Advance state pointer by 1 for the next sample */ px = pState++; /* Initialize coefficient pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* coef is in 2.30 format */ coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); /* get coef in 1.31 format by left shifting */ *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); /* update coefficient buffer to next coefficient */ pb++; coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); pb++; coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); pb++; coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); pb++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); pb++; /* Decrement loop counter */ tapCnt--; } /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the pState buffer */ pStateCurnt = S->pState; /* copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of LMS group */
8,659
C
29.492958
113
0.542788
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_interpolate_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_interpolate_q31.c * Description: Q31 FIR interpolation * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_Interpolate @{ */ /** @brief Processing function for the Q31 FIR interpolator. @param[in] S points to an instance of the Q31 FIR interpolator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by <code>1/(numTaps/L)</code>. since <code>numTaps/L</code> additions occur per output sample. After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. */ void arm_fir_interpolate_q31( const arm_fir_interpolate_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) q31_t *pState = S->pState; /* State pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *pStateCur; /* Points to the current sample of the state */ q31_t *ptr1; /* Temporary pointer for state buffer */ const q31_t *ptr2; /* Temporary pointer for coefficient buffer */ q63_t sum0; /* Accumulators */ uint32_t i, blkCnt, tapCnt; /* Loop counters */ uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ uint32_t j; #if defined (ARM_MATH_LOOPUNROLL) q63_t acc0, acc1, acc2, acc3; q31_t x0, x1, x2, x3; q31_t c0, c1, c2, c3; #endif /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (phaseLen - 1U); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = (S->L); while (i > 0U) { /* Set accumulator to zero */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Unroll by a factor of 4. Repeat until we've computed numTaps-(4*S->L) coefficients. */ tapCnt = phaseLen >> 2U; x0 = *(ptr1++); x1 = *(ptr1++); x2 = *(ptr1++); while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); /* Read the coefficient */ c0 = *(ptr2); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Read the coefficient */ c1 = *(ptr2 + S->L); /* Read the input sample */ x0 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x1 * c1; acc1 += (q63_t) x2 * c1; acc2 += (q63_t) x3 * c1; acc3 += (q63_t) x0 * c1; /* Read the coefficient */ c2 = *(ptr2 + S->L * 2); /* Read the input sample */ x1 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x2 * c2; acc1 += (q63_t) x3 * c2; acc2 += (q63_t) x0 * c2; acc3 += (q63_t) x1 * c2; /* Read the coefficient */ c3 = *(ptr2 + S->L * 3); /* Read the input sample */ x2 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x3 * c3; acc1 += (q63_t) x0 * c3; acc2 += (q63_t) x1 * c3; acc3 += (q63_t) x2 * c3; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += 4 * S->L; /* Decrement loop counter */ tapCnt--; } /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ tapCnt = phaseLen % 0x4U; while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); /* Read the coefficient */ c0 = *(ptr2); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* update states for next sample processing */ x0 = x1; x1 = x2; x2 = x3; /* Decrement loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *(pDst ) = (q31_t) (acc0 >> 31); *(pDst + S->L) = (q31_t) (acc1 >> 31); *(pDst + 2 * S->L) = (q31_t) (acc2 >> 31); *(pDst + 3 * S->L) = (q31_t) (acc3 >> 31); pDst++; /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 4; pDst += S->L * 3; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Repeat until we've computed numTaps-(4*S->L) coefficients. */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = phaseLen >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += (q63_t) *ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; sum0 += (q63_t) *ptr1++ * *ptr2; ptr2 += S->L; sum0 += (q63_t) *ptr1++ * *ptr2; ptr2 += S->L; sum0 += (q63_t) *ptr1++ * *ptr2; ptr2 += S->L; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = phaseLen % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = phaseLen; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += (q63_t) *ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = (q31_t) (sum0 >> 31); /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement the loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement the loop counter */ blkCnt--; } /* Processing is complete. Now copy the last phaseLen - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = (phaseLen - 1U) >> 2U; /* copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = (phaseLen - 1U) % 0x04U; #else /* Initialize tapCnt with number of samples */ tapCnt = (phaseLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #else /* alternate version for CM0_FAMILY */ q31_t *pState = S->pState; /* State pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *pStateCur; /* Points to the current sample of the state */ q31_t *ptr1; /* Temporary pointer for state buffer */ const q31_t *ptr2; /* Temporary pointer for coefficient buffer */ q63_t sum0; /* Accumulators */ uint32_t i, blkCnt, tapCnt; /* Loop counters */ uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (phaseLen - 1U); /* Total number of intput samples */ blkCnt = blockSize; /* Loop over the blockSize. */ while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (i - 1U); /* Loop over the polyPhase length */ tapCnt = phaseLen; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += ((q63_t) *ptr1++ * *ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement the loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = (q31_t) (sum0 >> 31); /* Decrement loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. ** Now copy the last phaseLen - 1 samples to the start of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; tapCnt = phaseLen - 1U; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of FIR_Interpolate group */
13,596
C
27.209544
162
0.548838
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_fast_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_fast_q31.c * Description: Processing function for the Q31 Fast Biquad cascade DirectFormI(DF1) filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF1 @{ */ /** @brief Processing function for the Q31 Biquad cascade filter (fast variant). @param[in] S points to an instance of the Q31 Biquad cascade structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process per call @return none @par Scaling and Overflow Behavior This function is optimized for speed at the expense of fixed-point precision and overflow protection. The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format. These intermediate results are added to a 2.30 accumulator. Finally, the accumulator is saturated and converted to a 1.31 result. The fast version has the same overflow behavior as the standard version and provides less precision since it discards the low 32 bits of each multiplication result. In order to avoid overflows completely the input signal must be scaled down by two bits and lie in the range [-0.25 +0.25). Use the intialization function arm_biquad_cascade_df1_init_q31() to initialize filter structure. @remark Refer to \ref arm_biquad_cascade_df1_q31() for a slower implementation of this function which uses 64-bit accumulation to provide higher precision. Both the slow and the fast versions use the same instance structure. Use the function \ref arm_biquad_cascade_df1_init_q31() to initialize the filter structure. */ void arm_biquad_cascade_df1_fast_q31( const arm_biquad_casd_df1_inst_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { const q31_t *pIn = pSrc; /* Source pointer */ q31_t *pOut = pDst; /* Destination pointer */ q31_t *pState = S->pState; /* pState pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t acc = 0; /* Accumulator */ q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ q31_t Xn1, Xn2, Yn1, Yn2; /* Filter pState variables */ q31_t Xn; /* Temporary input */ int32_t shift = (int32_t) S->postShift + 1; /* Shift to be applied to the output */ uint32_t sample, stage = S->numStages; /* Loop counters */ do { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; a2 = *pCoeffs++; /* Reading the pState values */ Xn1 = pState[0]; Xn2 = pState[1]; Yn1 = pState[2]; Yn2 = pState[3]; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 output values simultaneously. */ /* Variables acc ... acc3 hold output values that are being computed: * * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* Loop unrolling: Compute 4 outputs at a time */ sample = blockSize >> 2U; while (sample > 0U) { /* Read the input */ Xn = *pIn; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ /* acc = (q31_t) (((q63_t) b1 * Xn1) >> 32);*/ mult_32x32_keep32_R(acc, b1, Xn1); /* acc += b1 * x[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b0 * (Xn))) >> 32);*/ multAcc_32x32_keep32_R(acc, b0, Xn); /* acc += b[2] * x[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, b2, Xn2); /* acc += a1 * y[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, a1, Yn1); /* acc += a2 * y[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, a2, Yn2); /* The result is converted to 1.31 , Yn2 variable is reused */ Yn2 = acc << shift; /* Read the second input */ Xn2 = *(pIn + 1U); /* Store the output in the destination buffer. */ *pOut = Yn2; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ /* acc = (q31_t) (((q63_t) b0 * (Xn2)) >> 32);*/ mult_32x32_keep32_R(acc, b0, Xn2); /* acc += b1 * x[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn))) >> 32);*/ multAcc_32x32_keep32_R(acc, b1, Xn); /* acc += b[2] * x[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, b2, Xn1); /* acc += a1 * y[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, a1, Yn2); /* acc += a2 * y[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, a2, Yn1); /* The result is converted to 1.31, Yn1 variable is reused */ Yn1 = acc << shift; /* Read the third input */ Xn1 = *(pIn + 2U); /* Store the output in the destination buffer. */ *(pOut + 1U) = Yn1; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ /* acc = (q31_t) (((q63_t) b0 * (Xn1)) >> 32);*/ mult_32x32_keep32_R(acc, b0, Xn1); /* acc += b1 * x[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, b1, Xn2); /* acc += b[2] * x[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn))) >> 32);*/ multAcc_32x32_keep32_R(acc, b2, Xn); /* acc += a1 * y[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, a1, Yn1); /* acc += a2 * y[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, a2, Yn2); /* The result is converted to 1.31, Yn2 variable is reused */ Yn2 = acc << shift; /* Read the forth input */ Xn = *(pIn + 3U); /* Store the output in the destination buffer. */ *(pOut + 2U) = Yn2; pIn += 4U; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ /* acc = (q31_t) (((q63_t) b0 * (Xn)) >> 32);*/ mult_32x32_keep32_R(acc, b0, Xn); /* acc += b1 * x[n-1] */ /*acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, b1, Xn1); /* acc += b[2] * x[n-2] */ /*acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, b2, Xn2); /* acc += a1 * y[n-1] */ /*acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, a1, Yn2); /* acc += a2 * y[n-2] */ /*acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, a2, Yn1); /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ Xn2 = Xn1; /* The result is converted to 1.31, Yn1 variable is reused */ Yn1 = acc << shift; /* Xn1 = Xn */ Xn1 = Xn; /* Store the output in the destination buffer. */ *(pOut + 3U) = Yn1; pOut += 4U; /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = (blockSize & 0x3U); #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { /* Read the input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ /* acc = (q31_t) (((q63_t) b0 * (Xn)) >> 32);*/ mult_32x32_keep32_R(acc, b0, Xn); /* acc += b1 * x[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, b1, Xn1); /* acc += b[2] * x[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, b2, Xn2); /* acc += a1 * y[n-1] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn1))) >> 32);*/ multAcc_32x32_keep32_R(acc, a1, Yn1); /* acc += a2 * y[n-2] */ /* acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn2))) >> 32);*/ multAcc_32x32_keep32_R(acc, a2, Yn2); /* The result is converted to 1.31 */ acc = acc << shift; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; Yn1 = acc; /* Store the output in the destination buffer. */ *pOut++ = acc; /* decrement loop counter */ sample--; } /* The first stage goes from the input buffer to the output buffer. */ /* Subsequent stages occur in-place in the output buffer */ pIn = pDst; /* Reset to destination pointer */ pOut = pDst; /* Store the updated state variables back into the pState array */ *pState++ = Xn1; *pState++ = Xn2; *pState++ = Yn1; *pState++ = Yn2; } while (--stage); } /** @} end of BiquadCascadeDF1 group */
11,053
C
36.218855
183
0.499774
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_correlate_opt_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_correlate_opt_q15.c * Description: Correlation of Q15 sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup Corr @{ */ /** @brief Correlation of Q15 sequences. @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1. @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. @return none @par Scaling and Overflow Behavior The function is implemented using a 64-bit internal accumulator. Both inputs are in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. This approach provides 33 guard bits and there is no risk of overflow. The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format. @remark Refer to \ref arm_correlate_fast_q15() for a faster but less precise version of this function. */ void arm_correlate_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, q15_t * pScratch) { q63_t acc0; /* Accumulators */ q15_t *pOut = pDst; /* Output pointer */ q15_t *pScr1; /* Temporary pointer for scratch1 */ const q15_t *pIn1; /* InputA pointer */ const q15_t *pIn2; /* InputB pointer */ const q15_t *py; /* Intermediate inputB pointer */ uint32_t j, blkCnt, outBlockSize; /* Loop counter */ int32_t inc = 1; /* Output pointer increment */ uint32_t tapCnt; #if defined (ARM_MATH_LOOPUNROLL) q63_t acc1, acc2, acc3; /* Accumulators */ q31_t x1, x2, x3; /* Temporary variables for holding input1 and input2 values */ q31_t y1, y2; /* State variables */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ /* But CORR(x, y) is reverse of CORR(y, x) */ /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */ /* and the destination pointer modifier, inc is set to -1 */ /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */ /* But to improve the performance, * we include zeroes in the output instead of zero padding either of the the inputs*/ /* If srcALen > srcBLen, * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */ /* If srcALen < srcBLen, * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */ if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; /* Number of output samples is calculated */ outBlockSize = (srcALen * 2U) - 1U; /* When srcALen > srcBLen, zero padding is done to srcB * to make their lengths equal. * Instead, (outBlockSize - (srcALen + srcBLen - 1)) * number of output samples are made zero */ j = outBlockSize - (srcALen + (srcBLen - 1U)); /* Updating the pointer position to non zero value */ pOut += j; } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; /* Initialization of inputB pointer */ pIn2 = pSrcA; /* srcBLen is always considered as shorter or equal to srcALen */ j = srcBLen; srcBLen = srcALen; srcALen = j; /* CORR(x, y) = Reverse order(CORR(y, x)) */ /* Hence set the destination pointer to point to the last output sample */ pOut = pDst + ((srcALen + srcBLen) - 2U); /* Destination address modifier is set to -1 */ inc = -1; } pScr1 = pScratch; /* Fill (srcBLen - 1U) zeros in scratch buffer */ arm_fill_q15(0, pScr1, (srcBLen - 1U)); /* Update temporary scratch pointer */ pScr1 += (srcBLen - 1U); /* Copy (srcALen) samples in scratch buffer */ arm_copy_q15(pIn1, pScr1, srcALen); /* Update pointers */ pScr1 += srcALen; /* Fill (srcBLen - 1U) zeros at end of scratch buffer */ arm_fill_q15(0, pScr1, (srcBLen - 1U)); /* Update pointer */ pScr1 += (srcBLen - 1U); /* Temporary pointer for scratch2 */ py = pIn2; /* Actual correlation process starts here */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (srcALen + srcBLen - 1U) >> 2; while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch; /* Clear Accumlators */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Read two samples from scratch1 buffer */ x1 = read_q15x2_ia (&pScr1); /* Read next two samples from scratch1 buffer */ x2 = read_q15x2_ia (&pScr1); tapCnt = (srcBLen) >> 2U; while (tapCnt > 0U) { /* Read four samples from smaller buffer */ y1 = read_q15x2_ia ((q15_t **) &pIn2); y2 = read_q15x2_ia ((q15_t **) &pIn2); /* multiply and accumlate */ acc0 = __SMLALD(x1, y1, acc0); acc2 = __SMLALD(x2, y1, acc2); /* pack input data */ #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); #else x3 = __PKHBT(x1, x2, 0); #endif /* multiply and accumlate */ acc1 = __SMLALDX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ x1 = read_q15x2_ia (&pScr1); /* multiply and accumlate */ acc0 = __SMLALD(x2, y2, acc0); acc2 = __SMLALD(x1, y2, acc2); /* pack input data */ #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x1, x2, 0); #else x3 = __PKHBT(x2, x1, 0); #endif acc3 = __SMLALDX(x3, y1, acc3); acc1 = __SMLALDX(x3, y2, acc1); x2 = read_q15x2_ia (&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); #else x3 = __PKHBT(x1, x2, 0); #endif acc3 = __SMLALDX(x3, y2, acc3); /* Decrement loop counter */ tapCnt--; } /* Update scratch pointer for remaining samples of smaller length sequence */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ tapCnt = (srcBLen) & 3U; while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2); acc1 += (*pScr1++ * *pIn2); acc2 += (*pScr1++ * *pIn2); acc3 += (*pScr1++ * *pIn2++); pScr1 -= 3U; /* Decrement loop counter */ tapCnt--; } blkCnt--; /* Store the results in the accumulators in the destination buffer. */ *pOut = (__SSAT(acc0 >> 15U, 16)); pOut += inc; *pOut = (__SSAT(acc1 >> 15U, 16)); pOut += inc; *pOut = (__SSAT(acc2 >> 15U, 16)); pOut += inc; *pOut = (__SSAT(acc3 >> 15U, 16)); pOut += inc; /* Initialization of inputB pointer */ pIn2 = py; pScratch += 4U; } /* Loop unrolling: Compute remaining outputs */ blkCnt = (srcALen + srcBLen - 1U) & 0x3; #else /* Initialize blkCnt with number of samples */ blkCnt = (srcALen + srcBLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Calculate correlation for remaining samples of Bigger length sequence */ while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch; /* Clear Accumlators */ acc0 = 0; tapCnt = (srcBLen) >> 1U; while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ acc0 += (*pScr1++ * *pIn2++); acc0 += (*pScr1++ * *pIn2++); /* Decrement loop counter */ tapCnt--; } tapCnt = (srcBLen) & 1U; /* apply same above for remaining samples of smaller length sequence */ while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2++); /* Decrement loop counter */ tapCnt--; } blkCnt--; /* The result is in 2.30 format. Convert to 1.15 with saturation. Then store the output in the destination buffer. */ *pOut = (q15_t) (__SSAT((acc0 >> 15), 16)); pOut += inc; /* Initialization of inputB pointer */ pIn2 = py; pScratch += 1U; } } /** @} end of Corr group */
9,902
C
27.95614
134
0.573924
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_decimate_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_decimate_f32.c * Description: FIR decimation for floating-point sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup FIR_decimate Finite Impulse Response (FIR) Decimator These functions combine an FIR filter together with a decimator. They are used in multirate systems for reducing the sample rate of a signal without introducing aliasing distortion. Conceptually, the functions are equivalent to the block diagram below: \image html FIRDecimator.gif "Components included in the FIR Decimator functions" When decimating by a factor of <code>M</code>, the signal should be prefiltered by a lowpass filter with a normalized cutoff frequency of <code>1/M</code> in order to prevent aliasing distortion. The user of the function is responsible for providing the filter coefficients. The FIR decimator functions provided in the CMSIS DSP Library combine the FIR filter and the decimator in an efficient manner. Instead of calculating all of the FIR filter outputs and discarding <code>M-1</code> out of every <code>M</code>, only the samples output by the decimator are computed. The functions operate on blocks of input and output data. <code>pSrc</code> points to an array of <code>blockSize</code> input values and <code>pDst</code> points to an array of <code>blockSize/M</code> output values. In order to have an integer number of output samples <code>blockSize</code> must always be a multiple of the decimation factor <code>M</code>. The library provides separate functions for Q15, Q31 and floating-point data types. @par Algorithm: The FIR portion of the algorithm uses the standard form filter: <pre> y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1] </pre> where, <code>b[n]</code> are the filter coefficients. @par The <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>. Coefficients are stored in time reversed order. @par <pre> {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} </pre> @par <code>pState</code> points to a state array of size <code>numTaps + blockSize - 1</code>. Samples in the state buffer are stored in the order: @par <pre> {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]} </pre> The state variables are updated after each block of data is processed, the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable array should be allocated separately. There are separate instance structure declarations for each of the 3 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - Checks to make sure that the size of the input is a multiple of the decimation factor. To do this manually without calling the init function, assign the follow subfields of the instance structure: numTaps, pCoeffs, M (decimation factor), pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. The code below statically initializes each of the 3 different data type filter instance structures <pre> arm_fir_decimate_instance_f32 S = {M, numTaps, pCoeffs, pState}; arm_fir_decimate_instance_q31 S = {M, numTaps, pCoeffs, pState}; arm_fir_decimate_instance_q15 S = {M, numTaps, pCoeffs, pState}; </pre> where <code>M</code> is the decimation factor; <code>numTaps</code> is the number of filter coefficients in the filter; <code>pCoeffs</code> is the address of the coefficient buffer; <code>pState</code> is the address of the state buffer. Be sure to set the values in the state buffer to zeros when doing static initialization. @par Fixed-Point Behavior Care must be taken when using the fixed-point versions of the FIR decimate filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. */ /** @addtogroup FIR_decimate @{ */ /** @brief Processing function for floating-point FIR decimator. @param[in] S points to an instance of the floating-point FIR decimator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ #if defined(ARM_MATH_NEON) void arm_fir_decimate_f32( const arm_fir_decimate_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCurnt; /* Points to the current sample of the state */ float32_t *px; /* Temporary pointer for state buffer */ const float32_t *pb; /* Temporary pointer for coefficient buffer */ float32_t sum0; /* Accumulator */ float32_t x0, c0; /* Temporary variables to hold state and coefficient values */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M; /* Loop counters */ uint32_t blkCntN4; float32_t *px0, *px1, *px2, *px3; float32_t acc0, acc1, acc2, acc3; float32_t x1, x2, x3; float32x4_t accv,acc0v,acc1v,acc2v,acc3v; float32x4_t x0v, x1v, x2v, x3v; float32x4_t c0v; float32x2_t temp; float32x4_t sum0v; /* S->pState buffer contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 4; blkCntN4 = outBlockSize - (4 * blkCnt); while (blkCnt > 0U) { /* Copy 4 * decimation factor number of new input samples into the state buffer */ i = 4 * S->M; do { *pStateCurnt++ = *pSrc++; } while (--i); /* Set accumulators to zero */ acc0v = vdupq_n_f32(0.0); acc1v = vdupq_n_f32(0.0); acc2v = vdupq_n_f32(0.0); acc3v = vdupq_n_f32(0.0); /* Initialize state pointer for all the samples */ px0 = pState; px1 = pState + S->M; px2 = pState + 2 * S->M; px3 = pState + 3 * S->M; /* Initialize coeff pointer */ pb = pCoeffs; /* Process 4 taps at a time. */ tapCnt = numTaps >> 2; /* Loop over the number of taps. ** Repeat until we've computed numTaps-4 coefficients. */ while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0v = vld1q_f32(pb); pb += 4; /* Read x[n-numTaps-1] sample for acc0 */ x0v = vld1q_f32(px0); x1v = vld1q_f32(px1); x2v = vld1q_f32(px2); x3v = vld1q_f32(px3); px0 += 4; px1 += 4; px2 += 4; px3 += 4; acc0v = vmlaq_f32(acc0v, x0v, c0v); acc1v = vmlaq_f32(acc1v, x1v, c0v); acc2v = vmlaq_f32(acc2v, x2v, c0v); acc3v = vmlaq_f32(acc3v, x3v, c0v); /* Decrement the loop counter */ tapCnt--; } temp = vpadd_f32(vget_low_f32(acc0v),vget_high_f32(acc0v)); accv[0] = temp[0] + temp[1]; temp = vpadd_f32(vget_low_f32(acc1v),vget_high_f32(acc1v)); accv[1] = temp[0] + temp[1]; temp = vpadd_f32(vget_low_f32(acc2v),vget_high_f32(acc2v)); accv[2] = temp[0] + temp[1]; temp = vpadd_f32(vget_low_f32(acc3v),vget_high_f32(acc3v)); accv[3] = temp[0] + temp[1]; /* If the filter length is not a multiple of 4, compute the remaining filter taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch state variables for acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ accv[0] += x0 * c0; accv[1] += x1 * c0; accv[2] += x2 * c0; accv[3] += x3 * c0; /* Decrement the loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + 4 * S->M; /* The result is in the accumulator, store in the destination buffer. */ vst1q_f32(pDst,accv); pDst += 4; /* Decrement the loop counter */ blkCnt--; } while (blkCntN4 > 0U) { /* Copy decimation factor number of new input samples into the state buffer */ i = S->M; do { *pStateCurnt++ = *pSrc++; } while (--i); /* Set accumulator to zero */ sum0v = vdupq_n_f32(0.0); /* Initialize state pointer */ px = pState; /* Initialize coeff pointer */ pb = pCoeffs; /* Process 4 taps at a time. */ tapCnt = numTaps >> 2; /* Loop over the number of taps. ** Repeat until we've computed numTaps-4 coefficients. */ while (tapCnt > 0U) { c0v = vld1q_f32(pb); pb += 4; x0v = vld1q_f32(px); px += 4; sum0v = vmlaq_f32(sum0v, x0v, c0v); /* Decrement the loop counter */ tapCnt--; } temp = vpadd_f32(vget_low_f32(sum0v),vget_high_f32(sum0v)); sum0 = temp[0] + temp[1]; /* If the filter length is not a multiple of 4, compute the remaining filter taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch 1 state variable */ x0 = *(px++); /* Perform the multiply-accumulate */ sum0 += x0 * c0; /* Decrement the loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M; /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = sum0; /* Decrement the loop counter */ blkCntN4--; } /* Processing is complete. ** Now copy the last numTaps - 1 samples to the satrt of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; i = (numTaps - 1U) >> 2; /* Copy data */ while (i > 0U) { sum0v = vld1q_f32(pState); vst1q_f32(pStateCurnt,sum0v); pState += 4; pStateCurnt += 4; /* Decrement the loop counter */ i--; } i = (numTaps - 1U) % 0x04U; /* Copy data */ while (i > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ i--; } } #else void arm_fir_decimate_f32( const arm_fir_decimate_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCur; /* Points to the current sample of the state */ float32_t *px0; /* Temporary pointer for state buffer */ const float32_t *pb; /* Temporary pointer for coefficient buffer */ float32_t x0, c0; /* Temporary variables to hold state and coefficient values */ float32_t acc0; /* Accumulator */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) float32_t *px1, *px2, *px3; float32_t x1, x2, x3; float32_t acc1, acc2, acc3; #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (numTaps - 1U); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 samples at a time */ blkCnt = outBlockSize >> 2U; /* Samples loop unrolled by 4 */ while (blkCnt > 0U) { /* Copy 4 * decimation factor number of new input samples into the state buffer */ i = S->M * 4; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulators to zero */ acc0 = 0.0f; acc1 = 0.0f; acc2 = 0.0f; acc3 = 0.0f; /* Initialize state pointer for all the samples */ px0 = pState; px1 = pState + S->M; px2 = pState + 2 * S->M; px3 = pState + 3 * S->M; /* Initialize coeff pointer */ pb = pCoeffs; /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-1] sample for acc0 */ x0 = *(px0++); /* Read x[n-numTaps-1] sample for acc1 */ x1 = *(px1++); /* Read x[n-numTaps-1] sample for acc2 */ x2 = *(px2++); /* Read x[n-numTaps-1] sample for acc3 */ x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-2] sample for acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-3] sample acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-4] sample acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch state variables for acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M * 4; /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = acc0; *pDst++ = acc1; *pDst++ = acc2; *pDst++ = acc3; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining samples */ blkCnt = outBlockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = outBlockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy decimation factor number of new input samples into the state buffer */ i = S->M; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulator to zero */ acc0 = 0.0f; /* Initialize state pointer */ px0 = pState; /* Initialize coeff pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; /* Read x[n-numTaps-1] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *pb++; /* Read x[n-numTaps-2] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *pb++; /* Read x[n-numTaps-3] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *pb++; /* Read x[n-numTaps-4] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; /* Fetch 1 state variable */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += x0 * c0; /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M; /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = acc0; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = (numTaps - 1U) % 0x04U; #else /* Initialize tapCnt with number of taps */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of FIR_decimate group */
20,866
C
28.640625
139
0.578405
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_decimate_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_decimate_q31.c * Description: Q31 FIR Decimator * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_decimate @{ */ /** @brief Processing function for the Q31 FIR decimator. @param[in] S points to an instance of the Q31 FIR decimator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits (where log2 is read as log to the base 2). After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. @remark Refer to \ref arm_fir_decimate_fast_q31() for a faster but less precise implementation of this function. */ void arm_fir_decimate_q31( const arm_fir_decimate_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { q31_t *pState = S->pState; /* State pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *pStateCur; /* Points to the current sample of the state */ q31_t *px0; /* Temporary pointer for state buffer */ const q31_t *pb; /* Temporary pointer for coefficient buffer */ q31_t x0, c0; /* Temporary variables to hold state and coefficient values */ q63_t acc0; /* Accumulator */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q31_t *px1, *px2, *px3; q31_t x1, x2, x3; q63_t acc1, acc2, acc3; #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (numTaps - 1U); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 samples at a time */ blkCnt = outBlockSize >> 2U; /* Samples loop unrolled by 4 */ while (blkCnt > 0U) { /* Copy 4 * decimation factor number of new input samples into the state buffer */ i = S->M * 4; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulators to zero */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Initialize state pointer for all the samples */ px0 = pState; px1 = pState + S->M; px2 = pState + 2 * S->M; px3 = pState + 3 * S->M; /* Initialize coeff pointer */ pb = pCoeffs; /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-1] sample for acc0 */ x0 = *(px0++); /* Read x[n-numTaps-1] sample for acc1 */ x1 = *(px1++); /* Read x[n-numTaps-1] sample for acc2 */ x2 = *(px2++); /* Read x[n-numTaps-1] sample for acc3 */ x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-2] sample for acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-3] sample acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); /* Read x[n-numTaps-4] sample acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch state variables for acc0, acc1, acc2, acc3 */ x0 = *(px0++); x1 = *(px1++); x2 = *(px2++); x3 = *(px3++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M * 4; /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = (q31_t) (acc0 >> 31); *pDst++ = (q31_t) (acc1 >> 31); *pDst++ = (q31_t) (acc2 >> 31); *pDst++ = (q31_t) (acc3 >> 31); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining samples */ blkCnt = outBlockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = outBlockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy decimation factor number of new input samples into the state buffer */ i = S->M; do { *pStateCur++ = *pSrc++; } while (--i); /* Set accumulator to zero */ acc0 = 0; /* Initialize state pointer */ px0 = pState; /* Initialize coeff pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; /* Read x[n-numTaps-1] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *pb++; /* Read x[n-numTaps-2] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *pb++; /* Read x[n-numTaps-3] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *pb++; /* Read x[n-numTaps-4] sample */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; /* Fetch 1 state variable */ x0 = *px0++; /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by the decimation factor * to process the next group of decimation factor number samples */ pState = pState + S->M; /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = (q31_t) (acc0 >> 31); /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = (numTaps - 1U) % 0x04U; #else /* Initialize tapCnt with number of taps */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of FIR_decimate group */
10,422
C
25.863402
162
0.544905
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_iir_lattice_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_iir_lattice_q15.c * Description: Q15 IIR Lattice filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup IIR_Lattice @{ */ /** @brief Processing function for the Q15 IIR lattice filter. @param[in] S points to an instance of the Q15 IIR lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. */ void arm_iir_lattice_q15( const arm_iir_lattice_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ q15_t *pStateCur; /* State current pointer */ q31_t fcurr, fnext = 0, gcurr = 0, gnext; /* Temporary variables for lattice stages */ q63_t acc; /* Accumlator */ q15_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ uint32_t numStages = S->numStages; /* Number of stages */ uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ q15_t out; /* Temporary variable for output */ #if defined (ARM_MATH_DSP) && defined (ARM_MATH_LOOPUNROLL) q15_t gnext1, gnext2; /* Temporary variables for lattice stages */ q31_t v; /* Temporary variable for ladder coefficient */ #endif /* initialise loop count */ blkCnt = blockSize; #if defined (ARM_MATH_DSP) /* Sample processing */ while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; /* Initialize Ladder coeff pointer */ pv = &S->pvCoeffs[0]; /* Initialize Reflection coeff pointer */ pk = &S->pkCoeffs[0]; /* Initialize state read pointer */ px1 = pState; /* Initialize state write pointer */ px2 = pState; /* Set accumulator to zero */ acc = 0; /* Process sample for first tap */ gcurr = *px1++; /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; gnext = __SSAT(gnext, 16); /* write gN(n) into state for next sample processing */ *px2++ = (q15_t) gnext; /* y(n) += gN(n) * vN */ acc += (q31_t) ((gnext * (*pv++))); /* Update f values for next coefficient processing */ fcurr = fnext; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numStages - 1U) >> 2U; while (tapCnt > 0U) { /* Process sample for 2nd, 6th ...taps */ /* Read gN-2(n-1) from state buffer */ gcurr = *px1++; /* fN-2(n) = fN-1(n) - kN-1 * gN-2(n-1) */ fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN-1(n) = kN-1 * fN-2(n) + gN-2(n-1) */ gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; gnext1 = (q15_t) __SSAT(gnext, 16); /* write gN-1(n) into state for next sample processing */ *px2++ = (q15_t) gnext1; /* Process sample for 3nd, 7th ...taps */ /* Read gN-3(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 3rd, 7th .. taps */ /* fN-3(n) = fN-2(n) - kN-2 * gN-3(n-1) */ fcurr = fnext - (((q31_t) gcurr * (*pk)) >> 15); fcurr = __SSAT(fcurr, 16); /* gN-2(n) = kN-2 * fN-3(n) + gN-3(n-1) */ gnext = (((q31_t) fcurr * (*pk++)) >> 15) + gcurr; gnext2 = (q15_t) __SSAT(gnext, 16); /* write gN-2(n) into state */ *px2++ = (q15_t) gnext2; /* Read vN-1 and vN-2 at a time */ v = read_q15x2_ia (&pv); /* Pack gN-1(n) and gN-2(n) */ #ifndef ARM_MATH_BIG_ENDIAN gnext = __PKHBT(gnext1, gnext2, 16); #else gnext = __PKHBT(gnext2, gnext1, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* y(n) += gN-1(n) * vN-1 */ /* process for gN-5(n) * vN-5, gN-9(n) * vN-9 ... */ /* y(n) += gN-2(n) * vN-2 */ /* process for gN-6(n) * vN-6, gN-10(n) * vN-10 ... */ acc = __SMLALD(gnext, v, acc); /* Process sample for 4th, 8th ...taps */ /* Read gN-4(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 4th, 8th .. taps */ /* fN-4(n) = fN-3(n) - kN-3 * gN-4(n-1) */ fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN-3(n) = kN-3 * fN-1(n) + gN-1(n-1) */ gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; gnext1 = (q15_t) __SSAT(gnext, 16); /* write gN-3(n) for the next sample process */ *px2++ = (q15_t) gnext1; /* Process sample for 5th, 9th ...taps */ /* Read gN-5(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 5th, 9th .. taps */ /* fN-5(n) = fN-4(n) - kN-4 * gN-5(n-1) */ fcurr = fnext - (((q31_t) gcurr * (*pk)) >> 15); fcurr = __SSAT(fcurr, 16); /* gN-4(n) = kN-4 * fN-5(n) + gN-5(n-1) */ gnext = (((q31_t) fcurr * (*pk++)) >> 15) + gcurr; gnext2 = (q15_t) __SSAT(gnext, 16); /* write gN-4(n) for the next sample process */ *px2++ = (q15_t) gnext2; /* Read vN-3 and vN-4 at a time */ v = read_q15x2_ia (&pv); /* Pack gN-3(n) and gN-4(n) */ #ifndef ARM_MATH_BIG_ENDIAN gnext = __PKHBT(gnext1, gnext2, 16); #else gnext = __PKHBT(gnext2, gnext1, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* y(n) += gN-4(n) * vN-4 */ /* process for gN-8(n) * vN-8, gN-12(n) * vN-12 ... */ /* y(n) += gN-3(n) * vN-3 */ /* process for gN-7(n) * vN-7, gN-11(n) * vN-11 ... */ acc = __SMLALD(gnext, v, acc); /* Decrement loop counter */ tapCnt--; } fnext = fcurr; /* Loop unrolling: Compute remaining taps */ tapCnt = (numStages - 1U) % 0x4U; #else /* Initialize blkCnt with number of samples */ tapCnt = (numStages - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { gcurr = *px1++; /* Process sample for last taps */ fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; gnext = __SSAT(gnext, 16); /* Output samples for last taps */ acc += (q31_t) (((q31_t) gnext * (*pv++))); *px2++ = (q15_t) gnext; fcurr = fnext; /* Decrement loop counter */ tapCnt--; } /* y(n) += g0(n) * v0 */ acc += (q31_t) (((q31_t) fnext * (*pv++))); out = (q15_t) __SSAT(acc >> 15, 16); *px2++ = (q15_t) fnext; /* write out into pDst */ *pDst++ = out; /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy last S->numStages samples to start of the buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; /* copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numStages >> 2U; while (tapCnt > 0U) { write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numStages % 0x4U; #else /* Initialize blkCnt with number of samples */ tapCnt = (numStages - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #else /* #if defined (ARM_MATH_DSP) */ /* Sample processing */ while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; /* Initialize Ladder coeff pointer */ pv = &S->pvCoeffs[0]; /* Initialize Reflection coeff pointer */ pk = &S->pkCoeffs[0]; /* Initialize state read pointer */ px1 = pState; /* Initialize state write pointer */ px2 = pState; /* Set accumulator to zero */ acc = 0; tapCnt = numStages; while (tapCnt > 0U) { gcurr = *px1++; /* Process sample */ /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ fnext = fcurr - ((gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ gnext = ((fnext * (*pk++)) >> 15) + gcurr; gnext = __SSAT(gnext, 16); /* Output samples */ /* y(n) += gN(n) * vN */ acc += (q31_t) ((gnext * (*pv++))); /* write gN(n) into state for next sample processing */ *px2++ = (q15_t) gnext; /* Update f values for next coefficient processing */ fcurr = fnext; tapCnt--; } /* y(n) += g0(n) * v0 */ acc += (q31_t) ((fnext * (*pv++))); out = (q15_t) __SSAT(acc >> 15, 16); *px2++ = (q15_t) fnext; /* write out into pDst */ *pDst++ = out; /* Advance the state pointer by 1 to process the next group of samples */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy last S->numStages samples to start of the buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; tapCnt = numStages; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #endif /* #if defined (ARM_MATH_DSP) */ } /** @} end of IIR_Lattice group */
11,689
C
28.445844
144
0.528617
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_interpolate_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_interpolate_q15.c * Description: Q15 FIR interpolation * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR_Interpolate @{ */ /** @brief Processing function for the Q15 FIR interpolator. @param[in] S points to an instance of the Q15 FIR interpolator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using a 64-bit internal accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. */ void arm_fir_interpolate_q15( const arm_fir_interpolate_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCur; /* Points to the current sample of the state */ q15_t *ptr1; /* Temporary pointer for state buffer */ const q15_t *ptr2; /* Temporary pointer for coefficient buffer */ q63_t sum0; /* Accumulators */ uint32_t i, blkCnt, tapCnt; /* Loop counters */ uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ uint32_t j; #if defined (ARM_MATH_LOOPUNROLL) q63_t acc0, acc1, acc2, acc3; q15_t x0, x1, x2, x3; q15_t c0, c1, c2, c3; #endif /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (phaseLen - 1U); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = (S->L); while (i > 0U) { /* Set accumulator to zero */ acc0 = 0; acc1 = 0; acc2 = 0; acc3 = 0; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Unroll by a factor of 4. Repeat until we've computed numTaps-(4*S->L) coefficients. */ tapCnt = phaseLen >> 2U; x0 = *(ptr1++); x1 = *(ptr1++); x2 = *(ptr1++); while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); /* Read the coefficient */ c0 = *(ptr2); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Read the coefficient */ c1 = *(ptr2 + S->L); /* Read the input sample */ x0 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x1 * c1; acc1 += (q63_t) x2 * c1; acc2 += (q63_t) x3 * c1; acc3 += (q63_t) x0 * c1; /* Read the coefficient */ c2 = *(ptr2 + S->L * 2); /* Read the input sample */ x1 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x2 * c2; acc1 += (q63_t) x3 * c2; acc2 += (q63_t) x0 * c2; acc3 += (q63_t) x1 * c2; /* Read the coefficient */ c3 = *(ptr2 + S->L * 3); /* Read the input sample */ x2 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += (q63_t) x3 * c3; acc1 += (q63_t) x0 * c3; acc2 += (q63_t) x1 * c3; acc3 += (q63_t) x2 * c3; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += 4 * S->L; /* Decrement loop counter */ tapCnt--; } /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ tapCnt = phaseLen % 0x4U; while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); /* Read the coefficient */ c0 = *(ptr2); /* Perform the multiply-accumulate */ acc0 += (q63_t) x0 * c0; acc1 += (q63_t) x1 * c0; acc2 += (q63_t) x2 * c0; acc3 += (q63_t) x3 * c0; /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* update states for next sample processing */ x0 = x1; x1 = x2; x2 = x3; /* Decrement loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *(pDst ) = (q15_t) (__SSAT((acc0 >> 15), 16)); *(pDst + S->L) = (q15_t) (__SSAT((acc1 >> 15), 16)); *(pDst + 2 * S->L) = (q15_t) (__SSAT((acc2 >> 15), 16)); *(pDst + 3 * S->L) = (q15_t) (__SSAT((acc3 >> 15), 16)); pDst++; /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 4; pDst += S->L * 3; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Repeat until we've computed numTaps-(4*S->L) coefficients. */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = phaseLen >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += (q63_t) *ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; sum0 += (q63_t) *ptr1++ * *ptr2; ptr2 += S->L; sum0 += (q63_t) *ptr1++ * *ptr2; ptr2 += S->L; sum0 += (q63_t) *ptr1++ * *ptr2; ptr2 += S->L; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = phaseLen % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = phaseLen; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += (q63_t) *ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement the loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement the loop counter */ blkCnt--; } /* Processing is complete. Now copy the last phaseLen - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = (phaseLen - 1U) >> 2U; /* copy data */ while (tapCnt > 0U) { write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = (phaseLen - 1U) % 0x04U; #else /* Initialize tapCnt with number of samples */ tapCnt = (phaseLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #else /* alternate version for CM0_FAMILY */ q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCur; /* Points to the current sample of the state */ q15_t *ptr1; /* Temporary pointer for state buffer */ const q15_t *ptr2; /* Temporary pointer for coefficient buffer */ q63_t sum0; /* Accumulators */ uint32_t i, blkCnt, tapCnt; /* Loop counters */ uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (phaseLen - 1U); /* Total number of intput samples */ blkCnt = blockSize; /* Loop over the blockSize. */ while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (i - 1U); /* Loop over the polyPhase length */ tapCnt = phaseLen; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += ((q63_t) *ptr1++ * *ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement the loop counter */ tapCnt--; } /* Store the result after converting to 1.15 format in the destination buffer. */ *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. ** Now copy the last phaseLen - 1 samples to the start of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; tapCnt = phaseLen - 1U; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } /** @} end of FIR_Interpolate group */
13,670
C
27.48125
144
0.54989
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_q31.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_q31.c * Description: Q31 FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup FIR @{ */ /** @brief Processing function for Q31 FIR filter. @param[in] S points to an instance of the Q31 FIR filter structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. After all multiply-accumulates are performed, the 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. @remark Refer to \ref arm_fir_fast_q31() for a faster but less precise implementation of this filter. */ void arm_fir_q31( const arm_fir_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize) { q31_t *pState = S->pState; /* State pointer */ const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q31_t *pStateCurnt; /* Points to the current sample of the state */ q31_t *px; /* Temporary pointer for state buffer */ const q31_t *pb; /* Temporary pointer for coefficient buffer */ q63_t acc0; /* Accumulator */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t i, tapCnt, blkCnt; /* Loop counters */ #if defined (ARM_MATH_LOOPUNROLL) q63_t acc1, acc2; /* Accumulators */ q31_t x0, x1, x2; /* Temporary variables to hold state values */ q31_t c0; /* Temporary variable to hold coefficient value */ #endif /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize / 3; while (blkCnt > 0U) { /* Copy 3 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; acc2 = 0; /* Initialize state pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Read the first 2 samples from the state buffer: x[n-numTaps], x[n-numTaps-1] */ x0 = *px++; x1 = *px++; /* Loop unrolling: process 3 taps at a time. */ tapCnt = numTaps / 3; while (tapCnt > 0U) { /* Read the b[numTaps] coefficient */ c0 = *pb; /* Read x[n-numTaps-2] sample */ x2 = *(px++); /* Perform the multiply-accumulates */ acc0 += ((q63_t) x0 * c0); acc1 += ((q63_t) x1 * c0); acc2 += ((q63_t) x2 * c0); /* Read the coefficient and state */ c0 = *(pb + 1U); x0 = *(px++); /* Perform the multiply-accumulates */ acc0 += ((q63_t) x1 * c0); acc1 += ((q63_t) x2 * c0); acc2 += ((q63_t) x0 * c0); /* Read the coefficient and state */ c0 = *(pb + 2U); x1 = *(px++); /* update coefficient pointer */ pb += 3U; /* Perform the multiply-accumulates */ acc0 += ((q63_t) x2 * c0); acc1 += ((q63_t) x0 * c0); acc2 += ((q63_t) x1 * c0); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = numTaps % 0x3U; while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); /* Fetch 1 state variable */ x2 = *(px++); /* Perform the multiply-accumulates */ acc0 += ((q63_t) x0 * c0); acc1 += ((q63_t) x1 * c0); acc2 += ((q63_t) x2 * c0); /* Reuse the present sample states for next sample */ x0 = x1; x1 = x2; /* Decrement loop counter */ tapCnt--; } /* Advance the state pointer by 3 to process the next group of 3 samples */ pState = pState + 3; /* The result is in 2.30 format. Convert to 1.31 and store in destination buffer. */ *pDst++ = (q31_t) (acc0 >> 31U); *pDst++ = (q31_t) (acc1 >> 31U); *pDst++ = (q31_t) (acc2 >> 31U); /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining output samples */ blkCnt = blockSize % 0x3U; #else /* Initialize blkCnt with number of taps */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; /* Set the accumulator to zero */ acc0 = 0; /* Initialize state pointer */ px = pState; /* Initialize Coefficient pointer */ pb = pCoeffs; i = numTaps; /* Perform the multiply-accumulates */ do { /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ acc0 += (q63_t) *px++ * *pb++; i--; } while (i > 0U); /* Result is in 2.62 format. Convert to 1.31 and store in destination buffer. */ *pDst++ = (q31_t) (acc0 >> 31U); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Calculate remaining number of copies */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of taps */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of FIR group */
8,702
C
29.114187
169
0.556654
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_q15.c * Description: Processing function for the Q15 Biquad cascade DirectFormI(DF1) filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup BiquadCascadeDF1 @{ */ /** @brief Processing function for the Q15 Biquad cascade filter. @param[in] S points to an instance of the Q15 Biquad cascade structure @param[in] pSrc points to the block of input data @param[out] pDst points to the location where the output result is written @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using a 64-bit internal accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. The accumulator is then shifted by <code>postShift</code> bits to truncate the result to 1.15 format by discarding the low 16 bits. Finally, the result is saturated to 1.15 format. @remark Refer to \ref arm_biquad_cascade_df1_fast_q15() for a faster but less precise implementation of this filter. */ void arm_biquad_cascade_df1_q15( const arm_biquad_casd_df1_inst_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize) { #if defined (ARM_MATH_DSP) const q15_t *pIn = pSrc; /* Source pointer */ q15_t *pOut = pDst; /* Destination pointer */ q31_t in; /* Temporary variable to hold input value */ q31_t out; /* Temporary variable to hold output value */ q31_t b0; /* Temporary variable to hold bo value */ q31_t b1, a1; /* Filter coefficients */ q31_t state_in, state_out; /* Filter state variables */ q31_t acc_l, acc_h; q63_t acc; /* Accumulator */ q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ int32_t lShift = (15 - (int32_t) S->postShift); /* Post shift */ uint32_t sample, stage = (uint32_t) S->numStages; /* Stage loop counter */ int32_t uShift = (32 - lShift); do { /* Read the b0 and 0 coefficients using SIMD */ b0 = read_q15x2_ia ((q15_t **) &pCoeffs); /* Read the b1 and b2 coefficients using SIMD */ b1 = read_q15x2_ia ((q15_t **) &pCoeffs); /* Read the a1 and a2 coefficients using SIMD */ a1 = read_q15x2_ia ((q15_t **) &pCoeffs); /* Read the input state values from the state buffer: x[n-1], x[n-2] */ state_in = read_q15x2_ia (&pState); /* Read the output state values from the state buffer: y[n-1], y[n-2] */ state_out = read_q15x2_da (&pState); /* Apply loop unrolling and compute 2 output values simultaneously. */ /* The variable acc hold output values that are being computed: * * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ sample = blockSize >> 1U; /* First part of the processing with loop unrolling. Compute 2 outputs at a time. ** a second loop below computes the remaining 1 sample. */ while (sample > 0U) { /* Read the input */ in = read_q15x2_ia ((q15_t **) &pIn); /* out = b0 * x[n] + 0 * 0 */ out = __SMUAD(b0, in); /* acc += b1 * x[n-1] + b2 * x[n-2] + out */ acc = __SMLALD(b1, state_in, out); /* acc += a1 * y[n-1] + a2 * y[n-2] */ acc = __SMLALD(a1, state_out, acc); /* The result is converted from 3.29 to 1.31 if postShift = 1, and then saturation is applied */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ out = (uint32_t) acc_l >> lShift | acc_h << uShift; out = __SSAT(out, 16); /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ #ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else state_in = __PKHBT(state_in >> 16, (in >> 16), 16); state_out = __PKHBT(state_out >> 16, (out), 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* out = b0 * x[n] + 0 * 0 */ out = __SMUADX(b0, in); /* acc += b1 * x[n-1] + b2 * x[n-2] + out */ acc = __SMLALD(b1, state_in, out); /* acc += a1 * y[n-1] + a2 * y[n-2] */ acc = __SMLALD(a1, state_out, acc); /* The result is converted from 3.29 to 1.31 if postShift = 1, and then saturation is applied */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ out = (uint32_t) acc_l >> lShift | acc_h << uShift; out = __SSAT(out, 16); /* Store the output in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN write_q15x2_ia (&pOut, __PKHBT(state_out, out, 16)); #else write_q15x2_ia (&pOut, __PKHBT(out, state_out >> 16, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ #ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in >> 16, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else state_in = __PKHBT(state_in >> 16, in, 16); state_out = __PKHBT(state_out >> 16, out, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Decrement loop counter */ sample--; } /* If the blockSize is not a multiple of 2, compute any remaining output samples here. ** No loop unrolling is used. */ if ((blockSize & 0x1U) != 0U) { /* Read the input */ in = *pIn++; /* out = b0 * x[n] + 0 * 0 */ #ifndef ARM_MATH_BIG_ENDIAN out = __SMUAD(b0, in); #else out = __SMUADX(b0, in); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* acc = b1 * x[n-1] + b2 * x[n-2] + out */ acc = __SMLALD(b1, state_in, out); /* acc += a1 * y[n-1] + a2 * y[n-2] */ acc = __SMLALD(a1, state_out, acc); /* The result is converted from 3.29 to 1.31 if postShift = 1, and then saturation is applied */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ out = (uint32_t) acc_l >> lShift | acc_h << uShift; out = __SSAT(out, 16); /* Store the output in the destination buffer. */ *pOut++ = (q15_t) out; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ #ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else state_in = __PKHBT(state_in >> 16, in, 16); state_out = __PKHBT(state_out >> 16, out, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ } /* The first stage goes from the input wire to the output wire. */ /* Subsequent numStages occur in-place in the output wire */ pIn = pDst; /* Reset the output pointer */ pOut = pDst; /* Store the updated state variables back into the state array */ write_q15x2_ia (&pState, state_in); write_q15x2_ia (&pState, state_out); /* Decrement loop counter */ stage--; } while (stage > 0U); #else const q15_t *pIn = pSrc; /* Source pointer */ q15_t *pOut = pDst; /* Destination pointer */ q15_t b0, b1, b2, a1, a2; /* Filter coefficients */ q15_t Xn1, Xn2, Yn1, Yn2; /* Filter state variables */ q15_t Xn; /* temporary input */ q63_t acc; /* Accumulator */ int32_t shift = (15 - (int32_t) S->postShift); /* Post shift */ q15_t *pState = S->pState; /* State pointer */ const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ uint32_t sample, stage = (uint32_t) S->numStages; /* Stage loop counter */ do { /* Reading the coefficients */ b0 = *pCoeffs++; pCoeffs++; // skip the 0 coefficient b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; a2 = *pCoeffs++; /* Reading the state values */ Xn1 = pState[0]; Xn2 = pState[1]; Yn1 = pState[2]; Yn2 = pState[3]; /* The variables acc holds the output value that is computed: * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ sample = blockSize; while (sample > 0U) { /* Read the input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* acc = b0 * x[n] */ acc = (q31_t) b0 *Xn; /* acc += b1 * x[n-1] */ acc += (q31_t) b1 *Xn1; /* acc += b[2] * x[n-2] */ acc += (q31_t) b2 *Xn2; /* acc += a1 * y[n-1] */ acc += (q31_t) a1 *Yn1; /* acc += a2 * y[n-2] */ acc += (q31_t) a2 *Yn2; /* The result is converted to 1.31 */ acc = __SSAT((acc >> shift), 16); /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; Yn1 = (q15_t) acc; /* Store the output in the destination buffer. */ *pOut++ = (q15_t) acc; /* decrement the loop counter */ sample--; } /* The first stage goes from the input buffer to the output buffer. */ /* Subsequent stages occur in-place in the output buffer */ pIn = pDst; /* Reset to destination pointer */ pOut = pDst; /* Store the updated state variables back into the pState array */ *pState++ = Xn1; *pState++ = Xn2; *pState++ = Yn1; *pState++ = Yn2; } while (--stage); #endif /* #if defined (ARM_MATH_DSP) */ } /** @} end of BiquadCascadeDF1 group */
12,701
C
33.895604
150
0.53169
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_sparse_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_sparse_f32.c * Description: Floating-point sparse FIR filter processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup FIR_Sparse Finite Impulse Response (FIR) Sparse Filters This group of functions implements sparse FIR filters. Sparse FIR filters are equivalent to standard FIR filters except that most of the coefficients are equal to zero. Sparse filters are used for simulating reflections in communications and audio applications. There are separate functions for Q7, Q15, Q31, and floating-point data types. The functions operate on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> and <code>pDst</code> points to input and output arrays respectively containing <code>blockSize</code> values. @par Algorithm The sparse filter instant structure contains an array of tap indices <code>pTapDelay</code> which specifies the locations of the non-zero coefficients. This is in addition to the coefficient array <code>b</code>. The implementation essentially skips the multiplications by zero and leads to an efficient realization. <pre> y[n] = b[0] * x[n-pTapDelay[0]] + b[1] * x[n-pTapDelay[1]] + b[2] * x[n-pTapDelay[2]] + ...+ b[numTaps-1] * x[n-pTapDelay[numTaps-1]] </pre> @par \image html FIRSparse.gif "Sparse FIR filter. b[n] represents the filter coefficients" @par <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>; <code>pTapDelay</code> points to an array of nonzero indices and is also of size <code>numTaps</code>; <code>pState</code> points to a state array of size <code>maxDelay + blockSize</code>, where <code>maxDelay</code> is the largest offset value that is ever used in the <code>pTapDelay</code> array. Some of the processing functions also require temporary working buffers. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient and offset arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 4 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numTaps, pCoeffs, pTapDelay, maxDelay, stateIndex, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. The code below statically initializes each of the 4 different data type filter instance structures <pre> arm_fir_sparse_instance_f32 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay}; arm_fir_sparse_instance_q31 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay}; arm_fir_sparse_instance_q15 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay}; arm_fir_sparse_instance_q7 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay}; </pre> @par Fixed-Point Behavior Care must be taken when using the fixed-point versions of the sparse FIR filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. */ /** @addtogroup FIR_Sparse @{ */ /** @brief Processing function for the floating-point sparse FIR filter. @param[in] S points to an instance of the floating-point sparse FIR structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @param[in] blockSize number of input samples to process @return none */ void arm_fir_sparse_f32( arm_fir_sparse_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, float32_t * pScratchIn, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *px; /* Scratch buffer pointer */ float32_t *py = pState; /* Temporary pointers for state buffer */ float32_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ float32_t *pOut; /* Destination pointer */ int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ uint32_t delaySize = S->maxDelay + blockSize; /* state length */ uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ int32_t readIndex; /* Read index of the state buffer */ uint32_t tapCnt, blkCnt; /* loop counters */ float32_t coeff = *pCoeffs++; /* Read the first coefficient value */ /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ arm_circularWrite_f32((int32_t *) py, delaySize, &S->stateIndex, 1, (int32_t *) pSrc, 1, blockSize); /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pOut = pDst; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiplications and store in destination buffer */ *pOut++ = *px++ * coeff; *pOut++ = *px++ * coeff; *pOut++ = *px++ * coeff; *pOut++ = *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiplication and store in destination buffer */ *pOut++ = *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Load the coefficient value and * increment the coefficient buffer for the next set of state values */ coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Loop over the number of taps. */ tapCnt = (uint32_t) numTaps - 2U; while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pOut = pDst; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Load the coefficient value and * increment the coefficient buffer for the next set of state values */ coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ if (readIndex < 0) { readIndex += (int32_t) delaySize; } /* Decrement tap loop counter */ tapCnt--; } /* Compute last tap without the final read of pTapDelay */ /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; /* Working pointer for scratch buffer of output values */ pOut = pDst; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; /* Decrement loop counter */ blkCnt--; } } /** @} end of FIR_Sparse group */
12,285
C
34.923977
170
0.621164
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df1_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_f32.c * Description: Processing function for the floating-point Biquad cascade DirectFormI(DF1) filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup BiquadCascadeDF1 Biquad Cascade IIR Filters Using Direct Form I Structure This set of functions implements arbitrary order recursive (IIR) filters. The filters are implemented as a cascade of second order Biquad sections. The functions support Q15, Q31 and floating-point data types. Fast version of Q15 and Q31 also available. The functions operate on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> points to the array of input data and <code>pDst</code> points to the array of output data. Both arrays contain <code>blockSize</code> values. @par Algorithm Each Biquad stage implements a second order filter using the difference equation: <pre> y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] </pre> A Direct Form I algorithm is used with 5 coefficients and 4 state variables per stage. \image html Biquad.gif "Single Biquad filter stage" Coefficients <code>b0, b1 and b2 </code> multiply the input signal <code>x[n]</code> and are referred to as the feedforward coefficients. Coefficients <code>a1</code> and <code>a2</code> multiply the output signal <code>y[n]</code> and are referred to as the feedback coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools use the difference equation <pre> y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2] </pre> In this case the feedback coefficients <code>a1</code> and <code>a2</code> must be negated when used with the CMSIS DSP Library. @par Higher order filters are realized as a cascade of second order sections. <code>numStages</code> refers to the number of second order stages used. For example, an 8th order filter would be realized with <code>numStages=4</code> second order stages. \image html BiquadCascade.gif "8th order filter using a cascade of Biquad stages" A 9th order filter would be realized with <code>numStages=5</code> second order stages with the coefficients for one of the stages configured as a first order filter (<code>b2=0</code> and <code>a2=0</code>). @par The <code>pState</code> points to state variables array. Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>. The state variables are arranged in the <code>pState</code> array as: <pre> {x[n-1], x[n-2], y[n-1], y[n-2]} </pre> @par The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. The state array has a total length of <code>4*numStages</code> values. The state variables are updated after each block of data is processed, the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. There are separate instance structure declarations for each of the 3 supported data types. @par Init Function There is also an associated initialization function for each data type. The initialization function performs following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numStages, pCoeffs, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. The code below statically initializes each of the 3 different data type filter instance structures <pre> arm_biquad_casd_df1_inst_f32 S1 = {numStages, pState, pCoeffs}; arm_biquad_casd_df1_inst_q15 S2 = {numStages, pState, pCoeffs, postShift}; arm_biquad_casd_df1_inst_q31 S3 = {numStages, pState, pCoeffs, postShift}; </pre> where <code>numStages</code> is the number of Biquad stages in the filter; <code>pState</code> is the address of the state buffer; <code>pCoeffs</code> is the address of the coefficient buffer; <code>postShift</code> shift to be applied. @par Fixed-Point Behavior Care must be taken when using the Q15 and Q31 versions of the Biquad Cascade filter functions. Following issues must be considered: - Scaling of coefficients - Filter gain - Overflow and saturation @par Scaling of coefficients Filter coefficients are represented as fractional values and coefficients are restricted to lie in the range <code>[-1 +1)</code>. The fixed-point functions have an additional scaling parameter <code>postShift</code> which allow the filter coefficients to exceed the range <code>[+1 -1)</code>. At the output of the filter's accumulator is a shift register which shifts the result by <code>postShift</code> bits. \image html BiquadPostshift.gif "Fixed-point Biquad with shift by postShift bits after accumulator" This essentially scales the filter coefficients by <code>2^postShift</code>. For example, to realize the coefficients <pre> {1.5, -0.8, 1.2, 1.6, -0.9} </pre> set the pCoeffs array to: <pre> {0.75, -0.4, 0.6, 0.8, -0.45} </pre> and set <code>postShift=1</code> @par Filter gain The frequency response of a Biquad filter is a function of its coefficients. It is possible for the gain through the filter to exceed 1.0 meaning that the filter increases the amplitude of certain frequencies. This means that an input signal with amplitude < 1.0 may result in an output > 1.0 and these are saturated or overflowed based on the implementation of the filter. To avoid this behavior the filter needs to be scaled down such that its peak gain < 1.0 or the input signal must be scaled down so that the combination of input and filter are never overflowed. @par Overflow and saturation For Q15 and Q31 versions, it is described separately as part of the function specific documentation below. */ /** @addtogroup BiquadCascadeDF1 @{ */ /** @brief Processing function for the floating-point Biquad cascade filter. @param[in] S points to an instance of the floating-point Biquad cascade structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ #if defined(ARM_MATH_NEON) void arm_biquad_cascade_df1_f32( const arm_biquad_casd_df1_inst_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { const float32_t *pIn = pSrc; /* source pointer */ float32_t *pOut = pDst; /* destination pointer */ float32_t *pState = S->pState; /* pState pointer */ const float32_t *pCoeffs = S->pCoeffs; /* coefficient pointer */ float32_t acc; /* Simulates the accumulator */ uint32_t sample, stage = S->numStages; /* loop counters */ float32x4_t Xn; float32x2_t Yn; float32x2_t a; float32x4_t b; float32x4_t x,tmp; float32x2_t t; float32x2x2_t y; float32_t Xns; while (stage > 0U) { /* Reading the coefficients */ Xn = vld1q_f32(pState); Yn = vld1_f32(pState + 2); b = vld1q_f32(pCoeffs); b = vrev64q_f32(b); b = vcombine_f32(vget_high_f32(b), vget_low_f32(b)); a = vld1_f32(pCoeffs + 3); a = vrev64_f32(a); b[0] = 0.0; pCoeffs += 5; /* Reading the pState values */ /* Apply loop unrolling and compute 4 output values simultaneously. */ /* The variable acc hold output values that are being computed: * * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* First part of the processing with loop unrolling. Compute 4 outputs at a time. ** a second loop below computes the remaining 1 to 3 samples. */ sample = blockSize >> 2U; while (sample > 0U) { /* Read the first 4 inputs */ x = vld1q_f32(pIn); pIn += 4; tmp = vextq_f32(Xn, x, 1); t = vmul_f32(vget_high_f32(b), vget_high_f32(tmp)); t = vmla_f32(t, vget_low_f32(b), vget_low_f32(tmp)); t = vmla_f32(t, a, Yn); t = vpadd_f32(t, t); Yn = vext_f32(Yn, t, 1); tmp = vextq_f32(Xn, x, 2); t = vmul_f32(vget_high_f32(b), vget_high_f32(tmp)); t = vmla_f32(t, vget_low_f32(b), vget_low_f32(tmp)); t = vmla_f32(t, a, Yn); t = vpadd_f32(t, t); Yn = vext_f32(Yn, t, 1); y.val[0] = Yn; tmp = vextq_f32(Xn, x, 3); t = vmul_f32(vget_high_f32(b), vget_high_f32(tmp)); t = vmla_f32(t, vget_low_f32(b), vget_low_f32(tmp)); t = vmla_f32(t, a, Yn); t = vpadd_f32(t, t); Yn = vext_f32(Yn, t, 1); Xn = x; t = vmul_f32(vget_high_f32(b), vget_high_f32(Xn)); t = vmla_f32(t, vget_low_f32(b), vget_low_f32(Xn)); t = vmla_f32(t, a, Yn); t = vpadd_f32(t, t); Yn = vext_f32(Yn, t, 1); y.val[1] = Yn; tmp = vcombine_f32(y.val[0], y.val[1]); /* Store the 4 outputs and increment the pointer */ vst1q_f32(pOut, tmp); pOut += 4; /* Decrement the loop counter */ sample--; } /* If the block size is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ sample = blockSize & 0x3U; while (sample > 0U) { /* Read the input */ Xns = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = (b[1] * Xn[2]) + (b[2] * Xn[3]) + (b[3] * Xns) + (a[0] * Yn[0]) + (a[1] * Yn[1]); /* Store the result in the accumulator in the destination buffer. */ *pOut++ = acc; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn[2] = Xn[3]; Xn[3] = Xns; Yn[0] = Yn[1]; Yn[1] = acc; /* Decrement the loop counter */ sample--; } vst1q_f32(pState,vcombine_f32(vrev64_f32(vget_high_f32(Xn)),vrev64_f32(Yn))); pState += 4; /* Store the updated state variables back into the pState array */ /* The first stage goes from the input buffer to the output buffer. */ /* Subsequent numStages occur in-place in the output buffer */ pIn = pDst; /* Reset the output pointer */ pOut = pDst; /* Decrement the loop counter */ stage--; } } #else void arm_biquad_cascade_df1_f32( const arm_biquad_casd_df1_inst_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { const float32_t *pIn = pSrc; /* Source pointer */ float32_t *pOut = pDst; /* Destination pointer */ float32_t *pState = S->pState; /* pState pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t acc; /* Accumulator */ float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ float32_t Xn1, Xn2, Yn1, Yn2; /* Filter pState variables */ float32_t Xn; /* Temporary input */ uint32_t sample, stage = S->numStages; /* Loop counters */ do { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; a2 = *pCoeffs++; /* Reading the pState values */ Xn1 = pState[0]; Xn2 = pState[1]; Yn1 = pState[2]; Yn2 = pState[3]; #if defined (ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 output values simultaneously. */ /* Variable acc hold output values that are being computed: * * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ /* Loop unrolling: Compute 4 outputs at a time */ sample = blockSize >> 2U; while (sample > 0U) { /* Read the first input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ Yn2 = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn1) + (a2 * Yn2); /* Store output in destination buffer. */ *pOut++ = Yn2; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* Read the second input */ Xn2 = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ Yn1 = (b0 * Xn2) + (b1 * Xn) + (b2 * Xn1) + (a1 * Yn2) + (a2 * Yn1); /* Store output in destination buffer. */ *pOut++ = Yn1; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* Read the third input */ Xn1 = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ Yn2 = (b0 * Xn1) + (b1 * Xn2) + (b2 * Xn) + (a1 * Yn1) + (a2 * Yn2); /* Store output in destination buffer. */ *pOut++ = Yn2; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ /* Read the forth input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ Yn1 = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn2) + (a2 * Yn1); /* Store output in destination buffer. */ *pOut++ = Yn1; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = blockSize & 0x3U; #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { /* Read the input */ Xn = *pIn++; /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ acc = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn1) + (a2 * Yn2); /* Store output in destination buffer. */ *pOut++ = acc; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ /* Xn2 = Xn1 */ /* Xn1 = Xn */ /* Yn2 = Yn1 */ /* Yn1 = acc */ Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; Yn1 = acc; /* decrement loop counter */ sample--; } /* Store the updated state variables back into the pState array */ *pState++ = Xn1; *pState++ = Xn2; *pState++ = Yn1; *pState++ = Yn2; /* The first stage goes from the input buffer to the output buffer. */ /* Subsequent numStages occur in-place in the output buffer */ pIn = pDst; /* Reset output pointer */ pOut = pDst; /* decrement loop counter */ stage--; } while (stage > 0U); } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of BiquadCascadeDF1 group */
18,803
C
36.91129
227
0.559272
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_biquad_cascade_df2T_f64.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_f64.c * Description: Processing function for floating-point transposed direct form II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @defgroup BiquadCascadeDF2T Biquad Cascade IIR Filters Using a Direct Form II Transposed Structure This set of functions implements arbitrary order recursive (IIR) filters using a transposed direct form II structure. The filters are implemented as a cascade of second order Biquad sections. These functions provide a slight memory savings as compared to the direct form I Biquad filter functions. Only floating-point data is supported. This function operate on blocks of input and output data and each call to the function processes <code>blockSize</code> samples through the filter. <code>pSrc</code> points to the array of input data and <code>pDst</code> points to the array of output data. Both arrays contain <code>blockSize</code> values. @par Algorithm Each Biquad stage implements a second order filter using the difference equation: <pre> y[n] = b0 * x[n] + d1 d1 = b1 * x[n] + a1 * y[n] + d2 d2 = b2 * x[n] + a2 * y[n] </pre> where d1 and d2 represent the two state values. @par A Biquad filter using a transposed Direct Form II structure is shown below. \image html BiquadDF2Transposed.gif "Single transposed Direct Form II Biquad" Coefficients <code>b0, b1, and b2 </code> multiply the input signal <code>x[n]</code> and are referred to as the feedforward coefficients. Coefficients <code>a1</code> and <code>a2</code> multiply the output signal <code>y[n]</code> and are referred to as the feedback coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools flip the sign of the feedback coefficients: <pre> y[n] = b0 * x[n] + d1; d1 = b1 * x[n] - a1 * y[n] + d2; d2 = b2 * x[n] - a2 * y[n]; </pre> In this case the feedback coefficients <code>a1</code> and <code>a2</code> must be negated when used with the CMSIS DSP Library. @par Higher order filters are realized as a cascade of second order sections. <code>numStages</code> refers to the number of second order stages used. For example, an 8th order filter would be realized with <code>numStages=4</code> second order stages. A 9th order filter would be realized with <code>numStages=5</code> second order stages with the coefficients for one of the stages configured as a first order filter (<code>b2=0</code> and <code>a2=0</code>). @par <code>pState</code> points to the state variable array. Each Biquad stage has 2 state variables <code>d1</code> and <code>d2</code>. The state variables are arranged in the <code>pState</code> array as: <pre> {d11, d12, d21, d22, ...} </pre> where <code>d1x</code> refers to the state variables for the first Biquad and <code>d2x</code> refers to the state variables for the second Biquad. The state array has a total length of <code>2*numStages</code> values. The state variables are updated after each block of data is processed; the coefficients are untouched. @par The CMSIS library contains Biquad filters in both Direct Form I and transposed Direct Form II. The advantage of the Direct Form I structure is that it is numerically more robust for fixed-point data types. That is why the Direct Form I structure supports Q15 and Q31 data types. The transposed Direct Form II structure, on the other hand, requires a wide dynamic range for the state variables <code>d1</code> and <code>d2</code>. Because of this, the CMSIS library only has a floating-point version of the Direct Form II Biquad. The advantage of the Direct Form II Biquad is that it requires half the number of state variables, 2 rather than 4, per Biquad stage. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. @par Init Functions There is also an associated initialization function. The initialization function performs following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. To do this manually without calling the init function, assign the follow subfields of the instance structure: numStages, pCoeffs, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. For example, to statically initialize the instance structure use <pre> arm_biquad_cascade_df2T_instance_f64 S1 = {numStages, pState, pCoeffs}; arm_biquad_cascade_df2T_instance_f32 S1 = {numStages, pState, pCoeffs}; </pre> where <code>numStages</code> is the number of Biquad stages in the filter; <code>pState</code> is the address of the state buffer. <code>pCoeffs</code> is the address of the coefficient buffer; */ /** @addtogroup BiquadCascadeDF2T @{ */ /** @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. @param[in] S points to an instance of the filter data structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ LOW_OPTIMIZATION_ENTER void arm_biquad_cascade_df2T_f64( const arm_biquad_cascade_df2T_instance_f64 * S, float64_t * pSrc, float64_t * pDst, uint32_t blockSize) { float64_t *pIn = pSrc; /* Source pointer */ float64_t *pOut = pDst; /* Destination pointer */ float64_t *pState = S->pState; /* State pointer */ float64_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float64_t acc1; /* Accumulator */ float64_t b0, b1, b2, a1, a2; /* Filter coefficients */ float64_t Xn1; /* Temporary input */ float64_t d1, d2; /* State variables */ uint32_t sample, stage = S->numStages; /* Loop counters */ do { /* Reading the coefficients */ b0 = pCoeffs[0]; b1 = pCoeffs[1]; b2 = pCoeffs[2]; a1 = pCoeffs[3]; a2 = pCoeffs[4]; /* Reading the state values */ d1 = pState[0]; d2 = pState[1]; pCoeffs += 5U; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 16 outputs at a time */ sample = blockSize >> 4U; while (sample > 0U) { /* y[n] = b0 * x[n] + d1 */ /* d1 = b1 * x[n] + a1 * y[n] + d2 */ /* d2 = b2 * x[n] + a2 * y[n] */ /* 1 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 2 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 3 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 4 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 5 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 6 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 7 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 8 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 9 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 10 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 11 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 12 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 13 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 14 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 15 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* 16 */ Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* decrement loop counter */ sample--; } /* Loop unrolling: Compute remaining outputs */ sample = blockSize & 0xFU; #else /* Initialize blkCnt with number of samples */ sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (sample > 0U) { Xn1 = *pIn++; acc1 = b0 * Xn1 + d1; d1 = b1 * Xn1 + d2; d1 += a1 * acc1; d2 = b2 * Xn1; d2 += a2 * acc1; *pOut++ = acc1; /* decrement loop counter */ sample--; } /* Store the updated state variables back into the state array */ pState[0] = d1; pState[1] = d2; pState += 2U; /* The current stage input is given as the output to the next stage */ pIn = pDst; /* Reset the output working pointer */ pOut = pDst; /* decrement loop counter */ stage--; } while (stage > 0U); } LOW_OPTIMIZATION_EXIT /** @} end of BiquadCascadeDF2T group */
13,152
C
28.623874
169
0.530186
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_lms_norm_q15.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_lms_norm_q15.c * Description: Processing function for Q15 normalized LMS filter * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @ingroup groupFilters */ /** @addtogroup LMS_NORM @{ */ /** @brief Processing function for Q15 normalized LMS filter. @param[in] S points to an instance of the Q15 normalized LMS filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @param[out] pErr points to the block of error data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior The function is implemented using a 64-bit internal accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. @par In this filter, filter coefficients are updated for each sample and the updation of filter cofficients are saturted. */ void arm_lms_norm_q15( arm_lms_norm_instance_q15 * S, const q15_t * pSrc, q15_t * pRef, q15_t * pOut, q15_t * pErr, uint32_t blockSize) { q15_t *pState = S->pState; /* State pointer */ q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ q15_t *pStateCurnt; /* Points to the current sample of the state */ q15_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ q15_t mu = S->mu; /* Adaptive factor */ uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ uint32_t tapCnt, blkCnt; /* Loop counters */ q63_t acc; /* Accumulator */ q31_t energy; /* Energy of the input */ q15_t e = 0, d = 0; /* Error, reference data sample */ q15_t w = 0, in; /* Weight factor and state */ q15_t x0; /* Temporary variable to hold input sample */ q15_t errorXmu, oneByEnergy; /* Temporary variables to store error and mu product and reciprocal of energy */ q15_t postShift; /* Post shift to be applied to weight after reciprocal calculation */ q31_t coef; /* Temporary variable for coefficient */ q31_t acc_l, acc_h; /* Temporary input */ int32_t lShift = (15 - (int32_t) S->postShift); /* Post shift */ int32_t uShift = (32 - lShift); energy = S->energy; x0 = S->x0; /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc; /* Initialize pState pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; /* Read the sample from input buffer */ in = *pSrc++; /* Update the energy calculation */ energy -= (((q31_t) x0 * (x0)) >> 15); energy += (((q31_t) in * (in)) >> 15); /* Set the accumulator to zero */ acc = 0; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (q63_t) (((q31_t) (*px++) * (*pb++))); /* Decrement the loop counter */ tapCnt--; } /* Calc lower part of acc */ acc_l = acc & 0xffffffff; /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ acc = (uint32_t) acc_l >> lShift | acc_h << uShift; /* Converting the result to 1.15 format and saturate the output */ acc = __SSAT(acc, 16U); /* Store the result from accumulator into the destination buffer. */ *pOut++ = (q15_t) acc; /* Compute and store error */ d = *pRef++; e = d - (q15_t) acc; *pErr++ = e; /* Calculation of 1/energy */ postShift = arm_recip_q15((q15_t) energy + DELTA_Q15, &oneByEnergy, S->recipTable); /* Calculation of e * mu value */ errorXmu = (q15_t) (((q31_t) e * mu) >> 15); /* Calculation of (e * mu) * (1/energy) value */ acc = (((q31_t) errorXmu * oneByEnergy) >> (15 - postShift)); /* Weighting factor for the normalized version */ w = (q15_t) __SSAT((q31_t) acc, 16); /* Initialize pState pointer */ px = pState; /* Initialize coefficient pointer */ pb = pCoeffs; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ while (tapCnt > 0U) { coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); *pb++ = (q15_t) __SSAT(coef, 16); coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); *pb++ = (q15_t) __SSAT(coef, 16); coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); *pb++ = (q15_t) __SSAT(coef, 16); coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); *pb++ = (q15_t) __SSAT(coef, 16); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = numTaps; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); *pb++ = (q15_t) __SSAT(coef, 16); /* Decrement loop counter */ tapCnt--; } x0 = *pState; /* Advance state pointer by 1 for the next sample */ pState = pState + 1; /* Decrement loop counter */ blkCnt--; } /* Save energy and x0 values for the next frame */ S->energy = (q15_t) energy; S->x0 = x0; /* Processing is complete. Now copy the last numTaps - 1 samples to the start of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the pState buffer */ pStateCurnt = S->pState; /* copy data */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; while (tapCnt > 0U) { write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining taps */ tapCnt = (numTaps - 1U) % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = (numTaps - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } } /** @} end of LMS_NORM group */
9,383
C
30.489933
135
0.552595
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Source/FilteringFunctions/arm_fir_interpolate_f32.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_fir_interpolate_f32.c * Description: Floating-point FIR interpolation sequences * * $Date: 18. March 2019 * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * 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. */ #include "arm_math.h" /** @defgroup FIR_Interpolate Finite Impulse Response (FIR) Interpolator These functions combine an upsampler (zero stuffer) and an FIR filter. They are used in multirate systems for increasing the sample rate of a signal without introducing high frequency images. Conceptually, the functions are equivalent to the block diagram below: \image html FIRInterpolator.gif "Components included in the FIR Interpolator functions" After upsampling by a factor of <code>L</code>, the signal should be filtered by a lowpass filter with a normalized cutoff frequency of <code>1/L</code> in order to eliminate high frequency copies of the spectrum. The user of the function is responsible for providing the filter coefficients. The FIR interpolator functions provided in the CMSIS DSP Library combine the upsampler and FIR filter in an efficient manner. The upsampler inserts <code>L-1</code> zeros between each sample. Instead of multiplying by these zero values, the FIR filter is designed to skip them. This leads to an efficient implementation without any wasted effort. The functions operate on blocks of input and output data. <code>pSrc</code> points to an array of <code>blockSize</code> input values and <code>pDst</code> points to an array of <code>blockSize*L</code> output values. The library provides separate functions for Q15, Q31, and floating-point data types. @par Algorithm The functions use a polyphase filter structure: <pre> y[n] = b[0] * x[n] + b[L] * x[n-1] + ... + b[L*(phaseLength-1)] * x[n-phaseLength+1] y[n+1] = b[1] * x[n] + b[L+1] * x[n-1] + ... + b[L*(phaseLength-1)+1] * x[n-phaseLength+1] ... y[n+(L-1)] = b[L-1] * x[n] + b[2*L-1] * x[n-1] + ....+ b[L*(phaseLength-1)+(L-1)] * x[n-phaseLength+1] </pre> This approach is more efficient than straightforward upsample-then-filter algorithms. With this method the computation is reduced by a factor of <code>1/L</code> when compared to using a standard FIR filter. @par <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>. <code>numTaps</code> must be a multiple of the interpolation factor <code>L</code> and this is checked by the initialization functions. Internally, the function divides the FIR filter's impulse response into shorter filters of length <code>phaseLength=numTaps/L</code>. Coefficients are stored in time reversed order. <pre> {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} </pre> @par <code>pState</code> points to a state array of size <code>blockSize + phaseLength - 1</code>. Samples in the state buffer are stored in the order: <pre> {x[n-phaseLength+1], x[n-phaseLength], x[n-phaseLength-1], x[n-phaseLength-2]....x[0], x[1], ..., x[blockSize-1]} </pre> @par The state variables are updated after each block of data is processed, the coefficients are untouched. @par Instance Structure The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter. Coefficient arrays may be shared among several instances while state variable array should be allocated separately. There are separate instance structure declarations for each of the 3 supported data types. @par Initialization Functions There is also an associated initialization function for each data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - Checks to make sure that the length of the filter is a multiple of the interpolation factor. To do this manually without calling the init function, assign the follow subfields of the instance structure: L (interpolation factor), pCoeffs, phaseLength (numTaps / L), pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. The code below statically initializes each of the 3 different data type filter instance structures <pre> arm_fir_interpolate_instance_f32 S = {L, phaseLength, pCoeffs, pState}; arm_fir_interpolate_instance_q31 S = {L, phaseLength, pCoeffs, pState}; arm_fir_interpolate_instance_q15 S = {L, phaseLength, pCoeffs, pState}; </pre> @par where <code>L</code> is the interpolation factor; <code>phaseLength=numTaps/L</code> is the length of each of the shorter FIR filters used internally, <code>pCoeffs</code> is the address of the coefficient buffer; <code>pState</code> is the address of the state buffer. Be sure to set the values in the state buffer to zeros when doing static initialization. @par Fixed-Point Behavior Care must be taken when using the fixed-point versions of the FIR interpolate filter functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. */ /** @addtogroup FIR_Interpolate @{ */ /** @brief Processing function for floating-point FIR interpolator. @param[in] S points to an instance of the floating-point FIR interpolator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ #if defined(ARM_MATH_NEON) void arm_fir_interpolate_f32( const arm_fir_interpolate_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCurnt; /* Points to the current sample of the state */ float32_t *ptr1; /* Temporary pointers for state buffer */ const float32_t *ptr2; /* Temporary pointers for coefficient buffer */ float32_t sum0; /* Accumulators */ float32_t x0, c0; /* Temporary variables to hold state and coefficient values */ uint32_t i, blkCnt, j; /* Loop counters */ uint16_t phaseLen = S->phaseLength, tapCnt; /* Length of each polyphase filter component */ float32_t acc0, acc1, acc2, acc3; float32_t x1, x2, x3; uint32_t blkCntN4; float32_t c1, c2, c3; float32x4_t sum0v; float32x4_t accV,accV0,accV1; float32x4_t x0v,x1v,x2v,xa,xb; uint32x4_t x0v_u,x1v_u,x2v_u,xa_u,xb_u; float32x2_t tempV; /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCurnt points to the location where the new input data should be written */ pStateCurnt = S->pState + (phaseLen - 1U); /* Initialise blkCnt */ blkCnt = blockSize >> 3; blkCntN4 = blockSize & 7; /* Loop unrolling */ while (blkCnt > 0U) { /* Copy new input samples into the state buffer */ sum0v = vld1q_f32(pSrc); vst1q_f32(pStateCurnt,sum0v); pSrc += 4; pStateCurnt += 4; sum0v = vld1q_f32(pSrc); vst1q_f32(pStateCurnt,sum0v); pSrc += 4; pStateCurnt += 4; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = (S->L); while (i > 0U) { /* Set accumulator to zero */ accV0 = vdupq_n_f32(0.0); accV1 = vdupq_n_f32(0.0); /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Unroll by a factor of 4. ** Repeat until we've computed numTaps-(4*S->L) coefficients. */ tapCnt = phaseLen >> 2U; x0v = vld1q_f32(ptr1); x1v = vld1q_f32(ptr1 + 4); while (tapCnt > 0U) { /* Read the input samples */ x2v = vld1q_f32(ptr1 + 8); /* Read the coefficients */ c0 = *(ptr2); /* Perform the multiply-accumulate */ accV0 = vmlaq_n_f32(accV0,x0v,c0); accV1 = vmlaq_n_f32(accV1,x1v,c0); /* Read the coefficients, inputs and perform multiply-accumulate */ c1 = *(ptr2 + S->L); xa = vextq_f32(x0v,x1v,1); xb = vextq_f32(x1v,x2v,1); accV0 = vmlaq_n_f32(accV0,xa,c1); accV1 = vmlaq_n_f32(accV1,xb,c1); /* Read the coefficients, inputs and perform multiply-accumulate */ c2 = *(ptr2 + S->L * 2); xa = vextq_f32(x0v,x1v,2); xb = vextq_f32(x1v,x2v,2); accV0 = vmlaq_n_f32(accV0,xa,c2); accV1 = vmlaq_n_f32(accV1,xb,c2); /* Read the coefficients, inputs and perform multiply-accumulate */ c3 = *(ptr2 + S->L * 3); xa = vextq_f32(x0v,x1v,3); xb = vextq_f32(x1v,x2v,3); accV0 = vmlaq_n_f32(accV0,xa,c3); accV1 = vmlaq_n_f32(accV1,xb,c3); /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += 4 * S->L; ptr1 += 4; x0v = x1v; x1v = x2v; /* Decrement the loop counter */ tapCnt--; } /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ tapCnt = phaseLen % 0x4U; x2v = vld1q_f32(ptr1 + 8); switch (tapCnt) { case 3: c0 = *(ptr2); accV0 = vmlaq_n_f32(accV0,x0v,c0); accV1 = vmlaq_n_f32(accV1,x1v,c0); ptr2 += S->L; c0 = *(ptr2); xa = vextq_f32(x0v,x1v,1); xb = vextq_f32(x1v,x2v,1); accV0 = vmlaq_n_f32(accV0,xa,c0); accV1 = vmlaq_n_f32(accV1,xb,c0); ptr2 += S->L; c0 = *(ptr2); xa = vextq_f32(x0v,x1v,2); xb = vextq_f32(x1v,x2v,2); accV0 = vmlaq_n_f32(accV0,xa,c0); accV1 = vmlaq_n_f32(accV1,xb,c0); ptr2 += S->L; break; case 2: c0 = *(ptr2); accV0 = vmlaq_n_f32(accV0,x0v,c0); accV1 = vmlaq_n_f32(accV1,x1v,c0); ptr2 += S->L; c0 = *(ptr2); xa = vextq_f32(x0v,x1v,1); xb = vextq_f32(x1v,x2v,1); accV0 = vmlaq_n_f32(accV0,xa,c0); accV1 = vmlaq_n_f32(accV1,xb,c0); ptr2 += S->L; break; case 1: c0 = *(ptr2); accV0 = vmlaq_n_f32(accV0,x0v,c0); accV1 = vmlaq_n_f32(accV1,x1v,c0); ptr2 += S->L; break; default: break; } /* The result is in the accumulator, store in the destination buffer. */ *pDst = accV0[0]; *(pDst + S->L) = accV0[1]; *(pDst + 2 * S->L) = accV0[2]; *(pDst + 3 * S->L) = accV0[3]; *(pDst + 4 * S->L) = accV1[0]; *(pDst + 5 * S->L) = accV1[1]; *(pDst + 6 * S->L) = accV1[2]; *(pDst + 7 * S->L) = accV1[3]; pDst++; /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement the loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 8; pDst += S->L * 7; /* Decrement the loop counter */ blkCnt--; } /* If the blockSize is not a multiple of 4, compute any remaining output samples here. ** No loop unrolling is used. */ while (blkCntN4 > 0U) { /* Copy new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0v = vdupq_n_f32(0.0); /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Unroll by a factor of 4. ** Repeat until we've computed numTaps-(4*S->L) coefficients. */ tapCnt = phaseLen >> 2U; while (tapCnt > 0U) { /* Read the coefficient */ x1v[0] = *(ptr2); /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Read the input sample */ x0v = vld1q_f32(ptr1); ptr1 += 4; /* Read the coefficient */ x1v[1] = *(ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Read the coefficient */ x1v[2] = *(ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Read the coefficient */ x1v[3] = *(ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; sum0v = vmlaq_f32(sum0v,x0v,x1v); /* Decrement the loop counter */ tapCnt--; } tempV = vpadd_f32(vget_low_f32(sum0v),vget_high_f32(sum0v)); sum0 = tempV[0] + tempV[1]; /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ tapCnt = phaseLen % 0x4U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *(ptr1++) * (*ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement the loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = sum0; /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement the loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement the loop counter */ blkCntN4--; } /* Processing is complete. ** Now copy the last phaseLen - 1 samples to the satrt of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCurnt = S->pState; tapCnt = (phaseLen - 1U) >> 2U; /* Copy data */ while (tapCnt > 0U) { sum0v = vld1q_f32(pState); vst1q_f32(pStateCurnt,sum0v); pState += 4; pStateCurnt += 4; /* Decrement the loop counter */ tapCnt--; } tapCnt = (phaseLen - 1U) % 0x04U; /* copy data */ while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ tapCnt--; } } #else void arm_fir_interpolate_f32( const arm_fir_interpolate_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize) { #if (1) //#if !defined(ARM_MATH_CM0_FAMILY) float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCur; /* Points to the current sample of the state */ float32_t *ptr1; /* Temporary pointer for state buffer */ const float32_t *ptr2; /* Temporary pointer for coefficient buffer */ float32_t sum0; /* Accumulators */ uint32_t i, blkCnt, tapCnt; /* Loop counters */ uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ uint32_t j; #if defined (ARM_MATH_LOOPUNROLL) float32_t acc0, acc1, acc2, acc3; float32_t x0, x1, x2, x3; float32_t c0, c1, c2, c3; #endif /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (phaseLen - 1U); #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = (S->L); while (i > 0U) { /* Set accumulator to zero */ acc0 = 0.0f; acc1 = 0.0f; acc2 = 0.0f; acc3 = 0.0f; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Unroll by a factor of 4. Repeat until we've computed numTaps-(4*S->L) coefficients. */ tapCnt = phaseLen >> 2U; x0 = *(ptr1++); x1 = *(ptr1++); x2 = *(ptr1++); while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); /* Read the coefficient */ c0 = *(ptr2); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Read the coefficient */ c1 = *(ptr2 + S->L); /* Read the input sample */ x0 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += x1 * c1; acc1 += x2 * c1; acc2 += x3 * c1; acc3 += x0 * c1; /* Read the coefficient */ c2 = *(ptr2 + S->L * 2); /* Read the input sample */ x1 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += x2 * c2; acc1 += x3 * c2; acc2 += x0 * c2; acc3 += x1 * c2; /* Read the coefficient */ c3 = *(ptr2 + S->L * 3); /* Read the input sample */ x2 = *(ptr1++); /* Perform the multiply-accumulate */ acc0 += x3 * c3; acc1 += x0 * c3; acc2 += x1 * c3; acc3 += x2 * c3; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += 4 * S->L; /* Decrement loop counter */ tapCnt--; } /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ tapCnt = phaseLen % 0x4U; while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); /* Read the coefficient */ c0 = *(ptr2); /* Perform the multiply-accumulate */ acc0 += x0 * c0; acc1 += x1 * c0; acc2 += x2 * c0; acc3 += x3 * c0; /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* update states for next sample processing */ x0 = x1; x1 = x2; x2 = x3; /* Decrement loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *(pDst ) = acc0; *(pDst + S->L) = acc1; *(pDst + 2 * S->L) = acc2; *(pDst + 3 * S->L) = acc3; pDst++; /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 4; pDst += S->L * 3; /* Decrement loop counter */ blkCnt--; } /* Loop unrolling: Compute remaining outputs */ blkCnt = blockSize % 0x4U; #else /* Initialize blkCnt with number of samples */ blkCnt = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Address modifier index of coefficient buffer */ j = 1U; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0 = 0.0f; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (S->L - j); /* Loop over the polyPhase length. Repeat until we've computed numTaps-(4*S->L) coefficients. */ #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = phaseLen >> 2U; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; sum0 += *ptr1++ * *ptr2; ptr2 += S->L; sum0 += *ptr1++ * *ptr2; ptr2 += S->L; sum0 += *ptr1++ * *ptr2; ptr2 += S->L; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = phaseLen % 0x4U; #else /* Initialize tapCnt with number of samples */ tapCnt = phaseLen; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = sum0; /* Increment the address modifier index of coefficient buffer */ j++; /* Decrement the loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement the loop counter */ blkCnt--; } /* Processing is complete. Now copy the last phaseLen - 1 samples to the satrt of the state buffer. This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; #if defined (ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = (phaseLen - 1U) >> 2U; /* copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } /* Loop unrolling: Compute remaining outputs */ tapCnt = (phaseLen - 1U) % 0x04U; #else /* Initialize tapCnt with number of samples */ tapCnt = (phaseLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #else /* alternate version for CM0_FAMILY */ float32_t *pState = S->pState; /* State pointer */ const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ float32_t *pStateCur; /* Points to the current sample of the state */ float32_t *ptr1; /* Temporary pointer for state buffer */ const float32_t *ptr2; /* Temporary pointer for coefficient buffer */ float32_t sum0; /* Accumulators */ uint32_t i, blkCnt, tapCnt; /* Loop counters */ uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ /* S->pState buffer contains previous frame (phaseLen - 1) samples */ /* pStateCur points to the location where the new input data should be written */ pStateCur = S->pState + (phaseLen - 1U); /* Total number of intput samples */ blkCnt = blockSize; /* Loop over the blockSize. */ while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Loop over the Interpolation factor. */ i = S->L; while (i > 0U) { /* Set accumulator to zero */ sum0 = 0.0f; /* Initialize state pointer */ ptr1 = pState; /* Initialize coefficient pointer */ ptr2 = pCoeffs + (i - 1U); /* Loop over the polyPhase length */ tapCnt = phaseLen; while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *ptr1++ * *ptr2; /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; /* Decrement the loop counter */ tapCnt--; } /* The result is in the accumulator, store in the destination buffer. */ *pDst++ = sum0; /* Decrement loop counter */ i--; } /* Advance the state pointer by 1 * to process the next group of interpolation factor number samples */ pState = pState + 1; /* Decrement loop counter */ blkCnt--; } /* Processing is complete. ** Now copy the last phaseLen - 1 samples to the start of the state buffer. ** This prepares the state buffer for the next function call. */ /* Points to the start of the state buffer */ pStateCur = S->pState; tapCnt = phaseLen - 1U; /* Copy data */ while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ } #endif /* #if defined(ARM_MATH_NEON) */ /** @} end of FIR_Interpolate group */
28,073
C
29.681967
140
0.568732
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Include/arm_math.h
/****************************************************************************** * @file arm_math.h * @brief Public header file for CMSIS DSP Library * @version V1.6.0 * @date 18. March 2019 ******************************************************************************/ /* * Copyright (c) 2010-2019 Arm Limited or its affiliates. All rights reserved. * * 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. */ /** \mainpage CMSIS DSP Software Library * * Introduction * ------------ * * This user manual describes the CMSIS DSP software library, * a suite of common signal processing functions for use on Cortex-M processor based devices. * * The library is divided into a number of functions each covering a specific category: * - Basic math functions * - Fast math functions * - Complex math functions * - Filters * - Matrix functions * - Transform functions * - Motor control functions * - Statistical functions * - Support functions * - Interpolation functions * * The library has separate functions for operating on 8-bit integers, 16-bit integers, * 32-bit integer and 32-bit floating-point values. * * Using the Library * ------------ * * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder. * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit) * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit) * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit) * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on) * - arm_cortexM7l_math.lib (Cortex-M7, Little endian) * - arm_cortexM7b_math.lib (Cortex-M7, Big endian) * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit) * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit) * - arm_cortexM4l_math.lib (Cortex-M4, Little endian) * - arm_cortexM4b_math.lib (Cortex-M4, Big endian) * - arm_cortexM3l_math.lib (Cortex-M3, Little endian) * - arm_cortexM3b_math.lib (Cortex-M3, Big endian) * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian) * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian) * - arm_ARMv8MBLl_math.lib (Armv8-M Baseline, Little endian) * - arm_ARMv8MMLl_math.lib (Armv8-M Mainline, Little endian) * - arm_ARMv8MMLlfsp_math.lib (Armv8-M Mainline, Little endian, Single Precision Floating Point Unit) * - arm_ARMv8MMLld_math.lib (Armv8-M Mainline, Little endian, DSP instructions) * - arm_ARMv8MMLldfsp_math.lib (Armv8-M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit) * * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder. * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single * public header file <code> arm_math.h</code> for Cortex-M cores with little endian and big endian. Same header file will be used for floating point unit(FPU) variants. * * * Examples * -------- * * The library ships with a number of examples which demonstrate how to use the library functions. * * Toolchain Support * ------------ * * The library has been developed and tested with MDK version 5.14.0.0 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly. * * Building the Library * ------------ * * The library installer contains a project file to rebuild libraries on MDK toolchain in the <code>CMSIS\\DSP\\Projects\\ARM</code> folder. * - arm_cortexM_math.uvprojx * * * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional preprocessor macros detailed above. * * Preprocessor Macros * ------------ * * Each library project have different preprocessor macros. * * - ARM_MATH_BIG_ENDIAN: * * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets. * * - ARM_MATH_MATRIX_CHECK: * * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices * * - ARM_MATH_ROUNDING: * * Define macro ARM_MATH_ROUNDING for rounding on support functions * * - ARM_MATH_LOOPUNROLL: * * Define macro ARM_MATH_LOOPUNROLL to enable manual loop unrolling in DSP functions * * - ARM_MATH_NEON: * * Define macro ARM_MATH_NEON to enable Neon versions of the DSP functions. * It is not enabled by default when Neon is available because performances are * dependent on the compiler and target architecture. * * - ARM_MATH_NEON_EXPERIMENTAL: * * Define macro ARM_MATH_NEON_EXPERIMENTAL to enable experimental Neon versions of * of some DSP functions. Experimental Neon versions currently do not have better * performances than the scalar versions. * * <hr> * CMSIS-DSP in ARM::CMSIS Pack * ----------------------------- * * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories: * |File/Folder |Content | * |---------------------------------|------------------------------------------------------------------------| * |\b CMSIS\\Documentation\\DSP | This documentation | * |\b CMSIS\\DSP\\DSP_Lib_TestSuite | DSP_Lib test suite | * |\b CMSIS\\DSP\\Examples | Example projects demonstrating the usage of the library functions | * |\b CMSIS\\DSP\\Include | DSP_Lib include files | * |\b CMSIS\\DSP\\Lib | DSP_Lib binaries | * |\b CMSIS\\DSP\\Projects | Projects to rebuild DSP_Lib binaries | * |\b CMSIS\\DSP\\Source | DSP_Lib source files | * * <hr> * Revision History of CMSIS-DSP * ------------ * Please refer to \ref ChangeLog_pg. */ /** * @defgroup groupMath Basic Math Functions */ /** * @defgroup groupFastMath Fast Math Functions * This set of functions provides a fast approximation to sine, cosine, and square root. * As compared to most of the other functions in the CMSIS math library, the fast math functions * operate on individual values and not arrays. * There are separate functions for Q15, Q31, and floating-point data. * */ /** * @defgroup groupCmplxMath Complex Math Functions * This set of functions operates on complex data vectors. * The data in the complex arrays is stored in an interleaved fashion * (real, imag, real, imag, ...). * In the API functions, the number of samples in a complex array refers * to the number of complex values; the array contains twice this number of * real values. */ /** * @defgroup groupFilters Filtering Functions */ /** * @defgroup groupMatrix Matrix Functions * * This set of functions provides basic matrix math operations. * The functions operate on matrix data structures. For example, * the type * definition for the floating-point matrix structure is shown * below: * <pre> * typedef struct * { * uint16_t numRows; // number of rows of the matrix. * uint16_t numCols; // number of columns of the matrix. * float32_t *pData; // points to the data of the matrix. * } arm_matrix_instance_f32; * </pre> * There are similar definitions for Q15 and Q31 data types. * * The structure specifies the size of the matrix and then points to * an array of data. The array is of size <code>numRows X numCols</code> * and the values are arranged in row order. That is, the * matrix element (i, j) is stored at: * <pre> * pData[i*numCols + j] * </pre> * * \par Init Functions * There is an associated initialization function for each type of matrix * data structure. * The initialization function sets the values of the internal structure fields. * Refer to \ref arm_mat_init_f32(), \ref arm_mat_init_q31() and \ref arm_mat_init_q15() * for floating-point, Q31 and Q15 types, respectively. * * \par * Use of the initialization function is optional. However, if initialization function is used * then the instance structure cannot be placed into a const data section. * To place the instance structure in a const data * section, manually initialize the data structure. For example: * <pre> * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code> * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code> * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code> * </pre> * where <code>nRows</code> specifies the number of rows, <code>nColumns</code> * specifies the number of columns, and <code>pData</code> points to the * data array. * * \par Size Checking * By default all of the matrix functions perform size checking on the input and * output matrices. For example, the matrix addition function verifies that the * two input matrices and the output matrix all have the same number of rows and * columns. If the size check fails the functions return: * <pre> * ARM_MATH_SIZE_MISMATCH * </pre> * Otherwise the functions return * <pre> * ARM_MATH_SUCCESS * </pre> * There is some overhead associated with this matrix size checking. * The matrix size checking is enabled via the \#define * <pre> * ARM_MATH_MATRIX_CHECK * </pre> * within the library project settings. By default this macro is defined * and size checking is enabled. By changing the project settings and * undefining this macro size checking is eliminated and the functions * run a bit faster. With size checking disabled the functions always * return <code>ARM_MATH_SUCCESS</code>. */ /** * @defgroup groupTransforms Transform Functions */ /** * @defgroup groupController Controller Functions */ /** * @defgroup groupStats Statistics Functions */ /** * @defgroup groupSupport Support Functions */ /** * @defgroup groupInterpolation Interpolation Functions * These functions perform 1- and 2-dimensional interpolation of data. * Linear interpolation is used for 1-dimensional data and * bilinear interpolation is used for 2-dimensional data. */ /** * @defgroup groupExamples Examples */ #ifndef _ARM_MATH_H #define _ARM_MATH_H /* Compiler specific diagnostic adjustment */ #if defined ( __CC_ARM ) #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) #elif defined ( __GNUC__ ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wunused-parameter" #elif defined ( __ICCARM__ ) #elif defined ( __TI_ARM__ ) #elif defined ( __CSMC__ ) #elif defined ( __TASKING__ ) #elif defined ( _MSC_VER ) #else #error Unknown compiler #endif /* Included for instrinsics definitions */ #if !defined ( _MSC_VER ) #include "cmsis_compiler.h" #else #include <stdint.h> #define __STATIC_FORCEINLINE static __forceinline #define __ALIGNED(x) __declspec(align(x)) #define LOW_OPTIMIZATION_ENTER #define LOW_OPTIMIZATION_EXIT #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #endif #include "string.h" #include "math.h" #include "float.h" /* evaluate ARM DSP feature */ #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) #define ARM_MATH_DSP 1 #endif #if defined(__ARM_NEON) #include <arm_neon.h> #endif #ifdef __cplusplus extern "C" { #endif /** * @brief Macros required for reciprocal calculation in Normalized LMS */ #define DELTA_Q31 (0x100) #define DELTA_Q15 0x5 #define INDEX_MASK 0x0000003F #ifndef PI #define PI 3.14159265358979f #endif /** * @brief Macros required for SINE and COSINE Fast math approximations */ #define FAST_MATH_TABLE_SIZE 512 #define FAST_MATH_Q31_SHIFT (32 - 10) #define FAST_MATH_Q15_SHIFT (16 - 10) #define CONTROLLER_Q31_SHIFT (32 - 9) #define TABLE_SPACING_Q31 0x400000 #define TABLE_SPACING_Q15 0x80 /** * @brief Macros required for SINE and COSINE Controller functions */ /* 1.31(q31) Fixed value of 2/360 */ /* -1 to +1 is divided into 360 values so total spacing is (2/360) */ #define INPUT_SPACING 0xB60B61 /** * @brief Error status returned by some functions in the library. */ typedef enum { ARM_MATH_SUCCESS = 0, /**< No error */ ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */ ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */ ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation */ ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */ ARM_MATH_SINGULAR = -5, /**< Input matrix is singular and cannot be inverted */ ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */ } arm_status; /** * @brief 8-bit fractional data type in 1.7 format. */ typedef int8_t q7_t; /** * @brief 16-bit fractional data type in 1.15 format. */ typedef int16_t q15_t; /** * @brief 32-bit fractional data type in 1.31 format. */ typedef int32_t q31_t; /** * @brief 64-bit fractional data type in 1.63 format. */ typedef int64_t q63_t; /** * @brief 32-bit floating-point type definition. */ typedef float float32_t; /** * @brief 64-bit floating-point type definition. */ typedef double float64_t; /** @brief definition to read/write two 16 bit values. @deprecated */ #if defined ( __CC_ARM ) #define __SIMD32_TYPE int32_t __packed #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) #define __SIMD32_TYPE int32_t #elif defined ( __GNUC__ ) #define __SIMD32_TYPE int32_t #elif defined ( __ICCARM__ ) #define __SIMD32_TYPE int32_t __packed #elif defined ( __TI_ARM__ ) #define __SIMD32_TYPE int32_t #elif defined ( __CSMC__ ) #define __SIMD32_TYPE int32_t #elif defined ( __TASKING__ ) #define __SIMD32_TYPE __un(aligned) int32_t #elif defined(_MSC_VER ) #define __SIMD32_TYPE int32_t #else #error Unknown compiler #endif #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr)) #define __SIMD32_CONST(addr) ( (__SIMD32_TYPE * ) (addr)) #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE * ) (addr)) #define __SIMD64(addr) (*( int64_t **) & (addr)) /* SIMD replacement */ /** @brief Read 2 Q15 from Q15 pointer. @param[in] pQ15 points to input value @return Q31 value */ __STATIC_FORCEINLINE q31_t read_q15x2 ( q15_t * pQ15) { q31_t val; memcpy (&val, pQ15, 4); return (val); } /** @brief Read 2 Q15 from Q15 pointer and increment pointer afterwards. @param[in] pQ15 points to input value @return Q31 value */ __STATIC_FORCEINLINE q31_t read_q15x2_ia ( q15_t ** pQ15) { q31_t val; memcpy (&val, *pQ15, 4); *pQ15 += 2; return (val); } /** @brief Read 2 Q15 from Q15 pointer and decrement pointer afterwards. @param[in] pQ15 points to input value @return Q31 value */ __STATIC_FORCEINLINE q31_t read_q15x2_da ( q15_t ** pQ15) { q31_t val; memcpy (&val, *pQ15, 4); *pQ15 -= 2; return (val); } /** @brief Write 2 Q15 to Q15 pointer and increment pointer afterwards. @param[in] pQ15 points to input value @param[in] value Q31 value @return none */ __STATIC_FORCEINLINE void write_q15x2_ia ( q15_t ** pQ15, q31_t value) { q31_t val = value; memcpy (*pQ15, &val, 4); *pQ15 += 2; } /** @brief Write 2 Q15 to Q15 pointer. @param[in] pQ15 points to input value @param[in] value Q31 value @return none */ __STATIC_FORCEINLINE void write_q15x2 ( q15_t * pQ15, q31_t value) { q31_t val = value; memcpy (pQ15, &val, 4); } /** @brief Read 4 Q7 from Q7 pointer and increment pointer afterwards. @param[in] pQ7 points to input value @return Q31 value */ __STATIC_FORCEINLINE q31_t read_q7x4_ia ( q7_t ** pQ7) { q31_t val; memcpy (&val, *pQ7, 4); *pQ7 += 4; return (val); } /** @brief Read 4 Q7 from Q7 pointer and decrement pointer afterwards. @param[in] pQ7 points to input value @return Q31 value */ __STATIC_FORCEINLINE q31_t read_q7x4_da ( q7_t ** pQ7) { q31_t val; memcpy (&val, *pQ7, 4); *pQ7 -= 4; return (val); } /** @brief Write 4 Q7 to Q7 pointer and increment pointer afterwards. @param[in] pQ7 points to input value @param[in] value Q31 value @return none */ __STATIC_FORCEINLINE void write_q7x4_ia ( q7_t ** pQ7, q31_t value) { q31_t val = value; memcpy (*pQ7, &val, 4); *pQ7 += 4; } /* Normally those kind of definitions are in a compiler file in Core or Core_A. But for MSVC compiler it is a bit special. The goal is very specific to CMSIS-DSP and only to allow the use of this library from other systems like Python or Matlab. MSVC is not going to be used to cross-compile to ARM. So, having a MSVC compiler file in Core or Core_A would not make sense. */ #if defined ( _MSC_VER ) __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t data) { if (data == 0U) { return 32U; } uint32_t count = 0U; uint32_t mask = 0x80000000U; while ((data & mask) == 0U) { count += 1U; mask = mask >> 1U; } return count; } __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) { if ((sat >= 1U) && (sat <= 32U)) { const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); const int32_t min = -1 - max ; if (val > max) { return max; } else if (val < min) { return min; } } return val; } __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) { if (sat <= 31U) { const uint32_t max = ((1U << sat) - 1U); if (val > (int32_t)max) { return max; } else if (val < 0) { return 0U; } } return (uint32_t)val; } #endif #ifndef ARM_MATH_DSP /** * @brief definition to pack two 16 bit values. */ #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \ (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) ) #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \ (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) ) #endif /** * @brief definition to pack four 8 bit values. */ #ifndef ARM_MATH_BIG_ENDIAN #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \ (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \ (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \ (((int32_t)(v3) << 24) & (int32_t)0xFF000000) ) #else #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \ (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \ (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \ (((int32_t)(v0) << 24) & (int32_t)0xFF000000) ) #endif /** * @brief Clips Q63 to Q31 values. */ __STATIC_FORCEINLINE q31_t clip_q63_to_q31( q63_t x) { return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x; } /** * @brief Clips Q63 to Q15 values. */ __STATIC_FORCEINLINE q15_t clip_q63_to_q15( q63_t x) { return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15); } /** * @brief Clips Q31 to Q7 values. */ __STATIC_FORCEINLINE q7_t clip_q31_to_q7( q31_t x) { return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ? ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x; } /** * @brief Clips Q31 to Q15 values. */ __STATIC_FORCEINLINE q15_t clip_q31_to_q15( q31_t x) { return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ? ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x; } /** * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format. */ __STATIC_FORCEINLINE q63_t mult32x64( q63_t x, q31_t y) { return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) + (((q63_t) (x >> 32) * y) ) ); } /** * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type. */ __STATIC_FORCEINLINE uint32_t arm_recip_q31( q31_t in, q31_t * dst, const q31_t * pRecipTable) { q31_t out; uint32_t tempVal; uint32_t index, i; uint32_t signBits; if (in > 0) { signBits = ((uint32_t) (__CLZ( in) - 1)); } else { signBits = ((uint32_t) (__CLZ(-in) - 1)); } /* Convert input sample to 1.31 format */ in = (in << signBits); /* calculation of index for initial approximated Val */ index = (uint32_t)(in >> 24); index = (index & INDEX_MASK); /* 1.31 with exp 1 */ out = pRecipTable[index]; /* calculation of reciprocal value */ /* running approximation for two iterations */ for (i = 0U; i < 2U; i++) { tempVal = (uint32_t) (((q63_t) in * out) >> 31); tempVal = 0x7FFFFFFFu - tempVal; /* 1.31 with exp 1 */ /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */ out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30); } /* write output */ *dst = out; /* return num of signbits of out = 1/in value */ return (signBits + 1U); } /** * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type. */ __STATIC_FORCEINLINE uint32_t arm_recip_q15( q15_t in, q15_t * dst, const q15_t * pRecipTable) { q15_t out = 0; uint32_t tempVal = 0; uint32_t index = 0, i = 0; uint32_t signBits = 0; if (in > 0) { signBits = ((uint32_t)(__CLZ( in) - 17)); } else { signBits = ((uint32_t)(__CLZ(-in) - 17)); } /* Convert input sample to 1.15 format */ in = (in << signBits); /* calculation of index for initial approximated Val */ index = (uint32_t)(in >> 8); index = (index & INDEX_MASK); /* 1.15 with exp 1 */ out = pRecipTable[index]; /* calculation of reciprocal value */ /* running approximation for two iterations */ for (i = 0U; i < 2U; i++) { tempVal = (uint32_t) (((q31_t) in * out) >> 15); tempVal = 0x7FFFu - tempVal; /* 1.15 with exp 1 */ out = (q15_t) (((q31_t) out * tempVal) >> 14); /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */ } /* write output */ *dst = out; /* return num of signbits of out = 1/in value */ return (signBits + 1); } #if defined(ARM_MATH_NEON) static inline float32x4_t __arm_vec_sqrt_f32_neon(float32x4_t x) { float32x4_t x1 = vmaxq_f32(x, vdupq_n_f32(FLT_MIN)); float32x4_t e = vrsqrteq_f32(x1); e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); return vmulq_f32(x, e); } static inline int16x8_t __arm_vec_sqrt_q15_neon(int16x8_t vec) { float32x4_t tempF; int32x4_t tempHI,tempLO; tempLO = vmovl_s16(vget_low_s16(vec)); tempF = vcvtq_n_f32_s32(tempLO,15); tempF = __arm_vec_sqrt_f32_neon(tempF); tempLO = vcvtq_n_s32_f32(tempF,15); tempHI = vmovl_s16(vget_high_s16(vec)); tempF = vcvtq_n_f32_s32(tempHI,15); tempF = __arm_vec_sqrt_f32_neon(tempF); tempHI = vcvtq_n_s32_f32(tempF,15); return(vcombine_s16(vqmovn_s32(tempLO),vqmovn_s32(tempHI))); } static inline int32x4_t __arm_vec_sqrt_q31_neon(int32x4_t vec) { float32x4_t temp; temp = vcvtq_n_f32_s32(vec,31); temp = __arm_vec_sqrt_f32_neon(temp); return(vcvtq_n_s32_f32(temp,31)); } #endif /* * @brief C custom defined intrinsic functions */ #if !defined (ARM_MATH_DSP) /* * @brief C custom defined QADD8 */ __STATIC_FORCEINLINE uint32_t __QADD8( uint32_t x, uint32_t y) { q31_t r, s, t, u; r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF; s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF; t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF; u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF; return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r ))); } /* * @brief C custom defined QSUB8 */ __STATIC_FORCEINLINE uint32_t __QSUB8( uint32_t x, uint32_t y) { q31_t r, s, t, u; r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF; s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF; t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF; u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF; return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r ))); } /* * @brief C custom defined QADD16 */ __STATIC_FORCEINLINE uint32_t __QADD16( uint32_t x, uint32_t y) { /* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */ q31_t r = 0, s = 0; r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined SHADD16 */ __STATIC_FORCEINLINE uint32_t __SHADD16( uint32_t x, uint32_t y) { q31_t r, s; r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined QSUB16 */ __STATIC_FORCEINLINE uint32_t __QSUB16( uint32_t x, uint32_t y) { q31_t r, s; r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined SHSUB16 */ __STATIC_FORCEINLINE uint32_t __SHSUB16( uint32_t x, uint32_t y) { q31_t r, s; r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined QASX */ __STATIC_FORCEINLINE uint32_t __QASX( uint32_t x, uint32_t y) { q31_t r, s; r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined SHASX */ __STATIC_FORCEINLINE uint32_t __SHASX( uint32_t x, uint32_t y) { q31_t r, s; r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined QSAX */ __STATIC_FORCEINLINE uint32_t __QSAX( uint32_t x, uint32_t y) { q31_t r, s; r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined SHSAX */ __STATIC_FORCEINLINE uint32_t __SHSAX( uint32_t x, uint32_t y) { q31_t r, s; r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; return ((uint32_t)((s << 16) | (r ))); } /* * @brief C custom defined SMUSDX */ __STATIC_FORCEINLINE uint32_t __SMUSDX( uint32_t x, uint32_t y) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) - ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) )); } /* * @brief C custom defined SMUADX */ __STATIC_FORCEINLINE uint32_t __SMUADX( uint32_t x, uint32_t y) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) )); } /* * @brief C custom defined QADD */ __STATIC_FORCEINLINE int32_t __QADD( int32_t x, int32_t y) { return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y))); } /* * @brief C custom defined QSUB */ __STATIC_FORCEINLINE int32_t __QSUB( int32_t x, int32_t y) { return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y))); } /* * @brief C custom defined SMLAD */ __STATIC_FORCEINLINE uint32_t __SMLAD( uint32_t x, uint32_t y, uint32_t sum) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) + ( ((q31_t)sum ) ) )); } /* * @brief C custom defined SMLADX */ __STATIC_FORCEINLINE uint32_t __SMLADX( uint32_t x, uint32_t y, uint32_t sum) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) + ( ((q31_t)sum ) ) )); } /* * @brief C custom defined SMLSDX */ __STATIC_FORCEINLINE uint32_t __SMLSDX( uint32_t x, uint32_t y, uint32_t sum) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) - ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) + ( ((q31_t)sum ) ) )); } /* * @brief C custom defined SMLALD */ __STATIC_FORCEINLINE uint64_t __SMLALD( uint32_t x, uint32_t y, uint64_t sum) { /* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */ return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) + ( ((q63_t)sum ) ) )); } /* * @brief C custom defined SMLALDX */ __STATIC_FORCEINLINE uint64_t __SMLALDX( uint32_t x, uint32_t y, uint64_t sum) { /* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */ return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) + ( ((q63_t)sum ) ) )); } /* * @brief C custom defined SMUAD */ __STATIC_FORCEINLINE uint32_t __SMUAD( uint32_t x, uint32_t y) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) )); } /* * @brief C custom defined SMUSD */ __STATIC_FORCEINLINE uint32_t __SMUSD( uint32_t x, uint32_t y) { return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) - ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) )); } /* * @brief C custom defined SXTB16 */ __STATIC_FORCEINLINE uint32_t __SXTB16( uint32_t x) { return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) | ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) )); } /* * @brief C custom defined SMMLA */ __STATIC_FORCEINLINE int32_t __SMMLA( int32_t x, int32_t y, int32_t sum) { return (sum + (int32_t) (((int64_t) x * y) >> 32)); } #endif /* !defined (ARM_MATH_DSP) */ /** * @brief Instance structure for the Q7 FIR filter. */ typedef struct { uint16_t numTaps; /**< number of filter coefficients in the filter. */ q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ } arm_fir_instance_q7; /** * @brief Instance structure for the Q15 FIR filter. */ typedef struct { uint16_t numTaps; /**< number of filter coefficients in the filter. */ q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ } arm_fir_instance_q15; /** * @brief Instance structure for the Q31 FIR filter. */ typedef struct { uint16_t numTaps; /**< number of filter coefficients in the filter. */ q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ } arm_fir_instance_q31; /** * @brief Instance structure for the floating-point FIR filter. */ typedef struct { uint16_t numTaps; /**< number of filter coefficients in the filter. */ float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ } arm_fir_instance_f32; /** * @brief Processing function for the Q7 FIR filter. * @param[in] S points to an instance of the Q7 FIR filter structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_q7( const arm_fir_instance_q7 * S, const q7_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q7 FIR filter. * @param[in,out] S points to an instance of the Q7 FIR structure. * @param[in] numTaps Number of filter coefficients in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] blockSize number of samples that are processed. */ void arm_fir_init_q7( arm_fir_instance_q7 * S, uint16_t numTaps, const q7_t * pCoeffs, q7_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q15 FIR filter. * @param[in] S points to an instance of the Q15 FIR structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_q15( const arm_fir_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Processing function for the fast Q15 FIR filter (fast version). * @param[in] S points to an instance of the Q15 FIR filter structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_fast_q15( const arm_fir_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q15 FIR filter. * @param[in,out] S points to an instance of the Q15 FIR filter structure. * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] blockSize number of samples that are processed at a time. * @return The function returns either * <code>ARM_MATH_SUCCESS</code> if initialization was successful or * <code>ARM_MATH_ARGUMENT_ERROR</code> if <code>numTaps</code> is not a supported value. */ arm_status arm_fir_init_q15( arm_fir_instance_q15 * S, uint16_t numTaps, const q15_t * pCoeffs, q15_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q31 FIR filter. * @param[in] S points to an instance of the Q31 FIR filter structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_q31( const arm_fir_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Processing function for the fast Q31 FIR filter (fast version). * @param[in] S points to an instance of the Q31 FIR filter structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_fast_q31( const arm_fir_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q31 FIR filter. * @param[in,out] S points to an instance of the Q31 FIR structure. * @param[in] numTaps Number of filter coefficients in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] blockSize number of samples that are processed at a time. */ void arm_fir_init_q31( arm_fir_instance_q31 * S, uint16_t numTaps, const q31_t * pCoeffs, q31_t * pState, uint32_t blockSize); /** * @brief Processing function for the floating-point FIR filter. * @param[in] S points to an instance of the floating-point FIR structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_f32( const arm_fir_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the floating-point FIR filter. * @param[in,out] S points to an instance of the floating-point FIR filter structure. * @param[in] numTaps Number of filter coefficients in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] blockSize number of samples that are processed at a time. */ void arm_fir_init_f32( arm_fir_instance_f32 * S, uint16_t numTaps, const float32_t * pCoeffs, float32_t * pState, uint32_t blockSize); /** * @brief Instance structure for the Q15 Biquad cascade filter. */ typedef struct { int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ const q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ } arm_biquad_casd_df1_inst_q15; /** * @brief Instance structure for the Q31 Biquad cascade filter. */ typedef struct { uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ const q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ } arm_biquad_casd_df1_inst_q31; /** * @brief Instance structure for the floating-point Biquad cascade filter. */ typedef struct { uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ const float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ } arm_biquad_casd_df1_inst_f32; /** * @brief Processing function for the Q15 Biquad cascade filter. * @param[in] S points to an instance of the Q15 Biquad cascade structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df1_q15( const arm_biquad_casd_df1_inst_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q15 Biquad cascade filter. * @param[in,out] S points to an instance of the Q15 Biquad cascade structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format */ void arm_biquad_cascade_df1_init_q15( arm_biquad_casd_df1_inst_q15 * S, uint8_t numStages, const q15_t * pCoeffs, q15_t * pState, int8_t postShift); /** * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4. * @param[in] S points to an instance of the Q15 Biquad cascade structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df1_fast_q15( const arm_biquad_casd_df1_inst_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Processing function for the Q31 Biquad cascade filter * @param[in] S points to an instance of the Q31 Biquad cascade structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df1_q31( const arm_biquad_casd_df1_inst_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4. * @param[in] S points to an instance of the Q31 Biquad cascade structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df1_fast_q31( const arm_biquad_casd_df1_inst_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q31 Biquad cascade filter. * @param[in,out] S points to an instance of the Q31 Biquad cascade structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format */ void arm_biquad_cascade_df1_init_q31( arm_biquad_casd_df1_inst_q31 * S, uint8_t numStages, const q31_t * pCoeffs, q31_t * pState, int8_t postShift); /** * @brief Processing function for the floating-point Biquad cascade filter. * @param[in] S points to an instance of the floating-point Biquad cascade structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df1_f32( const arm_biquad_casd_df1_inst_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the floating-point Biquad cascade filter. * @param[in,out] S points to an instance of the floating-point Biquad cascade structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. */ void arm_biquad_cascade_df1_init_f32( arm_biquad_casd_df1_inst_f32 * S, uint8_t numStages, const float32_t * pCoeffs, float32_t * pState); /** * @brief Instance structure for the floating-point matrix structure. */ typedef struct { uint16_t numRows; /**< number of rows of the matrix. */ uint16_t numCols; /**< number of columns of the matrix. */ float32_t *pData; /**< points to the data of the matrix. */ } arm_matrix_instance_f32; /** * @brief Instance structure for the floating-point matrix structure. */ typedef struct { uint16_t numRows; /**< number of rows of the matrix. */ uint16_t numCols; /**< number of columns of the matrix. */ float64_t *pData; /**< points to the data of the matrix. */ } arm_matrix_instance_f64; /** * @brief Instance structure for the Q15 matrix structure. */ typedef struct { uint16_t numRows; /**< number of rows of the matrix. */ uint16_t numCols; /**< number of columns of the matrix. */ q15_t *pData; /**< points to the data of the matrix. */ } arm_matrix_instance_q15; /** * @brief Instance structure for the Q31 matrix structure. */ typedef struct { uint16_t numRows; /**< number of rows of the matrix. */ uint16_t numCols; /**< number of columns of the matrix. */ q31_t *pData; /**< points to the data of the matrix. */ } arm_matrix_instance_q31; /** * @brief Floating-point matrix addition. * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_add_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst); /** * @brief Q15 matrix addition. * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_add_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst); /** * @brief Q31 matrix addition. * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_add_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst); /** * @brief Floating-point, complex, matrix multiplication. * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_cmplx_mult_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst); /** * @brief Q15, complex, matrix multiplication. * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_cmplx_mult_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst, q15_t * pScratch); /** * @brief Q31, complex, matrix multiplication. * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_cmplx_mult_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst); /** * @brief Floating-point matrix transpose. * @param[in] pSrc points to the input matrix * @param[out] pDst points to the output matrix * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_trans_f32( const arm_matrix_instance_f32 * pSrc, arm_matrix_instance_f32 * pDst); /** * @brief Q15 matrix transpose. * @param[in] pSrc points to the input matrix * @param[out] pDst points to the output matrix * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_trans_q15( const arm_matrix_instance_q15 * pSrc, arm_matrix_instance_q15 * pDst); /** * @brief Q31 matrix transpose. * @param[in] pSrc points to the input matrix * @param[out] pDst points to the output matrix * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_trans_q31( const arm_matrix_instance_q31 * pSrc, arm_matrix_instance_q31 * pDst); /** * @brief Floating-point matrix multiplication * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_mult_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst); /** * @brief Q15 matrix multiplication * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @param[in] pState points to the array for storing intermediate results * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_mult_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst, q15_t * pState); /** * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @param[in] pState points to the array for storing intermediate results * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_mult_fast_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst, q15_t * pState); /** * @brief Q31 matrix multiplication * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_mult_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst); /** * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_mult_fast_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst); /** * @brief Floating-point matrix subtraction * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_sub_f32( const arm_matrix_instance_f32 * pSrcA, const arm_matrix_instance_f32 * pSrcB, arm_matrix_instance_f32 * pDst); /** * @brief Q15 matrix subtraction * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_sub_q15( const arm_matrix_instance_q15 * pSrcA, const arm_matrix_instance_q15 * pSrcB, arm_matrix_instance_q15 * pDst); /** * @brief Q31 matrix subtraction * @param[in] pSrcA points to the first input matrix structure * @param[in] pSrcB points to the second input matrix structure * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_sub_q31( const arm_matrix_instance_q31 * pSrcA, const arm_matrix_instance_q31 * pSrcB, arm_matrix_instance_q31 * pDst); /** * @brief Floating-point matrix scaling. * @param[in] pSrc points to the input matrix * @param[in] scale scale factor * @param[out] pDst points to the output matrix * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_scale_f32( const arm_matrix_instance_f32 * pSrc, float32_t scale, arm_matrix_instance_f32 * pDst); /** * @brief Q15 matrix scaling. * @param[in] pSrc points to input matrix * @param[in] scaleFract fractional portion of the scale factor * @param[in] shift number of bits to shift the result by * @param[out] pDst points to output matrix * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_scale_q15( const arm_matrix_instance_q15 * pSrc, q15_t scaleFract, int32_t shift, arm_matrix_instance_q15 * pDst); /** * @brief Q31 matrix scaling. * @param[in] pSrc points to input matrix * @param[in] scaleFract fractional portion of the scale factor * @param[in] shift number of bits to shift the result by * @param[out] pDst points to output matrix structure * @return The function returns either * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. */ arm_status arm_mat_scale_q31( const arm_matrix_instance_q31 * pSrc, q31_t scaleFract, int32_t shift, arm_matrix_instance_q31 * pDst); /** * @brief Q31 matrix initialization. * @param[in,out] S points to an instance of the floating-point matrix structure. * @param[in] nRows number of rows in the matrix. * @param[in] nColumns number of columns in the matrix. * @param[in] pData points to the matrix data array. */ void arm_mat_init_q31( arm_matrix_instance_q31 * S, uint16_t nRows, uint16_t nColumns, q31_t * pData); /** * @brief Q15 matrix initialization. * @param[in,out] S points to an instance of the floating-point matrix structure. * @param[in] nRows number of rows in the matrix. * @param[in] nColumns number of columns in the matrix. * @param[in] pData points to the matrix data array. */ void arm_mat_init_q15( arm_matrix_instance_q15 * S, uint16_t nRows, uint16_t nColumns, q15_t * pData); /** * @brief Floating-point matrix initialization. * @param[in,out] S points to an instance of the floating-point matrix structure. * @param[in] nRows number of rows in the matrix. * @param[in] nColumns number of columns in the matrix. * @param[in] pData points to the matrix data array. */ void arm_mat_init_f32( arm_matrix_instance_f32 * S, uint16_t nRows, uint16_t nColumns, float32_t * pData); /** * @brief Instance structure for the Q15 PID Control. */ typedef struct { q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ #if !defined (ARM_MATH_DSP) q15_t A1; q15_t A2; #else q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/ #endif q15_t state[3]; /**< The state array of length 3. */ q15_t Kp; /**< The proportional gain. */ q15_t Ki; /**< The integral gain. */ q15_t Kd; /**< The derivative gain. */ } arm_pid_instance_q15; /** * @brief Instance structure for the Q31 PID Control. */ typedef struct { q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ q31_t A2; /**< The derived gain, A2 = Kd . */ q31_t state[3]; /**< The state array of length 3. */ q31_t Kp; /**< The proportional gain. */ q31_t Ki; /**< The integral gain. */ q31_t Kd; /**< The derivative gain. */ } arm_pid_instance_q31; /** * @brief Instance structure for the floating-point PID Control. */ typedef struct { float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ float32_t A2; /**< The derived gain, A2 = Kd . */ float32_t state[3]; /**< The state array of length 3. */ float32_t Kp; /**< The proportional gain. */ float32_t Ki; /**< The integral gain. */ float32_t Kd; /**< The derivative gain. */ } arm_pid_instance_f32; /** * @brief Initialization function for the floating-point PID Control. * @param[in,out] S points to an instance of the PID structure. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. */ void arm_pid_init_f32( arm_pid_instance_f32 * S, int32_t resetStateFlag); /** * @brief Reset function for the floating-point PID Control. * @param[in,out] S is an instance of the floating-point PID Control structure */ void arm_pid_reset_f32( arm_pid_instance_f32 * S); /** * @brief Initialization function for the Q31 PID Control. * @param[in,out] S points to an instance of the Q15 PID structure. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. */ void arm_pid_init_q31( arm_pid_instance_q31 * S, int32_t resetStateFlag); /** * @brief Reset function for the Q31 PID Control. * @param[in,out] S points to an instance of the Q31 PID Control structure */ void arm_pid_reset_q31( arm_pid_instance_q31 * S); /** * @brief Initialization function for the Q15 PID Control. * @param[in,out] S points to an instance of the Q15 PID structure. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. */ void arm_pid_init_q15( arm_pid_instance_q15 * S, int32_t resetStateFlag); /** * @brief Reset function for the Q15 PID Control. * @param[in,out] S points to an instance of the q15 PID Control structure */ void arm_pid_reset_q15( arm_pid_instance_q15 * S); /** * @brief Instance structure for the floating-point Linear Interpolate function. */ typedef struct { uint32_t nValues; /**< nValues */ float32_t x1; /**< x1 */ float32_t xSpacing; /**< xSpacing */ float32_t *pYData; /**< pointer to the table of Y values */ } arm_linear_interp_instance_f32; /** * @brief Instance structure for the floating-point bilinear interpolation function. */ typedef struct { uint16_t numRows; /**< number of rows in the data table. */ uint16_t numCols; /**< number of columns in the data table. */ float32_t *pData; /**< points to the data table. */ } arm_bilinear_interp_instance_f32; /** * @brief Instance structure for the Q31 bilinear interpolation function. */ typedef struct { uint16_t numRows; /**< number of rows in the data table. */ uint16_t numCols; /**< number of columns in the data table. */ q31_t *pData; /**< points to the data table. */ } arm_bilinear_interp_instance_q31; /** * @brief Instance structure for the Q15 bilinear interpolation function. */ typedef struct { uint16_t numRows; /**< number of rows in the data table. */ uint16_t numCols; /**< number of columns in the data table. */ q15_t *pData; /**< points to the data table. */ } arm_bilinear_interp_instance_q15; /** * @brief Instance structure for the Q15 bilinear interpolation function. */ typedef struct { uint16_t numRows; /**< number of rows in the data table. */ uint16_t numCols; /**< number of columns in the data table. */ q7_t *pData; /**< points to the data table. */ } arm_bilinear_interp_instance_q7; /** * @brief Q7 vector multiplication. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_mult_q7( const q7_t * pSrcA, const q7_t * pSrcB, q7_t * pDst, uint32_t blockSize); /** * @brief Q15 vector multiplication. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_mult_q15( const q15_t * pSrcA, const q15_t * pSrcB, q15_t * pDst, uint32_t blockSize); /** * @brief Q31 vector multiplication. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_mult_q31( const q31_t * pSrcA, const q31_t * pSrcB, q31_t * pDst, uint32_t blockSize); /** * @brief Floating-point vector multiplication. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_mult_f32( const float32_t * pSrcA, const float32_t * pSrcB, float32_t * pDst, uint32_t blockSize); /** * @brief Instance structure for the Q15 CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ const q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ } arm_cfft_radix2_instance_q15; /* Deprecated */ arm_status arm_cfft_radix2_init_q15( arm_cfft_radix2_instance_q15 * S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag); /* Deprecated */ void arm_cfft_radix2_q15( const arm_cfft_radix2_instance_q15 * S, q15_t * pSrc); /** * @brief Instance structure for the Q15 CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ const q15_t *pTwiddle; /**< points to the twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ } arm_cfft_radix4_instance_q15; /* Deprecated */ arm_status arm_cfft_radix4_init_q15( arm_cfft_radix4_instance_q15 * S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag); /* Deprecated */ void arm_cfft_radix4_q15( const arm_cfft_radix4_instance_q15 * S, q15_t * pSrc); /** * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ const q31_t *pTwiddle; /**< points to the Twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ } arm_cfft_radix2_instance_q31; /* Deprecated */ arm_status arm_cfft_radix2_init_q31( arm_cfft_radix2_instance_q31 * S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag); /* Deprecated */ void arm_cfft_radix2_q31( const arm_cfft_radix2_instance_q31 * S, q31_t * pSrc); /** * @brief Instance structure for the Q31 CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ const q31_t *pTwiddle; /**< points to the twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ } arm_cfft_radix4_instance_q31; /* Deprecated */ void arm_cfft_radix4_q31( const arm_cfft_radix4_instance_q31 * S, q31_t * pSrc); /* Deprecated */ arm_status arm_cfft_radix4_init_q31( arm_cfft_radix4_instance_q31 * S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag); /** * @brief Instance structure for the floating-point CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ float32_t onebyfftLen; /**< value of 1/fftLen. */ } arm_cfft_radix2_instance_f32; /* Deprecated */ arm_status arm_cfft_radix2_init_f32( arm_cfft_radix2_instance_f32 * S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag); /* Deprecated */ void arm_cfft_radix2_f32( const arm_cfft_radix2_instance_f32 * S, float32_t * pSrc); /** * @brief Instance structure for the floating-point CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ float32_t onebyfftLen; /**< value of 1/fftLen. */ } arm_cfft_radix4_instance_f32; /* Deprecated */ arm_status arm_cfft_radix4_init_f32( arm_cfft_radix4_instance_f32 * S, uint16_t fftLen, uint8_t ifftFlag, uint8_t bitReverseFlag); /* Deprecated */ void arm_cfft_radix4_f32( const arm_cfft_radix4_instance_f32 * S, float32_t * pSrc); /** * @brief Instance structure for the fixed-point CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ const q15_t *pTwiddle; /**< points to the Twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t bitRevLength; /**< bit reversal table length. */ } arm_cfft_instance_q15; void arm_cfft_q15( const arm_cfft_instance_q15 * S, q15_t * p1, uint8_t ifftFlag, uint8_t bitReverseFlag); /** * @brief Instance structure for the fixed-point CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ const q31_t *pTwiddle; /**< points to the Twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t bitRevLength; /**< bit reversal table length. */ } arm_cfft_instance_q31; void arm_cfft_q31( const arm_cfft_instance_q31 * S, q31_t * p1, uint8_t ifftFlag, uint8_t bitReverseFlag); /** * @brief Instance structure for the floating-point CFFT/CIFFT function. */ typedef struct { uint16_t fftLen; /**< length of the FFT. */ const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ uint16_t bitRevLength; /**< bit reversal table length. */ } arm_cfft_instance_f32; void arm_cfft_f32( const arm_cfft_instance_f32 * S, float32_t * p1, uint8_t ifftFlag, uint8_t bitReverseFlag); /** * @brief Instance structure for the Q15 RFFT/RIFFT function. */ typedef struct { uint32_t fftLenReal; /**< length of the real FFT. */ uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ const q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ const q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */ } arm_rfft_instance_q15; arm_status arm_rfft_init_q15( arm_rfft_instance_q15 * S, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag); void arm_rfft_q15( const arm_rfft_instance_q15 * S, q15_t * pSrc, q15_t * pDst); /** * @brief Instance structure for the Q31 RFFT/RIFFT function. */ typedef struct { uint32_t fftLenReal; /**< length of the real FFT. */ uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ const q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ const q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */ } arm_rfft_instance_q31; arm_status arm_rfft_init_q31( arm_rfft_instance_q31 * S, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag); void arm_rfft_q31( const arm_rfft_instance_q31 * S, q31_t * pSrc, q31_t * pDst); /** * @brief Instance structure for the floating-point RFFT/RIFFT function. */ typedef struct { uint32_t fftLenReal; /**< length of the real FFT. */ uint16_t fftLenBy2; /**< length of the complex FFT. */ uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ const float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ const float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ } arm_rfft_instance_f32; arm_status arm_rfft_init_f32( arm_rfft_instance_f32 * S, arm_cfft_radix4_instance_f32 * S_CFFT, uint32_t fftLenReal, uint32_t ifftFlagR, uint32_t bitReverseFlag); void arm_rfft_f32( const arm_rfft_instance_f32 * S, float32_t * pSrc, float32_t * pDst); /** * @brief Instance structure for the floating-point RFFT/RIFFT function. */ typedef struct { arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */ uint16_t fftLenRFFT; /**< length of the real sequence */ const float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */ } arm_rfft_fast_instance_f32 ; arm_status arm_rfft_fast_init_f32 ( arm_rfft_fast_instance_f32 * S, uint16_t fftLen); arm_status arm_rfft_32_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_64_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_128_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_256_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_512_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_1024_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_2048_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); arm_status arm_rfft_4096_fast_init_f32 ( arm_rfft_fast_instance_f32 * S ); void arm_rfft_fast_f32( arm_rfft_fast_instance_f32 * S, float32_t * p, float32_t * pOut, uint8_t ifftFlag); /** * @brief Instance structure for the floating-point DCT4/IDCT4 function. */ typedef struct { uint16_t N; /**< length of the DCT4. */ uint16_t Nby2; /**< half of the length of the DCT4. */ float32_t normalize; /**< normalizing factor. */ const float32_t *pTwiddle; /**< points to the twiddle factor table. */ const float32_t *pCosFactor; /**< points to the cosFactor table. */ arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */ arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ } arm_dct4_instance_f32; /** * @brief Initialization function for the floating-point DCT4/IDCT4. * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure. * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure. * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure. * @param[in] N length of the DCT4. * @param[in] Nby2 half of the length of the DCT4. * @param[in] normalize normalizing factor. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length. */ arm_status arm_dct4_init_f32( arm_dct4_instance_f32 * S, arm_rfft_instance_f32 * S_RFFT, arm_cfft_radix4_instance_f32 * S_CFFT, uint16_t N, uint16_t Nby2, float32_t normalize); /** * @brief Processing function for the floating-point DCT4/IDCT4. * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure. * @param[in] pState points to state buffer. * @param[in,out] pInlineBuffer points to the in-place input and output buffer. */ void arm_dct4_f32( const arm_dct4_instance_f32 * S, float32_t * pState, float32_t * pInlineBuffer); /** * @brief Instance structure for the Q31 DCT4/IDCT4 function. */ typedef struct { uint16_t N; /**< length of the DCT4. */ uint16_t Nby2; /**< half of the length of the DCT4. */ q31_t normalize; /**< normalizing factor. */ const q31_t *pTwiddle; /**< points to the twiddle factor table. */ const q31_t *pCosFactor; /**< points to the cosFactor table. */ arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */ arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */ } arm_dct4_instance_q31; /** * @brief Initialization function for the Q31 DCT4/IDCT4. * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure. * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure * @param[in] N length of the DCT4. * @param[in] Nby2 half of the length of the DCT4. * @param[in] normalize normalizing factor. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length. */ arm_status arm_dct4_init_q31( arm_dct4_instance_q31 * S, arm_rfft_instance_q31 * S_RFFT, arm_cfft_radix4_instance_q31 * S_CFFT, uint16_t N, uint16_t Nby2, q31_t normalize); /** * @brief Processing function for the Q31 DCT4/IDCT4. * @param[in] S points to an instance of the Q31 DCT4 structure. * @param[in] pState points to state buffer. * @param[in,out] pInlineBuffer points to the in-place input and output buffer. */ void arm_dct4_q31( const arm_dct4_instance_q31 * S, q31_t * pState, q31_t * pInlineBuffer); /** * @brief Instance structure for the Q15 DCT4/IDCT4 function. */ typedef struct { uint16_t N; /**< length of the DCT4. */ uint16_t Nby2; /**< half of the length of the DCT4. */ q15_t normalize; /**< normalizing factor. */ const q15_t *pTwiddle; /**< points to the twiddle factor table. */ const q15_t *pCosFactor; /**< points to the cosFactor table. */ arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */ arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */ } arm_dct4_instance_q15; /** * @brief Initialization function for the Q15 DCT4/IDCT4. * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure. * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure. * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure. * @param[in] N length of the DCT4. * @param[in] Nby2 half of the length of the DCT4. * @param[in] normalize normalizing factor. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length. */ arm_status arm_dct4_init_q15( arm_dct4_instance_q15 * S, arm_rfft_instance_q15 * S_RFFT, arm_cfft_radix4_instance_q15 * S_CFFT, uint16_t N, uint16_t Nby2, q15_t normalize); /** * @brief Processing function for the Q15 DCT4/IDCT4. * @param[in] S points to an instance of the Q15 DCT4 structure. * @param[in] pState points to state buffer. * @param[in,out] pInlineBuffer points to the in-place input and output buffer. */ void arm_dct4_q15( const arm_dct4_instance_q15 * S, q15_t * pState, q15_t * pInlineBuffer); /** * @brief Floating-point vector addition. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_add_f32( const float32_t * pSrcA, const float32_t * pSrcB, float32_t * pDst, uint32_t blockSize); /** * @brief Q7 vector addition. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_add_q7( const q7_t * pSrcA, const q7_t * pSrcB, q7_t * pDst, uint32_t blockSize); /** * @brief Q15 vector addition. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_add_q15( const q15_t * pSrcA, const q15_t * pSrcB, q15_t * pDst, uint32_t blockSize); /** * @brief Q31 vector addition. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_add_q31( const q31_t * pSrcA, const q31_t * pSrcB, q31_t * pDst, uint32_t blockSize); /** * @brief Floating-point vector subtraction. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_sub_f32( const float32_t * pSrcA, const float32_t * pSrcB, float32_t * pDst, uint32_t blockSize); /** * @brief Q7 vector subtraction. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_sub_q7( const q7_t * pSrcA, const q7_t * pSrcB, q7_t * pDst, uint32_t blockSize); /** * @brief Q15 vector subtraction. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_sub_q15( const q15_t * pSrcA, const q15_t * pSrcB, q15_t * pDst, uint32_t blockSize); /** * @brief Q31 vector subtraction. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in each vector */ void arm_sub_q31( const q31_t * pSrcA, const q31_t * pSrcB, q31_t * pDst, uint32_t blockSize); /** * @brief Multiplies a floating-point vector by a scalar. * @param[in] pSrc points to the input vector * @param[in] scale scale factor to be applied * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_scale_f32( const float32_t * pSrc, float32_t scale, float32_t * pDst, uint32_t blockSize); /** * @brief Multiplies a Q7 vector by a scalar. * @param[in] pSrc points to the input vector * @param[in] scaleFract fractional portion of the scale value * @param[in] shift number of bits to shift the result by * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_scale_q7( const q7_t * pSrc, q7_t scaleFract, int8_t shift, q7_t * pDst, uint32_t blockSize); /** * @brief Multiplies a Q15 vector by a scalar. * @param[in] pSrc points to the input vector * @param[in] scaleFract fractional portion of the scale value * @param[in] shift number of bits to shift the result by * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_scale_q15( const q15_t * pSrc, q15_t scaleFract, int8_t shift, q15_t * pDst, uint32_t blockSize); /** * @brief Multiplies a Q31 vector by a scalar. * @param[in] pSrc points to the input vector * @param[in] scaleFract fractional portion of the scale value * @param[in] shift number of bits to shift the result by * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_scale_q31( const q31_t * pSrc, q31_t scaleFract, int8_t shift, q31_t * pDst, uint32_t blockSize); /** * @brief Q7 vector absolute value. * @param[in] pSrc points to the input buffer * @param[out] pDst points to the output buffer * @param[in] blockSize number of samples in each vector */ void arm_abs_q7( const q7_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Floating-point vector absolute value. * @param[in] pSrc points to the input buffer * @param[out] pDst points to the output buffer * @param[in] blockSize number of samples in each vector */ void arm_abs_f32( const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Q15 vector absolute value. * @param[in] pSrc points to the input buffer * @param[out] pDst points to the output buffer * @param[in] blockSize number of samples in each vector */ void arm_abs_q15( const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Q31 vector absolute value. * @param[in] pSrc points to the input buffer * @param[out] pDst points to the output buffer * @param[in] blockSize number of samples in each vector */ void arm_abs_q31( const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Dot product of floating-point vectors. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] blockSize number of samples in each vector * @param[out] result output result returned here */ void arm_dot_prod_f32( const float32_t * pSrcA, const float32_t * pSrcB, uint32_t blockSize, float32_t * result); /** * @brief Dot product of Q7 vectors. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] blockSize number of samples in each vector * @param[out] result output result returned here */ void arm_dot_prod_q7( const q7_t * pSrcA, const q7_t * pSrcB, uint32_t blockSize, q31_t * result); /** * @brief Dot product of Q15 vectors. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] blockSize number of samples in each vector * @param[out] result output result returned here */ void arm_dot_prod_q15( const q15_t * pSrcA, const q15_t * pSrcB, uint32_t blockSize, q63_t * result); /** * @brief Dot product of Q31 vectors. * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] blockSize number of samples in each vector * @param[out] result output result returned here */ void arm_dot_prod_q31( const q31_t * pSrcA, const q31_t * pSrcB, uint32_t blockSize, q63_t * result); /** * @brief Shifts the elements of a Q7 vector a specified number of bits. * @param[in] pSrc points to the input vector * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_shift_q7( const q7_t * pSrc, int8_t shiftBits, q7_t * pDst, uint32_t blockSize); /** * @brief Shifts the elements of a Q15 vector a specified number of bits. * @param[in] pSrc points to the input vector * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_shift_q15( const q15_t * pSrc, int8_t shiftBits, q15_t * pDst, uint32_t blockSize); /** * @brief Shifts the elements of a Q31 vector a specified number of bits. * @param[in] pSrc points to the input vector * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_shift_q31( const q31_t * pSrc, int8_t shiftBits, q31_t * pDst, uint32_t blockSize); /** * @brief Adds a constant offset to a floating-point vector. * @param[in] pSrc points to the input vector * @param[in] offset is the offset to be added * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_offset_f32( const float32_t * pSrc, float32_t offset, float32_t * pDst, uint32_t blockSize); /** * @brief Adds a constant offset to a Q7 vector. * @param[in] pSrc points to the input vector * @param[in] offset is the offset to be added * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_offset_q7( const q7_t * pSrc, q7_t offset, q7_t * pDst, uint32_t blockSize); /** * @brief Adds a constant offset to a Q15 vector. * @param[in] pSrc points to the input vector * @param[in] offset is the offset to be added * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_offset_q15( const q15_t * pSrc, q15_t offset, q15_t * pDst, uint32_t blockSize); /** * @brief Adds a constant offset to a Q31 vector. * @param[in] pSrc points to the input vector * @param[in] offset is the offset to be added * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_offset_q31( const q31_t * pSrc, q31_t offset, q31_t * pDst, uint32_t blockSize); /** * @brief Negates the elements of a floating-point vector. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_negate_f32( const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Negates the elements of a Q7 vector. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_negate_q7( const q7_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Negates the elements of a Q15 vector. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_negate_q15( const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Negates the elements of a Q31 vector. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] blockSize number of samples in the vector */ void arm_negate_q31( const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Copies the elements of a floating-point vector. * @param[in] pSrc input pointer * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_copy_f32( const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Copies the elements of a Q7 vector. * @param[in] pSrc input pointer * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_copy_q7( const q7_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Copies the elements of a Q15 vector. * @param[in] pSrc input pointer * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_copy_q15( const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Copies the elements of a Q31 vector. * @param[in] pSrc input pointer * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_copy_q31( const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Fills a constant value into a floating-point vector. * @param[in] value input value to be filled * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_fill_f32( float32_t value, float32_t * pDst, uint32_t blockSize); /** * @brief Fills a constant value into a Q7 vector. * @param[in] value input value to be filled * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_fill_q7( q7_t value, q7_t * pDst, uint32_t blockSize); /** * @brief Fills a constant value into a Q15 vector. * @param[in] value input value to be filled * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_fill_q15( q15_t value, q15_t * pDst, uint32_t blockSize); /** * @brief Fills a constant value into a Q31 vector. * @param[in] value input value to be filled * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_fill_q31( q31_t value, q31_t * pDst, uint32_t blockSize); /** * @brief Convolution of floating-point sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. */ void arm_conv_f32( const float32_t * pSrcA, uint32_t srcALen, const float32_t * pSrcB, uint32_t srcBLen, float32_t * pDst); /** * @brief Convolution of Q15 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). */ void arm_conv_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Convolution of Q15 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. */ void arm_conv_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst); /** * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. */ void arm_conv_fast_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst); /** * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). */ void arm_conv_fast_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Convolution of Q31 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. */ void arm_conv_q31( const q31_t * pSrcA, uint32_t srcALen, const q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst); /** * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. */ void arm_conv_fast_q31( const q31_t * pSrcA, uint32_t srcALen, const q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst); /** * @brief Convolution of Q7 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). */ void arm_conv_opt_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Convolution of Q7 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. */ void arm_conv_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst); /** * @brief Partial convolution of floating-point sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_f32( const float32_t * pSrcA, uint32_t srcALen, const float32_t * pSrcB, uint32_t srcBLen, float32_t * pDst, uint32_t firstIndex, uint32_t numPoints); /** * @brief Partial convolution of Q15 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex, uint32_t numPoints, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Partial convolution of Q15 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex, uint32_t numPoints); /** * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_fast_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex, uint32_t numPoints); /** * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_fast_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, uint32_t firstIndex, uint32_t numPoints, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Partial convolution of Q31 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_q31( const q31_t * pSrcA, uint32_t srcALen, const q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst, uint32_t firstIndex, uint32_t numPoints); /** * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_fast_q31( const q31_t * pSrcA, uint32_t srcALen, const q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst, uint32_t firstIndex, uint32_t numPoints); /** * @brief Partial convolution of Q7 sequences * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_opt_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst, uint32_t firstIndex, uint32_t numPoints, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Partial convolution of Q7 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data * @param[in] firstIndex is the first output sample to start with. * @param[in] numPoints is the number of output points to be computed. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. */ arm_status arm_conv_partial_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst, uint32_t firstIndex, uint32_t numPoints); /** * @brief Instance structure for the Q15 FIR decimator. */ typedef struct { uint8_t M; /**< decimation factor. */ uint16_t numTaps; /**< number of coefficients in the filter. */ const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ } arm_fir_decimate_instance_q15; /** * @brief Instance structure for the Q31 FIR decimator. */ typedef struct { uint8_t M; /**< decimation factor. */ uint16_t numTaps; /**< number of coefficients in the filter. */ const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ } arm_fir_decimate_instance_q31; /** @brief Instance structure for floating-point FIR decimator. */ typedef struct { uint8_t M; /**< decimation factor. */ uint16_t numTaps; /**< number of coefficients in the filter. */ const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ } arm_fir_decimate_instance_f32; /** @brief Processing function for floating-point FIR decimator. @param[in] S points to an instance of the floating-point FIR decimator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process */ void arm_fir_decimate_f32( const arm_fir_decimate_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** @brief Initialization function for the floating-point FIR decimator. @param[in,out] S points to an instance of the floating-point FIR decimator structure @param[in] numTaps number of coefficients in the filter @param[in] M decimation factor @param[in] pCoeffs points to the filter coefficients @param[in] pState points to the state buffer @param[in] blockSize number of input samples to process per call @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_LENGTH_ERROR : <code>blockSize</code> is not a multiple of <code>M</code> */ arm_status arm_fir_decimate_init_f32( arm_fir_decimate_instance_f32 * S, uint16_t numTaps, uint8_t M, const float32_t * pCoeffs, float32_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q15 FIR decimator. * @param[in] S points to an instance of the Q15 FIR decimator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of input samples to process per call. */ void arm_fir_decimate_q15( const arm_fir_decimate_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. * @param[in] S points to an instance of the Q15 FIR decimator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of input samples to process per call. */ void arm_fir_decimate_fast_q15( const arm_fir_decimate_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q15 FIR decimator. * @param[in,out] S points to an instance of the Q15 FIR decimator structure. * @param[in] numTaps number of coefficients in the filter. * @param[in] M decimation factor. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] blockSize number of input samples to process per call. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if * <code>blockSize</code> is not a multiple of <code>M</code>. */ arm_status arm_fir_decimate_init_q15( arm_fir_decimate_instance_q15 * S, uint16_t numTaps, uint8_t M, const q15_t * pCoeffs, q15_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q31 FIR decimator. * @param[in] S points to an instance of the Q31 FIR decimator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of input samples to process per call. */ void arm_fir_decimate_q31( const arm_fir_decimate_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. * @param[in] S points to an instance of the Q31 FIR decimator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of input samples to process per call. */ void arm_fir_decimate_fast_q31( const arm_fir_decimate_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q31 FIR decimator. * @param[in,out] S points to an instance of the Q31 FIR decimator structure. * @param[in] numTaps number of coefficients in the filter. * @param[in] M decimation factor. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] blockSize number of input samples to process per call. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if * <code>blockSize</code> is not a multiple of <code>M</code>. */ arm_status arm_fir_decimate_init_q31( arm_fir_decimate_instance_q31 * S, uint16_t numTaps, uint8_t M, const q31_t * pCoeffs, q31_t * pState, uint32_t blockSize); /** * @brief Instance structure for the Q15 FIR interpolator. */ typedef struct { uint8_t L; /**< upsample factor. */ uint16_t phaseLength; /**< length of each polyphase filter component. */ const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ } arm_fir_interpolate_instance_q15; /** * @brief Instance structure for the Q31 FIR interpolator. */ typedef struct { uint8_t L; /**< upsample factor. */ uint16_t phaseLength; /**< length of each polyphase filter component. */ const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ } arm_fir_interpolate_instance_q31; /** * @brief Instance structure for the floating-point FIR interpolator. */ typedef struct { uint8_t L; /**< upsample factor. */ uint16_t phaseLength; /**< length of each polyphase filter component. */ const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */ } arm_fir_interpolate_instance_f32; /** * @brief Processing function for the Q15 FIR interpolator. * @param[in] S points to an instance of the Q15 FIR interpolator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_interpolate_q15( const arm_fir_interpolate_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q15 FIR interpolator. * @param[in,out] S points to an instance of the Q15 FIR interpolator structure. * @param[in] L upsample factor. * @param[in] numTaps number of filter coefficients in the filter. * @param[in] pCoeffs points to the filter coefficient buffer. * @param[in] pState points to the state buffer. * @param[in] blockSize number of input samples to process per call. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. */ arm_status arm_fir_interpolate_init_q15( arm_fir_interpolate_instance_q15 * S, uint8_t L, uint16_t numTaps, const q15_t * pCoeffs, q15_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q31 FIR interpolator. * @param[in] S points to an instance of the Q15 FIR interpolator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_interpolate_q31( const arm_fir_interpolate_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q31 FIR interpolator. * @param[in,out] S points to an instance of the Q31 FIR interpolator structure. * @param[in] L upsample factor. * @param[in] numTaps number of filter coefficients in the filter. * @param[in] pCoeffs points to the filter coefficient buffer. * @param[in] pState points to the state buffer. * @param[in] blockSize number of input samples to process per call. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. */ arm_status arm_fir_interpolate_init_q31( arm_fir_interpolate_instance_q31 * S, uint8_t L, uint16_t numTaps, const q31_t * pCoeffs, q31_t * pState, uint32_t blockSize); /** * @brief Processing function for the floating-point FIR interpolator. * @param[in] S points to an instance of the floating-point FIR interpolator structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_interpolate_f32( const arm_fir_interpolate_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the floating-point FIR interpolator. * @param[in,out] S points to an instance of the floating-point FIR interpolator structure. * @param[in] L upsample factor. * @param[in] numTaps number of filter coefficients in the filter. * @param[in] pCoeffs points to the filter coefficient buffer. * @param[in] pState points to the state buffer. * @param[in] blockSize number of input samples to process per call. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. */ arm_status arm_fir_interpolate_init_f32( arm_fir_interpolate_instance_f32 * S, uint8_t L, uint16_t numTaps, const float32_t * pCoeffs, float32_t * pState, uint32_t blockSize); /** * @brief Instance structure for the high precision Q31 Biquad cascade filter. */ typedef struct { uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ const q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */ } arm_biquad_cas_df1_32x64_ins_q31; /** * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of samples to process. */ void arm_biquad_cas_df1_32x64_q31( const arm_biquad_cas_df1_32x64_ins_q31 * S, q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format */ void arm_biquad_cas_df1_32x64_init_q31( arm_biquad_cas_df1_32x64_ins_q31 * S, uint8_t numStages, const q31_t * pCoeffs, q63_t * pState, uint8_t postShift); /** * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. */ typedef struct { uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ } arm_biquad_cascade_df2T_instance_f32; /** * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. */ typedef struct { uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ } arm_biquad_cascade_stereo_df2T_instance_f32; /** * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. */ typedef struct { uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ } arm_biquad_cascade_df2T_instance_f64; /** * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. * @param[in] S points to an instance of the filter data structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df2T_f32( const arm_biquad_cascade_df2T_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels * @param[in] S points to an instance of the filter data structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_stereo_df2T_f32( const arm_biquad_cascade_stereo_df2T_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. * @param[in] S points to an instance of the filter data structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of samples to process. */ void arm_biquad_cascade_df2T_f64( const arm_biquad_cascade_df2T_instance_f64 * S, float64_t * pSrc, float64_t * pDst, uint32_t blockSize); #if defined(ARM_MATH_NEON) void arm_biquad_cascade_df2T_compute_coefs_f32( arm_biquad_cascade_df2T_instance_f32 * S, uint8_t numStages, float32_t * pCoeffs); #endif /** * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. * @param[in,out] S points to an instance of the filter data structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. */ void arm_biquad_cascade_df2T_init_f32( arm_biquad_cascade_df2T_instance_f32 * S, uint8_t numStages, const float32_t * pCoeffs, float32_t * pState); /** * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. * @param[in,out] S points to an instance of the filter data structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. */ void arm_biquad_cascade_stereo_df2T_init_f32( arm_biquad_cascade_stereo_df2T_instance_f32 * S, uint8_t numStages, const float32_t * pCoeffs, float32_t * pState); /** * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. * @param[in,out] S points to an instance of the filter data structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] pCoeffs points to the filter coefficients. * @param[in] pState points to the state buffer. */ void arm_biquad_cascade_df2T_init_f64( arm_biquad_cascade_df2T_instance_f64 * S, uint8_t numStages, float64_t * pCoeffs, float64_t * pState); /** * @brief Instance structure for the Q15 FIR lattice filter. */ typedef struct { uint16_t numStages; /**< number of filter stages. */ q15_t *pState; /**< points to the state variable array. The array is of length numStages. */ const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ } arm_fir_lattice_instance_q15; /** * @brief Instance structure for the Q31 FIR lattice filter. */ typedef struct { uint16_t numStages; /**< number of filter stages. */ q31_t *pState; /**< points to the state variable array. The array is of length numStages. */ const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ } arm_fir_lattice_instance_q31; /** * @brief Instance structure for the floating-point FIR lattice filter. */ typedef struct { uint16_t numStages; /**< number of filter stages. */ float32_t *pState; /**< points to the state variable array. The array is of length numStages. */ const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ } arm_fir_lattice_instance_f32; /** * @brief Initialization function for the Q15 FIR lattice filter. * @param[in] S points to an instance of the Q15 FIR lattice structure. * @param[in] numStages number of filter stages. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. * @param[in] pState points to the state buffer. The array is of length numStages. */ void arm_fir_lattice_init_q15( arm_fir_lattice_instance_q15 * S, uint16_t numStages, const q15_t * pCoeffs, q15_t * pState); /** * @brief Processing function for the Q15 FIR lattice filter. * @param[in] S points to an instance of the Q15 FIR lattice structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_fir_lattice_q15( const arm_fir_lattice_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q31 FIR lattice filter. * @param[in] S points to an instance of the Q31 FIR lattice structure. * @param[in] numStages number of filter stages. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. * @param[in] pState points to the state buffer. The array is of length numStages. */ void arm_fir_lattice_init_q31( arm_fir_lattice_instance_q31 * S, uint16_t numStages, const q31_t * pCoeffs, q31_t * pState); /** * @brief Processing function for the Q31 FIR lattice filter. * @param[in] S points to an instance of the Q31 FIR lattice structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of samples to process. */ void arm_fir_lattice_q31( const arm_fir_lattice_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the floating-point FIR lattice filter. * @param[in] S points to an instance of the floating-point FIR lattice structure. * @param[in] numStages number of filter stages. * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. * @param[in] pState points to the state buffer. The array is of length numStages. */ void arm_fir_lattice_init_f32( arm_fir_lattice_instance_f32 * S, uint16_t numStages, const float32_t * pCoeffs, float32_t * pState); /** * @brief Processing function for the floating-point FIR lattice filter. * @param[in] S points to an instance of the floating-point FIR lattice structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] blockSize number of samples to process. */ void arm_fir_lattice_f32( const arm_fir_lattice_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Instance structure for the Q15 IIR lattice filter. */ typedef struct { uint16_t numStages; /**< number of stages in the filter. */ q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ } arm_iir_lattice_instance_q15; /** * @brief Instance structure for the Q31 IIR lattice filter. */ typedef struct { uint16_t numStages; /**< number of stages in the filter. */ q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ } arm_iir_lattice_instance_q31; /** * @brief Instance structure for the floating-point IIR lattice filter. */ typedef struct { uint16_t numStages; /**< number of stages in the filter. */ float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ } arm_iir_lattice_instance_f32; /** * @brief Processing function for the floating-point IIR lattice filter. * @param[in] S points to an instance of the floating-point IIR lattice structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_iir_lattice_f32( const arm_iir_lattice_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the floating-point IIR lattice filter. * @param[in] S points to an instance of the floating-point IIR lattice structure. * @param[in] numStages number of stages in the filter. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1. * @param[in] blockSize number of samples to process. */ void arm_iir_lattice_init_f32( arm_iir_lattice_instance_f32 * S, uint16_t numStages, float32_t * pkCoeffs, float32_t * pvCoeffs, float32_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q31 IIR lattice filter. * @param[in] S points to an instance of the Q31 IIR lattice structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_iir_lattice_q31( const arm_iir_lattice_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q31 IIR lattice filter. * @param[in] S points to an instance of the Q31 IIR lattice structure. * @param[in] numStages number of stages in the filter. * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. * @param[in] pState points to the state buffer. The array is of length numStages+blockSize. * @param[in] blockSize number of samples to process. */ void arm_iir_lattice_init_q31( arm_iir_lattice_instance_q31 * S, uint16_t numStages, q31_t * pkCoeffs, q31_t * pvCoeffs, q31_t * pState, uint32_t blockSize); /** * @brief Processing function for the Q15 IIR lattice filter. * @param[in] S points to an instance of the Q15 IIR lattice structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data. * @param[in] blockSize number of samples to process. */ void arm_iir_lattice_q15( const arm_iir_lattice_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Initialization function for the Q15 IIR lattice filter. * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure. * @param[in] numStages number of stages in the filter. * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages. * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. * @param[in] pState points to state buffer. The array is of length numStages+blockSize. * @param[in] blockSize number of samples to process per call. */ void arm_iir_lattice_init_q15( arm_iir_lattice_instance_q15 * S, uint16_t numStages, q15_t * pkCoeffs, q15_t * pvCoeffs, q15_t * pState, uint32_t blockSize); /** * @brief Instance structure for the floating-point LMS filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ float32_t mu; /**< step size that controls filter coefficient updates. */ } arm_lms_instance_f32; /** * @brief Processing function for floating-point LMS filter. * @param[in] S points to an instance of the floating-point LMS filter structure. * @param[in] pSrc points to the block of input data. * @param[in] pRef points to the block of reference data. * @param[out] pOut points to the block of output data. * @param[out] pErr points to the block of error data. * @param[in] blockSize number of samples to process. */ void arm_lms_f32( const arm_lms_instance_f32 * S, const float32_t * pSrc, float32_t * pRef, float32_t * pOut, float32_t * pErr, uint32_t blockSize); /** * @brief Initialization function for floating-point LMS filter. * @param[in] S points to an instance of the floating-point LMS filter structure. * @param[in] numTaps number of filter coefficients. * @param[in] pCoeffs points to the coefficient buffer. * @param[in] pState points to state buffer. * @param[in] mu step size that controls filter coefficient updates. * @param[in] blockSize number of samples to process. */ void arm_lms_init_f32( arm_lms_instance_f32 * S, uint16_t numTaps, float32_t * pCoeffs, float32_t * pState, float32_t mu, uint32_t blockSize); /** * @brief Instance structure for the Q15 LMS filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ q15_t mu; /**< step size that controls filter coefficient updates. */ uint32_t postShift; /**< bit shift applied to coefficients. */ } arm_lms_instance_q15; /** * @brief Initialization function for the Q15 LMS filter. * @param[in] S points to an instance of the Q15 LMS filter structure. * @param[in] numTaps number of filter coefficients. * @param[in] pCoeffs points to the coefficient buffer. * @param[in] pState points to the state buffer. * @param[in] mu step size that controls filter coefficient updates. * @param[in] blockSize number of samples to process. * @param[in] postShift bit shift applied to coefficients. */ void arm_lms_init_q15( arm_lms_instance_q15 * S, uint16_t numTaps, q15_t * pCoeffs, q15_t * pState, q15_t mu, uint32_t blockSize, uint32_t postShift); /** * @brief Processing function for Q15 LMS filter. * @param[in] S points to an instance of the Q15 LMS filter structure. * @param[in] pSrc points to the block of input data. * @param[in] pRef points to the block of reference data. * @param[out] pOut points to the block of output data. * @param[out] pErr points to the block of error data. * @param[in] blockSize number of samples to process. */ void arm_lms_q15( const arm_lms_instance_q15 * S, const q15_t * pSrc, q15_t * pRef, q15_t * pOut, q15_t * pErr, uint32_t blockSize); /** * @brief Instance structure for the Q31 LMS filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ q31_t mu; /**< step size that controls filter coefficient updates. */ uint32_t postShift; /**< bit shift applied to coefficients. */ } arm_lms_instance_q31; /** * @brief Processing function for Q31 LMS filter. * @param[in] S points to an instance of the Q15 LMS filter structure. * @param[in] pSrc points to the block of input data. * @param[in] pRef points to the block of reference data. * @param[out] pOut points to the block of output data. * @param[out] pErr points to the block of error data. * @param[in] blockSize number of samples to process. */ void arm_lms_q31( const arm_lms_instance_q31 * S, const q31_t * pSrc, q31_t * pRef, q31_t * pOut, q31_t * pErr, uint32_t blockSize); /** * @brief Initialization function for Q31 LMS filter. * @param[in] S points to an instance of the Q31 LMS filter structure. * @param[in] numTaps number of filter coefficients. * @param[in] pCoeffs points to coefficient buffer. * @param[in] pState points to state buffer. * @param[in] mu step size that controls filter coefficient updates. * @param[in] blockSize number of samples to process. * @param[in] postShift bit shift applied to coefficients. */ void arm_lms_init_q31( arm_lms_instance_q31 * S, uint16_t numTaps, q31_t * pCoeffs, q31_t * pState, q31_t mu, uint32_t blockSize, uint32_t postShift); /** * @brief Instance structure for the floating-point normalized LMS filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ float32_t mu; /**< step size that control filter coefficient updates. */ float32_t energy; /**< saves previous frame energy. */ float32_t x0; /**< saves previous input sample. */ } arm_lms_norm_instance_f32; /** * @brief Processing function for floating-point normalized LMS filter. * @param[in] S points to an instance of the floating-point normalized LMS filter structure. * @param[in] pSrc points to the block of input data. * @param[in] pRef points to the block of reference data. * @param[out] pOut points to the block of output data. * @param[out] pErr points to the block of error data. * @param[in] blockSize number of samples to process. */ void arm_lms_norm_f32( arm_lms_norm_instance_f32 * S, const float32_t * pSrc, float32_t * pRef, float32_t * pOut, float32_t * pErr, uint32_t blockSize); /** * @brief Initialization function for floating-point normalized LMS filter. * @param[in] S points to an instance of the floating-point LMS filter structure. * @param[in] numTaps number of filter coefficients. * @param[in] pCoeffs points to coefficient buffer. * @param[in] pState points to state buffer. * @param[in] mu step size that controls filter coefficient updates. * @param[in] blockSize number of samples to process. */ void arm_lms_norm_init_f32( arm_lms_norm_instance_f32 * S, uint16_t numTaps, float32_t * pCoeffs, float32_t * pState, float32_t mu, uint32_t blockSize); /** * @brief Instance structure for the Q31 normalized LMS filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ q31_t mu; /**< step size that controls filter coefficient updates. */ uint8_t postShift; /**< bit shift applied to coefficients. */ const q31_t *recipTable; /**< points to the reciprocal initial value table. */ q31_t energy; /**< saves previous frame energy. */ q31_t x0; /**< saves previous input sample. */ } arm_lms_norm_instance_q31; /** * @brief Processing function for Q31 normalized LMS filter. * @param[in] S points to an instance of the Q31 normalized LMS filter structure. * @param[in] pSrc points to the block of input data. * @param[in] pRef points to the block of reference data. * @param[out] pOut points to the block of output data. * @param[out] pErr points to the block of error data. * @param[in] blockSize number of samples to process. */ void arm_lms_norm_q31( arm_lms_norm_instance_q31 * S, const q31_t * pSrc, q31_t * pRef, q31_t * pOut, q31_t * pErr, uint32_t blockSize); /** * @brief Initialization function for Q31 normalized LMS filter. * @param[in] S points to an instance of the Q31 normalized LMS filter structure. * @param[in] numTaps number of filter coefficients. * @param[in] pCoeffs points to coefficient buffer. * @param[in] pState points to state buffer. * @param[in] mu step size that controls filter coefficient updates. * @param[in] blockSize number of samples to process. * @param[in] postShift bit shift applied to coefficients. */ void arm_lms_norm_init_q31( arm_lms_norm_instance_q31 * S, uint16_t numTaps, q31_t * pCoeffs, q31_t * pState, q31_t mu, uint32_t blockSize, uint8_t postShift); /** * @brief Instance structure for the Q15 normalized LMS filter. */ typedef struct { uint16_t numTaps; /**< Number of coefficients in the filter. */ q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ q15_t mu; /**< step size that controls filter coefficient updates. */ uint8_t postShift; /**< bit shift applied to coefficients. */ const q15_t *recipTable; /**< Points to the reciprocal initial value table. */ q15_t energy; /**< saves previous frame energy. */ q15_t x0; /**< saves previous input sample. */ } arm_lms_norm_instance_q15; /** * @brief Processing function for Q15 normalized LMS filter. * @param[in] S points to an instance of the Q15 normalized LMS filter structure. * @param[in] pSrc points to the block of input data. * @param[in] pRef points to the block of reference data. * @param[out] pOut points to the block of output data. * @param[out] pErr points to the block of error data. * @param[in] blockSize number of samples to process. */ void arm_lms_norm_q15( arm_lms_norm_instance_q15 * S, const q15_t * pSrc, q15_t * pRef, q15_t * pOut, q15_t * pErr, uint32_t blockSize); /** * @brief Initialization function for Q15 normalized LMS filter. * @param[in] S points to an instance of the Q15 normalized LMS filter structure. * @param[in] numTaps number of filter coefficients. * @param[in] pCoeffs points to coefficient buffer. * @param[in] pState points to state buffer. * @param[in] mu step size that controls filter coefficient updates. * @param[in] blockSize number of samples to process. * @param[in] postShift bit shift applied to coefficients. */ void arm_lms_norm_init_q15( arm_lms_norm_instance_q15 * S, uint16_t numTaps, q15_t * pCoeffs, q15_t * pState, q15_t mu, uint32_t blockSize, uint8_t postShift); /** * @brief Correlation of floating-point sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. */ void arm_correlate_f32( const float32_t * pSrcA, uint32_t srcALen, const float32_t * pSrcB, uint32_t srcBLen, float32_t * pDst); /** @brief Correlation of Q15 sequences @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. */ void arm_correlate_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, q15_t * pScratch); /** @brief Correlation of Q15 sequences. @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. */ void arm_correlate_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst); /** @brief Correlation of Q15 sequences (fast version). @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1. @return none */ void arm_correlate_fast_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst); /** @brief Correlation of Q15 sequences (fast version). @param[in] pSrcA points to the first input sequence. @param[in] srcALen length of the first input sequence. @param[in] pSrcB points to the second input sequence. @param[in] srcBLen length of the second input sequence. @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. */ void arm_correlate_fast_opt_q15( const q15_t * pSrcA, uint32_t srcALen, const q15_t * pSrcB, uint32_t srcBLen, q15_t * pDst, q15_t * pScratch); /** * @brief Correlation of Q31 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. */ void arm_correlate_q31( const q31_t * pSrcA, uint32_t srcALen, const q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst); /** @brief Correlation of Q31 sequences (fast version). @param[in] pSrcA points to the first input sequence @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. */ void arm_correlate_fast_q31( const q31_t * pSrcA, uint32_t srcALen, const q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst); /** * @brief Correlation of Q7 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). */ void arm_correlate_opt_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst, q15_t * pScratch1, q15_t * pScratch2); /** * @brief Correlation of Q7 sequences. * @param[in] pSrcA points to the first input sequence. * @param[in] srcALen length of the first input sequence. * @param[in] pSrcB points to the second input sequence. * @param[in] srcBLen length of the second input sequence. * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. */ void arm_correlate_q7( const q7_t * pSrcA, uint32_t srcALen, const q7_t * pSrcB, uint32_t srcBLen, q7_t * pDst); /** * @brief Instance structure for the floating-point sparse FIR filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ } arm_fir_sparse_instance_f32; /** * @brief Instance structure for the Q31 sparse FIR filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ } arm_fir_sparse_instance_q31; /** * @brief Instance structure for the Q15 sparse FIR filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ } arm_fir_sparse_instance_q15; /** * @brief Instance structure for the Q7 sparse FIR filter. */ typedef struct { uint16_t numTaps; /**< number of coefficients in the filter. */ uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ } arm_fir_sparse_instance_q7; /** * @brief Processing function for the floating-point sparse FIR filter. * @param[in] S points to an instance of the floating-point sparse FIR structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] pScratchIn points to a temporary buffer of size blockSize. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_sparse_f32( arm_fir_sparse_instance_f32 * S, const float32_t * pSrc, float32_t * pDst, float32_t * pScratchIn, uint32_t blockSize); /** * @brief Initialization function for the floating-point sparse FIR filter. * @param[in,out] S points to an instance of the floating-point sparse FIR structure. * @param[in] numTaps number of nonzero coefficients in the filter. * @param[in] pCoeffs points to the array of filter coefficients. * @param[in] pState points to the state buffer. * @param[in] pTapDelay points to the array of offset times. * @param[in] maxDelay maximum offset time supported. * @param[in] blockSize number of samples that will be processed per block. */ void arm_fir_sparse_init_f32( arm_fir_sparse_instance_f32 * S, uint16_t numTaps, const float32_t * pCoeffs, float32_t * pState, int32_t * pTapDelay, uint16_t maxDelay, uint32_t blockSize); /** * @brief Processing function for the Q31 sparse FIR filter. * @param[in] S points to an instance of the Q31 sparse FIR structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] pScratchIn points to a temporary buffer of size blockSize. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_sparse_q31( arm_fir_sparse_instance_q31 * S, const q31_t * pSrc, q31_t * pDst, q31_t * pScratchIn, uint32_t blockSize); /** * @brief Initialization function for the Q31 sparse FIR filter. * @param[in,out] S points to an instance of the Q31 sparse FIR structure. * @param[in] numTaps number of nonzero coefficients in the filter. * @param[in] pCoeffs points to the array of filter coefficients. * @param[in] pState points to the state buffer. * @param[in] pTapDelay points to the array of offset times. * @param[in] maxDelay maximum offset time supported. * @param[in] blockSize number of samples that will be processed per block. */ void arm_fir_sparse_init_q31( arm_fir_sparse_instance_q31 * S, uint16_t numTaps, const q31_t * pCoeffs, q31_t * pState, int32_t * pTapDelay, uint16_t maxDelay, uint32_t blockSize); /** * @brief Processing function for the Q15 sparse FIR filter. * @param[in] S points to an instance of the Q15 sparse FIR structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] pScratchIn points to a temporary buffer of size blockSize. * @param[in] pScratchOut points to a temporary buffer of size blockSize. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_sparse_q15( arm_fir_sparse_instance_q15 * S, const q15_t * pSrc, q15_t * pDst, q15_t * pScratchIn, q31_t * pScratchOut, uint32_t blockSize); /** * @brief Initialization function for the Q15 sparse FIR filter. * @param[in,out] S points to an instance of the Q15 sparse FIR structure. * @param[in] numTaps number of nonzero coefficients in the filter. * @param[in] pCoeffs points to the array of filter coefficients. * @param[in] pState points to the state buffer. * @param[in] pTapDelay points to the array of offset times. * @param[in] maxDelay maximum offset time supported. * @param[in] blockSize number of samples that will be processed per block. */ void arm_fir_sparse_init_q15( arm_fir_sparse_instance_q15 * S, uint16_t numTaps, const q15_t * pCoeffs, q15_t * pState, int32_t * pTapDelay, uint16_t maxDelay, uint32_t blockSize); /** * @brief Processing function for the Q7 sparse FIR filter. * @param[in] S points to an instance of the Q7 sparse FIR structure. * @param[in] pSrc points to the block of input data. * @param[out] pDst points to the block of output data * @param[in] pScratchIn points to a temporary buffer of size blockSize. * @param[in] pScratchOut points to a temporary buffer of size blockSize. * @param[in] blockSize number of input samples to process per call. */ void arm_fir_sparse_q7( arm_fir_sparse_instance_q7 * S, const q7_t * pSrc, q7_t * pDst, q7_t * pScratchIn, q31_t * pScratchOut, uint32_t blockSize); /** * @brief Initialization function for the Q7 sparse FIR filter. * @param[in,out] S points to an instance of the Q7 sparse FIR structure. * @param[in] numTaps number of nonzero coefficients in the filter. * @param[in] pCoeffs points to the array of filter coefficients. * @param[in] pState points to the state buffer. * @param[in] pTapDelay points to the array of offset times. * @param[in] maxDelay maximum offset time supported. * @param[in] blockSize number of samples that will be processed per block. */ void arm_fir_sparse_init_q7( arm_fir_sparse_instance_q7 * S, uint16_t numTaps, const q7_t * pCoeffs, q7_t * pState, int32_t * pTapDelay, uint16_t maxDelay, uint32_t blockSize); /** * @brief Floating-point sin_cos function. * @param[in] theta input value in degrees * @param[out] pSinVal points to the processed sine output. * @param[out] pCosVal points to the processed cos output. */ void arm_sin_cos_f32( float32_t theta, float32_t * pSinVal, float32_t * pCosVal); /** * @brief Q31 sin_cos function. * @param[in] theta scaled input value in degrees * @param[out] pSinVal points to the processed sine output. * @param[out] pCosVal points to the processed cosine output. */ void arm_sin_cos_q31( q31_t theta, q31_t * pSinVal, q31_t * pCosVal); /** * @brief Floating-point complex conjugate. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] numSamples number of complex samples in each vector */ void arm_cmplx_conj_f32( const float32_t * pSrc, float32_t * pDst, uint32_t numSamples); /** * @brief Q31 complex conjugate. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] numSamples number of complex samples in each vector */ void arm_cmplx_conj_q31( const q31_t * pSrc, q31_t * pDst, uint32_t numSamples); /** * @brief Q15 complex conjugate. * @param[in] pSrc points to the input vector * @param[out] pDst points to the output vector * @param[in] numSamples number of complex samples in each vector */ void arm_cmplx_conj_q15( const q15_t * pSrc, q15_t * pDst, uint32_t numSamples); /** * @brief Floating-point complex magnitude squared * @param[in] pSrc points to the complex input vector * @param[out] pDst points to the real output vector * @param[in] numSamples number of complex samples in the input vector */ void arm_cmplx_mag_squared_f32( const float32_t * pSrc, float32_t * pDst, uint32_t numSamples); /** * @brief Q31 complex magnitude squared * @param[in] pSrc points to the complex input vector * @param[out] pDst points to the real output vector * @param[in] numSamples number of complex samples in the input vector */ void arm_cmplx_mag_squared_q31( const q31_t * pSrc, q31_t * pDst, uint32_t numSamples); /** * @brief Q15 complex magnitude squared * @param[in] pSrc points to the complex input vector * @param[out] pDst points to the real output vector * @param[in] numSamples number of complex samples in the input vector */ void arm_cmplx_mag_squared_q15( const q15_t * pSrc, q15_t * pDst, uint32_t numSamples); /** * @ingroup groupController */ /** * @defgroup PID PID Motor Control * * A Proportional Integral Derivative (PID) controller is a generic feedback control * loop mechanism widely used in industrial control systems. * A PID controller is the most commonly used type of feedback controller. * * This set of functions implements (PID) controllers * for Q15, Q31, and floating-point data types. The functions operate on a single sample * of data and each call to the function returns a single processed value. * <code>S</code> points to an instance of the PID control data structure. <code>in</code> * is the input sample value. The functions return the output value. * * \par Algorithm: * <pre> * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] * A0 = Kp + Ki + Kd * A1 = (-Kp ) - (2 * Kd ) * A2 = Kd * </pre> * * \par * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant * * \par * \image html PID.gif "Proportional Integral Derivative Controller" * * \par * The PID controller calculates an "error" value as the difference between * the measured output and the reference input. * The controller attempts to minimize the error by adjusting the process control inputs. * The proportional value determines the reaction to the current error, * the integral value determines the reaction based on the sum of recent errors, * and the derivative value determines the reaction based on the rate at which the error has been changing. * * \par Instance Structure * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure. * A separate instance structure must be defined for each PID Controller. * There are separate instance structure declarations for each of the 3 supported data types. * * \par Reset Functions * There is also an associated reset function for each data type which clears the state array. * * \par Initialization Functions * There is also an associated initialization function for each data type. * The initialization function performs the following operations: * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains. * - Zeros out the values in the state buffer. * * \par * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function. * * \par Fixed-Point Behavior * Care must be taken when using the fixed-point versions of the PID Controller functions. * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. * Refer to the function specific documentation below for usage guidelines. */ /** * @addtogroup PID * @{ */ /** * @brief Process function for the floating-point PID Control. * @param[in,out] S is an instance of the floating-point PID Control structure * @param[in] in input sample to process * @return processed output sample. */ __STATIC_FORCEINLINE float32_t arm_pid_f32( arm_pid_instance_f32 * S, float32_t in) { float32_t out; /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */ out = (S->A0 * in) + (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]); /* Update state */ S->state[1] = S->state[0]; S->state[0] = in; S->state[2] = out; /* return to application */ return (out); } /** @brief Process function for the Q31 PID Control. @param[in,out] S points to an instance of the Q31 PID Control structure @param[in] in input sample to process @return processed output sample. \par Scaling and Overflow Behavior The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions. After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. */ __STATIC_FORCEINLINE q31_t arm_pid_q31( arm_pid_instance_q31 * S, q31_t in) { q63_t acc; q31_t out; /* acc = A0 * x[n] */ acc = (q63_t) S->A0 * in; /* acc += A1 * x[n-1] */ acc += (q63_t) S->A1 * S->state[0]; /* acc += A2 * x[n-2] */ acc += (q63_t) S->A2 * S->state[1]; /* convert output to 1.31 format to add y[n-1] */ out = (q31_t) (acc >> 31U); /* out += y[n-1] */ out += S->state[2]; /* Update state */ S->state[1] = S->state[0]; S->state[0] = in; S->state[2] = out; /* return to application */ return (out); } /** @brief Process function for the Q15 PID Control. @param[in,out] S points to an instance of the Q15 PID Control structure @param[in] in input sample to process @return processed output sample. \par Scaling and Overflow Behavior The function is implemented using a 64-bit internal accumulator. Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. */ __STATIC_FORCEINLINE q15_t arm_pid_q15( arm_pid_instance_q15 * S, q15_t in) { q63_t acc; q15_t out; #if defined (ARM_MATH_DSP) /* Implementation of PID controller */ /* acc = A0 * x[n] */ acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in); /* acc += A1 * x[n-1] + A2 * x[n-2] */ acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)read_q15x2 (S->state), (uint64_t)acc); #else /* acc = A0 * x[n] */ acc = ((q31_t) S->A0) * in; /* acc += A1 * x[n-1] + A2 * x[n-2] */ acc += (q31_t) S->A1 * S->state[0]; acc += (q31_t) S->A2 * S->state[1]; #endif /* acc += y[n-1] */ acc += (q31_t) S->state[2] << 15; /* saturate the output */ out = (q15_t) (__SSAT((acc >> 15), 16)); /* Update state */ S->state[1] = S->state[0]; S->state[0] = in; S->state[2] = out; /* return to application */ return (out); } /** * @} end of PID group */ /** * @brief Floating-point matrix inverse. * @param[in] src points to the instance of the input floating-point matrix structure. * @param[out] dst points to the instance of the output floating-point matrix structure. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR. */ arm_status arm_mat_inverse_f32( const arm_matrix_instance_f32 * src, arm_matrix_instance_f32 * dst); /** * @brief Floating-point matrix inverse. * @param[in] src points to the instance of the input floating-point matrix structure. * @param[out] dst points to the instance of the output floating-point matrix structure. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR. */ arm_status arm_mat_inverse_f64( const arm_matrix_instance_f64 * src, arm_matrix_instance_f64 * dst); /** * @ingroup groupController */ /** * @defgroup clarke Vector Clarke Transform * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector. * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>. * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below * \image html clarke.gif Stator current space vector and its components in (a,b). * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code> * can be calculated using only <code>Ia</code> and <code>Ib</code>. * * The function operates on a single sample of data and each call to the function returns the processed output. * The library provides separate functions for Q31 and floating-point data types. * \par Algorithm * \image html clarkeFormula.gif * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector. * \par Fixed-Point Behavior * Care must be taken when using the Q31 version of the Clarke transform. * In particular, the overflow and saturation behavior of the accumulator used must be considered. * Refer to the function specific documentation below for usage guidelines. */ /** * @addtogroup clarke * @{ */ /** * * @brief Floating-point Clarke transform * @param[in] Ia input three-phase coordinate <code>a</code> * @param[in] Ib input three-phase coordinate <code>b</code> * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha * @param[out] pIbeta points to output two-phase orthogonal vector axis beta * @return none */ __STATIC_FORCEINLINE void arm_clarke_f32( float32_t Ia, float32_t Ib, float32_t * pIalpha, float32_t * pIbeta) { /* Calculate pIalpha using the equation, pIalpha = Ia */ *pIalpha = Ia; /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */ *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib); } /** @brief Clarke transform for Q31 version @param[in] Ia input three-phase coordinate <code>a</code> @param[in] Ib input three-phase coordinate <code>b</code> @param[out] pIalpha points to output two-phase orthogonal vector axis alpha @param[out] pIbeta points to output two-phase orthogonal vector axis beta @return none \par Scaling and Overflow Behavior The function is implemented using an internal 32-bit accumulator. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. There is saturation on the addition, hence there is no risk of overflow. */ __STATIC_FORCEINLINE void arm_clarke_q31( q31_t Ia, q31_t Ib, q31_t * pIalpha, q31_t * pIbeta) { q31_t product1, product2; /* Temporary variables used to store intermediate results */ /* Calculating pIalpha from Ia by equation pIalpha = Ia */ *pIalpha = Ia; /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */ product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30); /* Intermediate product is calculated by (2/sqrt(3) * Ib) */ product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30); /* pIbeta is calculated by adding the intermediate products */ *pIbeta = __QADD(product1, product2); } /** * @} end of clarke group */ /** * @ingroup groupController */ /** * @defgroup inv_clarke Vector Inverse Clarke Transform * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases. * * The function operates on a single sample of data and each call to the function returns the processed output. * The library provides separate functions for Q31 and floating-point data types. * \par Algorithm * \image html clarkeInvFormula.gif * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector. * \par Fixed-Point Behavior * Care must be taken when using the Q31 version of the Clarke transform. * In particular, the overflow and saturation behavior of the accumulator used must be considered. * Refer to the function specific documentation below for usage guidelines. */ /** * @addtogroup inv_clarke * @{ */ /** * @brief Floating-point Inverse Clarke transform * @param[in] Ialpha input two-phase orthogonal vector axis alpha * @param[in] Ibeta input two-phase orthogonal vector axis beta * @param[out] pIa points to output three-phase coordinate <code>a</code> * @param[out] pIb points to output three-phase coordinate <code>b</code> * @return none */ __STATIC_FORCEINLINE void arm_inv_clarke_f32( float32_t Ialpha, float32_t Ibeta, float32_t * pIa, float32_t * pIb) { /* Calculating pIa from Ialpha by equation pIa = Ialpha */ *pIa = Ialpha; /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */ *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta; } /** @brief Inverse Clarke transform for Q31 version @param[in] Ialpha input two-phase orthogonal vector axis alpha @param[in] Ibeta input two-phase orthogonal vector axis beta @param[out] pIa points to output three-phase coordinate <code>a</code> @param[out] pIb points to output three-phase coordinate <code>b</code> @return none \par Scaling and Overflow Behavior The function is implemented using an internal 32-bit accumulator. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. There is saturation on the subtraction, hence there is no risk of overflow. */ __STATIC_FORCEINLINE void arm_inv_clarke_q31( q31_t Ialpha, q31_t Ibeta, q31_t * pIa, q31_t * pIb) { q31_t product1, product2; /* Temporary variables used to store intermediate results */ /* Calculating pIa from Ialpha by equation pIa = Ialpha */ *pIa = Ialpha; /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */ product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31); /* Intermediate product is calculated by (1/sqrt(3) * pIb) */ product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31); /* pIb is calculated by subtracting the products */ *pIb = __QSUB(product2, product1); } /** * @} end of inv_clarke group */ /** * @ingroup groupController */ /** * @defgroup park Vector Park Transform * * Forward Park transform converts the input two-coordinate vector to flux and torque components. * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents * from the stationary to the moving reference frame and control the spatial relationship between * the stator vector current and rotor flux vector. * If we consider the d axis aligned with the rotor flux, the diagram below shows the * current vector and the relationship from the two reference frames: * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame" * * The function operates on a single sample of data and each call to the function returns the processed output. * The library provides separate functions for Q31 and floating-point data types. * \par Algorithm * \image html parkFormula.gif * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components, * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the * cosine and sine values of theta (rotor flux position). * \par Fixed-Point Behavior * Care must be taken when using the Q31 version of the Park transform. * In particular, the overflow and saturation behavior of the accumulator used must be considered. * Refer to the function specific documentation below for usage guidelines. */ /** * @addtogroup park * @{ */ /** * @brief Floating-point Park transform * @param[in] Ialpha input two-phase vector coordinate alpha * @param[in] Ibeta input two-phase vector coordinate beta * @param[out] pId points to output rotor reference frame d * @param[out] pIq points to output rotor reference frame q * @param[in] sinVal sine value of rotation angle theta * @param[in] cosVal cosine value of rotation angle theta * @return none * * The function implements the forward Park transform. * */ __STATIC_FORCEINLINE void arm_park_f32( float32_t Ialpha, float32_t Ibeta, float32_t * pId, float32_t * pIq, float32_t sinVal, float32_t cosVal) { /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */ *pId = Ialpha * cosVal + Ibeta * sinVal; /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */ *pIq = -Ialpha * sinVal + Ibeta * cosVal; } /** @brief Park transform for Q31 version @param[in] Ialpha input two-phase vector coordinate alpha @param[in] Ibeta input two-phase vector coordinate beta @param[out] pId points to output rotor reference frame d @param[out] pIq points to output rotor reference frame q @param[in] sinVal sine value of rotation angle theta @param[in] cosVal cosine value of rotation angle theta @return none \par Scaling and Overflow Behavior The function is implemented using an internal 32-bit accumulator. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. There is saturation on the addition and subtraction, hence there is no risk of overflow. */ __STATIC_FORCEINLINE void arm_park_q31( q31_t Ialpha, q31_t Ibeta, q31_t * pId, q31_t * pIq, q31_t sinVal, q31_t cosVal) { q31_t product1, product2; /* Temporary variables used to store intermediate results */ q31_t product3, product4; /* Temporary variables used to store intermediate results */ /* Intermediate product is calculated by (Ialpha * cosVal) */ product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31); /* Intermediate product is calculated by (Ibeta * sinVal) */ product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31); /* Intermediate product is calculated by (Ialpha * sinVal) */ product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31); /* Intermediate product is calculated by (Ibeta * cosVal) */ product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31); /* Calculate pId by adding the two intermediate products 1 and 2 */ *pId = __QADD(product1, product2); /* Calculate pIq by subtracting the two intermediate products 3 from 4 */ *pIq = __QSUB(product4, product3); } /** * @} end of park group */ /** * @ingroup groupController */ /** * @defgroup inv_park Vector Inverse Park transform * Inverse Park transform converts the input flux and torque components to two-coordinate vector. * * The function operates on a single sample of data and each call to the function returns the processed output. * The library provides separate functions for Q31 and floating-point data types. * \par Algorithm * \image html parkInvFormula.gif * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components, * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the * cosine and sine values of theta (rotor flux position). * \par Fixed-Point Behavior * Care must be taken when using the Q31 version of the Park transform. * In particular, the overflow and saturation behavior of the accumulator used must be considered. * Refer to the function specific documentation below for usage guidelines. */ /** * @addtogroup inv_park * @{ */ /** * @brief Floating-point Inverse Park transform * @param[in] Id input coordinate of rotor reference frame d * @param[in] Iq input coordinate of rotor reference frame q * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha * @param[out] pIbeta points to output two-phase orthogonal vector axis beta * @param[in] sinVal sine value of rotation angle theta * @param[in] cosVal cosine value of rotation angle theta * @return none */ __STATIC_FORCEINLINE void arm_inv_park_f32( float32_t Id, float32_t Iq, float32_t * pIalpha, float32_t * pIbeta, float32_t sinVal, float32_t cosVal) { /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */ *pIalpha = Id * cosVal - Iq * sinVal; /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */ *pIbeta = Id * sinVal + Iq * cosVal; } /** @brief Inverse Park transform for Q31 version @param[in] Id input coordinate of rotor reference frame d @param[in] Iq input coordinate of rotor reference frame q @param[out] pIalpha points to output two-phase orthogonal vector axis alpha @param[out] pIbeta points to output two-phase orthogonal vector axis beta @param[in] sinVal sine value of rotation angle theta @param[in] cosVal cosine value of rotation angle theta @return none @par Scaling and Overflow Behavior The function is implemented using an internal 32-bit accumulator. The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. There is saturation on the addition, hence there is no risk of overflow. */ __STATIC_FORCEINLINE void arm_inv_park_q31( q31_t Id, q31_t Iq, q31_t * pIalpha, q31_t * pIbeta, q31_t sinVal, q31_t cosVal) { q31_t product1, product2; /* Temporary variables used to store intermediate results */ q31_t product3, product4; /* Temporary variables used to store intermediate results */ /* Intermediate product is calculated by (Id * cosVal) */ product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31); /* Intermediate product is calculated by (Iq * sinVal) */ product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31); /* Intermediate product is calculated by (Id * sinVal) */ product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31); /* Intermediate product is calculated by (Iq * cosVal) */ product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31); /* Calculate pIalpha by using the two intermediate products 1 and 2 */ *pIalpha = __QSUB(product1, product2); /* Calculate pIbeta by using the two intermediate products 3 and 4 */ *pIbeta = __QADD(product4, product3); } /** * @} end of Inverse park group */ /** * @ingroup groupInterpolation */ /** * @defgroup LinearInterpolate Linear Interpolation * * Linear interpolation is a method of curve fitting using linear polynomials. * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line * * \par * \image html LinearInterp.gif "Linear interpolation" * * \par * A Linear Interpolate function calculates an output value(y), for the input(x) * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values) * * \par Algorithm: * <pre> * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0)) * where x0, x1 are nearest values of input x * y0, y1 are nearest values to output y * </pre> * * \par * This set of functions implements Linear interpolation process * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single * sample of data and each call to the function returns a single processed value. * <code>S</code> points to an instance of the Linear Interpolate function data structure. * <code>x</code> is the input sample value. The functions returns the output value. * * \par * if x is outside of the table boundary, Linear interpolation returns first value of the table * if x is below input range and returns last value of table if x is above range. */ /** * @addtogroup LinearInterpolate * @{ */ /** * @brief Process function for the floating-point Linear Interpolation Function. * @param[in,out] S is an instance of the floating-point Linear Interpolation structure * @param[in] x input sample to process * @return y processed output sample. * */ __STATIC_FORCEINLINE float32_t arm_linear_interp_f32( arm_linear_interp_instance_f32 * S, float32_t x) { float32_t y; float32_t x0, x1; /* Nearest input values */ float32_t y0, y1; /* Nearest output values */ float32_t xSpacing = S->xSpacing; /* spacing between input values */ int32_t i; /* Index variable */ float32_t *pYData = S->pYData; /* pointer to output table */ /* Calculation of index */ i = (int32_t) ((x - S->x1) / xSpacing); if (i < 0) { /* Iniatilize output for below specified range as least output value of table */ y = pYData[0]; } else if ((uint32_t)i >= S->nValues) { /* Iniatilize output for above specified range as last output value of table */ y = pYData[S->nValues - 1]; } else { /* Calculation of nearest input values */ x0 = S->x1 + i * xSpacing; x1 = S->x1 + (i + 1) * xSpacing; /* Read of nearest output values */ y0 = pYData[i]; y1 = pYData[i + 1]; /* Calculation of output */ y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0)); } /* returns output value */ return (y); } /** * * @brief Process function for the Q31 Linear Interpolation Function. * @param[in] pYData pointer to Q31 Linear Interpolation table * @param[in] x input sample to process * @param[in] nValues number of table values * @return y processed output sample. * * \par * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. * This function can support maximum of table size 2^12. * */ __STATIC_FORCEINLINE q31_t arm_linear_interp_q31( q31_t * pYData, q31_t x, uint32_t nValues) { q31_t y; /* output */ q31_t y0, y1; /* Nearest output values */ q31_t fract; /* fractional part */ int32_t index; /* Index to read nearest output values */ /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ index = ((x & (q31_t)0xFFF00000) >> 20); if (index >= (int32_t)(nValues - 1)) { return (pYData[nValues - 1]); } else if (index < 0) { return (pYData[0]); } else { /* 20 bits for the fractional part */ /* shift left by 11 to keep fract in 1.31 format */ fract = (x & 0x000FFFFF) << 11; /* Read two nearest output values from the index in 1.31(q31) format */ y0 = pYData[index]; y1 = pYData[index + 1]; /* Calculation of y0 * (1-fract) and y is in 2.30 format */ y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32)); /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */ y += ((q31_t) (((q63_t) y1 * fract) >> 32)); /* Convert y to 1.31 format */ return (y << 1U); } } /** * * @brief Process function for the Q15 Linear Interpolation Function. * @param[in] pYData pointer to Q15 Linear Interpolation table * @param[in] x input sample to process * @param[in] nValues number of table values * @return y processed output sample. * * \par * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. * This function can support maximum of table size 2^12. * */ __STATIC_FORCEINLINE q15_t arm_linear_interp_q15( q15_t * pYData, q31_t x, uint32_t nValues) { q63_t y; /* output */ q15_t y0, y1; /* Nearest output values */ q31_t fract; /* fractional part */ int32_t index; /* Index to read nearest output values */ /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ index = ((x & (int32_t)0xFFF00000) >> 20); if (index >= (int32_t)(nValues - 1)) { return (pYData[nValues - 1]); } else if (index < 0) { return (pYData[0]); } else { /* 20 bits for the fractional part */ /* fract is in 12.20 format */ fract = (x & 0x000FFFFF); /* Read two nearest output values from the index */ y0 = pYData[index]; y1 = pYData[index + 1]; /* Calculation of y0 * (1-fract) and y is in 13.35 format */ y = ((q63_t) y0 * (0xFFFFF - fract)); /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */ y += ((q63_t) y1 * (fract)); /* convert y to 1.15 format */ return (q15_t) (y >> 20); } } /** * * @brief Process function for the Q7 Linear Interpolation Function. * @param[in] pYData pointer to Q7 Linear Interpolation table * @param[in] x input sample to process * @param[in] nValues number of table values * @return y processed output sample. * * \par * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. * This function can support maximum of table size 2^12. */ __STATIC_FORCEINLINE q7_t arm_linear_interp_q7( q7_t * pYData, q31_t x, uint32_t nValues) { q31_t y; /* output */ q7_t y0, y1; /* Nearest output values */ q31_t fract; /* fractional part */ uint32_t index; /* Index to read nearest output values */ /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ if (x < 0) { return (pYData[0]); } index = (x >> 20) & 0xfff; if (index >= (nValues - 1)) { return (pYData[nValues - 1]); } else { /* 20 bits for the fractional part */ /* fract is in 12.20 format */ fract = (x & 0x000FFFFF); /* Read two nearest output values from the index and are in 1.7(q7) format */ y0 = pYData[index]; y1 = pYData[index + 1]; /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */ y = ((y0 * (0xFFFFF - fract))); /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */ y += (y1 * fract); /* convert y to 1.7(q7) format */ return (q7_t) (y >> 20); } } /** * @} end of LinearInterpolate group */ /** * @brief Fast approximation to the trigonometric sine function for floating-point data. * @param[in] x input value in radians. * @return sin(x). */ float32_t arm_sin_f32( float32_t x); /** * @brief Fast approximation to the trigonometric sine function for Q31 data. * @param[in] x Scaled input value in radians. * @return sin(x). */ q31_t arm_sin_q31( q31_t x); /** * @brief Fast approximation to the trigonometric sine function for Q15 data. * @param[in] x Scaled input value in radians. * @return sin(x). */ q15_t arm_sin_q15( q15_t x); /** * @brief Fast approximation to the trigonometric cosine function for floating-point data. * @param[in] x input value in radians. * @return cos(x). */ float32_t arm_cos_f32( float32_t x); /** * @brief Fast approximation to the trigonometric cosine function for Q31 data. * @param[in] x Scaled input value in radians. * @return cos(x). */ q31_t arm_cos_q31( q31_t x); /** * @brief Fast approximation to the trigonometric cosine function for Q15 data. * @param[in] x Scaled input value in radians. * @return cos(x). */ q15_t arm_cos_q15( q15_t x); /** * @ingroup groupFastMath */ /** * @defgroup SQRT Square Root * * Computes the square root of a number. * There are separate functions for Q15, Q31, and floating-point data types. * The square root function is computed using the Newton-Raphson algorithm. * This is an iterative algorithm of the form: * <pre> * x1 = x0 - f(x0)/f'(x0) * </pre> * where <code>x1</code> is the current estimate, * <code>x0</code> is the previous estimate, and * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>. * For the square root function, the algorithm reduces to: * <pre> * x0 = in/2 [initial guess] * x1 = 1/2 * ( x0 + in / x0) [each iteration] * </pre> */ /** * @addtogroup SQRT * @{ */ /** @brief Floating-point square root function. @param[in] in input value @param[out] pOut square root of input value @return execution status - \ref ARM_MATH_SUCCESS : input value is positive - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 */ __STATIC_FORCEINLINE arm_status arm_sqrt_f32( float32_t in, float32_t * pOut) { if (in >= 0.0f) { #if defined ( __CC_ARM ) #if defined __TARGET_FPU_VFP *pOut = __sqrtf(in); #else *pOut = sqrtf(in); #endif #elif defined ( __ICCARM__ ) #if defined __ARMVFP__ __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in)); #else *pOut = sqrtf(in); #endif #else *pOut = sqrtf(in); #endif return (ARM_MATH_SUCCESS); } else { *pOut = 0.0f; return (ARM_MATH_ARGUMENT_ERROR); } } /** @brief Q31 square root function. @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF @param[out] pOut points to square root of input value @return execution status - \ref ARM_MATH_SUCCESS : input value is positive - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 */ arm_status arm_sqrt_q31( q31_t in, q31_t * pOut); /** @brief Q15 square root function. @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF @param[out] pOut points to square root of input value @return execution status - \ref ARM_MATH_SUCCESS : input value is positive - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 */ arm_status arm_sqrt_q15( q15_t in, q15_t * pOut); /** * @brief Vector Floating-point square root function. * @param[in] pIn input vector. * @param[out] pOut vector of square roots of input elements. * @param[in] len length of input vector. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if * <code>in</code> is negative value and returns zero output for negative values. */ void arm_vsqrt_f32( float32_t * pIn, float32_t * pOut, uint16_t len); void arm_vsqrt_q31( q31_t * pIn, q31_t * pOut, uint16_t len); void arm_vsqrt_q15( q15_t * pIn, q15_t * pOut, uint16_t len); /** * @} end of SQRT group */ /** * @brief floating-point Circular write function. */ __STATIC_FORCEINLINE void arm_circularWrite_f32( int32_t * circBuffer, int32_t L, uint16_t * writeOffset, int32_t bufferInc, const int32_t * src, int32_t srcInc, uint32_t blockSize) { uint32_t i = 0U; int32_t wOffset; /* Copy the value of Index pointer that points * to the current location where the input samples to be copied */ wOffset = *writeOffset; /* Loop over the blockSize */ i = blockSize; while (i > 0U) { /* copy the input sample to the circular buffer */ circBuffer[wOffset] = *src; /* Update the input pointer */ src += srcInc; /* Circularly update wOffset. Watch out for positive and negative value */ wOffset += bufferInc; if (wOffset >= L) wOffset -= L; /* Decrement the loop counter */ i--; } /* Update the index pointer */ *writeOffset = (uint16_t)wOffset; } /** * @brief floating-point Circular Read function. */ __STATIC_FORCEINLINE void arm_circularRead_f32( int32_t * circBuffer, int32_t L, int32_t * readOffset, int32_t bufferInc, int32_t * dst, int32_t * dst_base, int32_t dst_length, int32_t dstInc, uint32_t blockSize) { uint32_t i = 0U; int32_t rOffset; int32_t* dst_end; /* Copy the value of Index pointer that points * to the current location from where the input samples to be read */ rOffset = *readOffset; dst_end = dst_base + dst_length; /* Loop over the blockSize */ i = blockSize; while (i > 0U) { /* copy the sample from the circular buffer to the destination buffer */ *dst = circBuffer[rOffset]; /* Update the input pointer */ dst += dstInc; if (dst == dst_end) { dst = dst_base; } /* Circularly update rOffset. Watch out for positive and negative value */ rOffset += bufferInc; if (rOffset >= L) { rOffset -= L; } /* Decrement the loop counter */ i--; } /* Update the index pointer */ *readOffset = rOffset; } /** * @brief Q15 Circular write function. */ __STATIC_FORCEINLINE void arm_circularWrite_q15( q15_t * circBuffer, int32_t L, uint16_t * writeOffset, int32_t bufferInc, const q15_t * src, int32_t srcInc, uint32_t blockSize) { uint32_t i = 0U; int32_t wOffset; /* Copy the value of Index pointer that points * to the current location where the input samples to be copied */ wOffset = *writeOffset; /* Loop over the blockSize */ i = blockSize; while (i > 0U) { /* copy the input sample to the circular buffer */ circBuffer[wOffset] = *src; /* Update the input pointer */ src += srcInc; /* Circularly update wOffset. Watch out for positive and negative value */ wOffset += bufferInc; if (wOffset >= L) wOffset -= L; /* Decrement the loop counter */ i--; } /* Update the index pointer */ *writeOffset = (uint16_t)wOffset; } /** * @brief Q15 Circular Read function. */ __STATIC_FORCEINLINE void arm_circularRead_q15( q15_t * circBuffer, int32_t L, int32_t * readOffset, int32_t bufferInc, q15_t * dst, q15_t * dst_base, int32_t dst_length, int32_t dstInc, uint32_t blockSize) { uint32_t i = 0; int32_t rOffset; q15_t* dst_end; /* Copy the value of Index pointer that points * to the current location from where the input samples to be read */ rOffset = *readOffset; dst_end = dst_base + dst_length; /* Loop over the blockSize */ i = blockSize; while (i > 0U) { /* copy the sample from the circular buffer to the destination buffer */ *dst = circBuffer[rOffset]; /* Update the input pointer */ dst += dstInc; if (dst == dst_end) { dst = dst_base; } /* Circularly update wOffset. Watch out for positive and negative value */ rOffset += bufferInc; if (rOffset >= L) { rOffset -= L; } /* Decrement the loop counter */ i--; } /* Update the index pointer */ *readOffset = rOffset; } /** * @brief Q7 Circular write function. */ __STATIC_FORCEINLINE void arm_circularWrite_q7( q7_t * circBuffer, int32_t L, uint16_t * writeOffset, int32_t bufferInc, const q7_t * src, int32_t srcInc, uint32_t blockSize) { uint32_t i = 0U; int32_t wOffset; /* Copy the value of Index pointer that points * to the current location where the input samples to be copied */ wOffset = *writeOffset; /* Loop over the blockSize */ i = blockSize; while (i > 0U) { /* copy the input sample to the circular buffer */ circBuffer[wOffset] = *src; /* Update the input pointer */ src += srcInc; /* Circularly update wOffset. Watch out for positive and negative value */ wOffset += bufferInc; if (wOffset >= L) wOffset -= L; /* Decrement the loop counter */ i--; } /* Update the index pointer */ *writeOffset = (uint16_t)wOffset; } /** * @brief Q7 Circular Read function. */ __STATIC_FORCEINLINE void arm_circularRead_q7( q7_t * circBuffer, int32_t L, int32_t * readOffset, int32_t bufferInc, q7_t * dst, q7_t * dst_base, int32_t dst_length, int32_t dstInc, uint32_t blockSize) { uint32_t i = 0; int32_t rOffset; q7_t* dst_end; /* Copy the value of Index pointer that points * to the current location from where the input samples to be read */ rOffset = *readOffset; dst_end = dst_base + dst_length; /* Loop over the blockSize */ i = blockSize; while (i > 0U) { /* copy the sample from the circular buffer to the destination buffer */ *dst = circBuffer[rOffset]; /* Update the input pointer */ dst += dstInc; if (dst == dst_end) { dst = dst_base; } /* Circularly update rOffset. Watch out for positive and negative value */ rOffset += bufferInc; if (rOffset >= L) { rOffset -= L; } /* Decrement the loop counter */ i--; } /* Update the index pointer */ *readOffset = rOffset; } /** * @brief Sum of the squares of the elements of a Q31 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_power_q31( const q31_t * pSrc, uint32_t blockSize, q63_t * pResult); /** * @brief Sum of the squares of the elements of a floating-point vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_power_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult); /** * @brief Sum of the squares of the elements of a Q15 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_power_q15( const q15_t * pSrc, uint32_t blockSize, q63_t * pResult); /** * @brief Sum of the squares of the elements of a Q7 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_power_q7( const q7_t * pSrc, uint32_t blockSize, q31_t * pResult); /** * @brief Mean value of a Q7 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_mean_q7( const q7_t * pSrc, uint32_t blockSize, q7_t * pResult); /** * @brief Mean value of a Q15 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_mean_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult); /** * @brief Mean value of a Q31 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_mean_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult); /** * @brief Mean value of a floating-point vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_mean_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult); /** * @brief Variance of the elements of a floating-point vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_var_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult); /** * @brief Variance of the elements of a Q31 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_var_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult); /** * @brief Variance of the elements of a Q15 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_var_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult); /** * @brief Root Mean Square of the elements of a floating-point vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_rms_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult); /** * @brief Root Mean Square of the elements of a Q31 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_rms_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult); /** * @brief Root Mean Square of the elements of a Q15 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_rms_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult); /** * @brief Standard deviation of the elements of a floating-point vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_std_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult); /** * @brief Standard deviation of the elements of a Q31 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_std_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult); /** * @brief Standard deviation of the elements of a Q15 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output value. */ void arm_std_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult); /** * @brief Floating-point complex magnitude * @param[in] pSrc points to the complex input vector * @param[out] pDst points to the real output vector * @param[in] numSamples number of complex samples in the input vector */ void arm_cmplx_mag_f32( const float32_t * pSrc, float32_t * pDst, uint32_t numSamples); /** * @brief Q31 complex magnitude * @param[in] pSrc points to the complex input vector * @param[out] pDst points to the real output vector * @param[in] numSamples number of complex samples in the input vector */ void arm_cmplx_mag_q31( const q31_t * pSrc, q31_t * pDst, uint32_t numSamples); /** * @brief Q15 complex magnitude * @param[in] pSrc points to the complex input vector * @param[out] pDst points to the real output vector * @param[in] numSamples number of complex samples in the input vector */ void arm_cmplx_mag_q15( const q15_t * pSrc, q15_t * pDst, uint32_t numSamples); /** * @brief Q15 complex dot product * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] numSamples number of complex samples in each vector * @param[out] realResult real part of the result returned here * @param[out] imagResult imaginary part of the result returned here */ void arm_cmplx_dot_prod_q15( const q15_t * pSrcA, const q15_t * pSrcB, uint32_t numSamples, q31_t * realResult, q31_t * imagResult); /** * @brief Q31 complex dot product * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] numSamples number of complex samples in each vector * @param[out] realResult real part of the result returned here * @param[out] imagResult imaginary part of the result returned here */ void arm_cmplx_dot_prod_q31( const q31_t * pSrcA, const q31_t * pSrcB, uint32_t numSamples, q63_t * realResult, q63_t * imagResult); /** * @brief Floating-point complex dot product * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[in] numSamples number of complex samples in each vector * @param[out] realResult real part of the result returned here * @param[out] imagResult imaginary part of the result returned here */ void arm_cmplx_dot_prod_f32( const float32_t * pSrcA, const float32_t * pSrcB, uint32_t numSamples, float32_t * realResult, float32_t * imagResult); /** * @brief Q15 complex-by-real multiplication * @param[in] pSrcCmplx points to the complex input vector * @param[in] pSrcReal points to the real input vector * @param[out] pCmplxDst points to the complex output vector * @param[in] numSamples number of samples in each vector */ void arm_cmplx_mult_real_q15( const q15_t * pSrcCmplx, const q15_t * pSrcReal, q15_t * pCmplxDst, uint32_t numSamples); /** * @brief Q31 complex-by-real multiplication * @param[in] pSrcCmplx points to the complex input vector * @param[in] pSrcReal points to the real input vector * @param[out] pCmplxDst points to the complex output vector * @param[in] numSamples number of samples in each vector */ void arm_cmplx_mult_real_q31( const q31_t * pSrcCmplx, const q31_t * pSrcReal, q31_t * pCmplxDst, uint32_t numSamples); /** * @brief Floating-point complex-by-real multiplication * @param[in] pSrcCmplx points to the complex input vector * @param[in] pSrcReal points to the real input vector * @param[out] pCmplxDst points to the complex output vector * @param[in] numSamples number of samples in each vector */ void arm_cmplx_mult_real_f32( const float32_t * pSrcCmplx, const float32_t * pSrcReal, float32_t * pCmplxDst, uint32_t numSamples); /** * @brief Minimum value of a Q7 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] result is output pointer * @param[in] index is the array index of the minimum value in the input buffer. */ void arm_min_q7( const q7_t * pSrc, uint32_t blockSize, q7_t * result, uint32_t * index); /** * @brief Minimum value of a Q15 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output pointer * @param[in] pIndex is the array index of the minimum value in the input buffer. */ void arm_min_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult, uint32_t * pIndex); /** * @brief Minimum value of a Q31 vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output pointer * @param[out] pIndex is the array index of the minimum value in the input buffer. */ void arm_min_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult, uint32_t * pIndex); /** * @brief Minimum value of a floating-point vector. * @param[in] pSrc is input pointer * @param[in] blockSize is the number of samples to process * @param[out] pResult is output pointer * @param[out] pIndex is the array index of the minimum value in the input buffer. */ void arm_min_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult, uint32_t * pIndex); /** * @brief Maximum value of a Q7 vector. * @param[in] pSrc points to the input buffer * @param[in] blockSize length of the input vector * @param[out] pResult maximum value returned here * @param[out] pIndex index of maximum value returned here */ void arm_max_q7( const q7_t * pSrc, uint32_t blockSize, q7_t * pResult, uint32_t * pIndex); /** * @brief Maximum value of a Q15 vector. * @param[in] pSrc points to the input buffer * @param[in] blockSize length of the input vector * @param[out] pResult maximum value returned here * @param[out] pIndex index of maximum value returned here */ void arm_max_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult, uint32_t * pIndex); /** * @brief Maximum value of a Q31 vector. * @param[in] pSrc points to the input buffer * @param[in] blockSize length of the input vector * @param[out] pResult maximum value returned here * @param[out] pIndex index of maximum value returned here */ void arm_max_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult, uint32_t * pIndex); /** * @brief Maximum value of a floating-point vector. * @param[in] pSrc points to the input buffer * @param[in] blockSize length of the input vector * @param[out] pResult maximum value returned here * @param[out] pIndex index of maximum value returned here */ void arm_max_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult, uint32_t * pIndex); /** * @brief Q15 complex-by-complex multiplication * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] numSamples number of complex samples in each vector */ void arm_cmplx_mult_cmplx_q15( const q15_t * pSrcA, const q15_t * pSrcB, q15_t * pDst, uint32_t numSamples); /** * @brief Q31 complex-by-complex multiplication * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] numSamples number of complex samples in each vector */ void arm_cmplx_mult_cmplx_q31( const q31_t * pSrcA, const q31_t * pSrcB, q31_t * pDst, uint32_t numSamples); /** * @brief Floating-point complex-by-complex multiplication * @param[in] pSrcA points to the first input vector * @param[in] pSrcB points to the second input vector * @param[out] pDst points to the output vector * @param[in] numSamples number of complex samples in each vector */ void arm_cmplx_mult_cmplx_f32( const float32_t * pSrcA, const float32_t * pSrcB, float32_t * pDst, uint32_t numSamples); /** * @brief Converts the elements of the floating-point vector to Q31 vector. * @param[in] pSrc points to the floating-point input vector * @param[out] pDst points to the Q31 output vector * @param[in] blockSize length of the input vector */ void arm_float_to_q31( const float32_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the floating-point vector to Q15 vector. * @param[in] pSrc points to the floating-point input vector * @param[out] pDst points to the Q15 output vector * @param[in] blockSize length of the input vector */ void arm_float_to_q15( const float32_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the floating-point vector to Q7 vector. * @param[in] pSrc points to the floating-point input vector * @param[out] pDst points to the Q7 output vector * @param[in] blockSize length of the input vector */ void arm_float_to_q7( const float32_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q31 vector to floating-point vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q31_to_float( const q31_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q31 vector to Q15 vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q31_to_q15( const q31_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q31 vector to Q7 vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q31_to_q7( const q31_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q15 vector to floating-point vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q15_to_float( const q15_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q15 vector to Q31 vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q15_to_q31( const q15_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q15 vector to Q7 vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q15_to_q7( const q15_t * pSrc, q7_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q7 vector to floating-point vector. * @param[in] pSrc is input pointer * @param[out] pDst is output pointer * @param[in] blockSize is the number of samples to process */ void arm_q7_to_float( const q7_t * pSrc, float32_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q7 vector to Q31 vector. * @param[in] pSrc input pointer * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_q7_to_q31( const q7_t * pSrc, q31_t * pDst, uint32_t blockSize); /** * @brief Converts the elements of the Q7 vector to Q15 vector. * @param[in] pSrc input pointer * @param[out] pDst output pointer * @param[in] blockSize number of samples to process */ void arm_q7_to_q15( const q7_t * pSrc, q15_t * pDst, uint32_t blockSize); /** * @ingroup groupInterpolation */ /** * @defgroup BilinearInterpolate Bilinear Interpolation * * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid. * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process * determines values between the grid points. * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension. * Bilinear interpolation is often used in image processing to rescale images. * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types. * * <b>Algorithm</b> * \par * The instance structure used by the bilinear interpolation functions describes a two dimensional data table. * For floating-point, the instance structure is defined as: * <pre> * typedef struct * { * uint16_t numRows; * uint16_t numCols; * float32_t *pData; * } arm_bilinear_interp_instance_f32; * </pre> * * \par * where <code>numRows</code> specifies the number of rows in the table; * <code>numCols</code> specifies the number of columns in the table; * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values. * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes. * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers. * * \par * Let <code>(x, y)</code> specify the desired interpolation point. Then define: * <pre> * XF = floor(x) * YF = floor(y) * </pre> * \par * The interpolated output point is computed as: * <pre> * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF)) * + f(XF+1, YF) * (x-XF)*(1-(y-YF)) * + f(XF, YF+1) * (1-(x-XF))*(y-YF) * + f(XF+1, YF+1) * (x-XF)*(y-YF) * </pre> * Note that the coordinates (x, y) contain integer and fractional components. * The integer components specify which portion of the table to use while the * fractional components control the interpolation processor. * * \par * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output. */ /** * @addtogroup BilinearInterpolate * @{ */ /** * @brief Floating-point bilinear interpolation. * @param[in,out] S points to an instance of the interpolation structure. * @param[in] X interpolation coordinate. * @param[in] Y interpolation coordinate. * @return out interpolated value. */ __STATIC_FORCEINLINE float32_t arm_bilinear_interp_f32( const arm_bilinear_interp_instance_f32 * S, float32_t X, float32_t Y) { float32_t out; float32_t f00, f01, f10, f11; float32_t *pData = S->pData; int32_t xIndex, yIndex, index; float32_t xdiff, ydiff; float32_t b1, b2, b3, b4; xIndex = (int32_t) X; yIndex = (int32_t) Y; /* Care taken for table outside boundary */ /* Returns zero output when values are outside table boundary */ if (xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1)) { return (0); } /* Calculation of index for two nearest points in X-direction */ index = (xIndex - 1) + (yIndex - 1) * S->numCols; /* Read two nearest points in X-direction */ f00 = pData[index]; f01 = pData[index + 1]; /* Calculation of index for two nearest points in Y-direction */ index = (xIndex - 1) + (yIndex) * S->numCols; /* Read two nearest points in Y-direction */ f10 = pData[index]; f11 = pData[index + 1]; /* Calculation of intermediate values */ b1 = f00; b2 = f01 - f00; b3 = f10 - f00; b4 = f00 - f01 - f10 + f11; /* Calculation of fractional part in X */ xdiff = X - xIndex; /* Calculation of fractional part in Y */ ydiff = Y - yIndex; /* Calculation of bi-linear interpolated output */ out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff; /* return to application */ return (out); } /** * @brief Q31 bilinear interpolation. * @param[in,out] S points to an instance of the interpolation structure. * @param[in] X interpolation coordinate in 12.20 format. * @param[in] Y interpolation coordinate in 12.20 format. * @return out interpolated value. */ __STATIC_FORCEINLINE q31_t arm_bilinear_interp_q31( arm_bilinear_interp_instance_q31 * S, q31_t X, q31_t Y) { q31_t out; /* Temporary output */ q31_t acc = 0; /* output */ q31_t xfract, yfract; /* X, Y fractional parts */ q31_t x1, x2, y1, y2; /* Nearest output values */ int32_t rI, cI; /* Row and column indices */ q31_t *pYData = S->pData; /* pointer to output table values */ uint32_t nCols = S->numCols; /* num of rows */ /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ rI = ((X & (q31_t)0xFFF00000) >> 20); /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ cI = ((Y & (q31_t)0xFFF00000) >> 20); /* Care taken for table outside boundary */ /* Returns zero output when values are outside table boundary */ if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) { return (0); } /* 20 bits for the fractional part */ /* shift left xfract by 11 to keep 1.31 format */ xfract = (X & 0x000FFFFF) << 11U; /* Read two nearest output values from the index */ x1 = pYData[(rI) + (int32_t)nCols * (cI) ]; x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1]; /* 20 bits for the fractional part */ /* shift left yfract by 11 to keep 1.31 format */ yfract = (Y & 0x000FFFFF) << 11U; /* Read two nearest output values from the index */ y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ]; y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1]; /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */ out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32)); acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32)); /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */ out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32)); acc += ((q31_t) ((q63_t) out * (xfract) >> 32)); /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */ out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32)); acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */ out = ((q31_t) ((q63_t) y2 * (xfract) >> 32)); acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); /* Convert acc to 1.31(q31) format */ return ((q31_t)(acc << 2)); } /** * @brief Q15 bilinear interpolation. * @param[in,out] S points to an instance of the interpolation structure. * @param[in] X interpolation coordinate in 12.20 format. * @param[in] Y interpolation coordinate in 12.20 format. * @return out interpolated value. */ __STATIC_FORCEINLINE q15_t arm_bilinear_interp_q15( arm_bilinear_interp_instance_q15 * S, q31_t X, q31_t Y) { q63_t acc = 0; /* output */ q31_t out; /* Temporary output */ q15_t x1, x2, y1, y2; /* Nearest output values */ q31_t xfract, yfract; /* X, Y fractional parts */ int32_t rI, cI; /* Row and column indices */ q15_t *pYData = S->pData; /* pointer to output table values */ uint32_t nCols = S->numCols; /* num of rows */ /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ rI = ((X & (q31_t)0xFFF00000) >> 20); /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ cI = ((Y & (q31_t)0xFFF00000) >> 20); /* Care taken for table outside boundary */ /* Returns zero output when values are outside table boundary */ if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) { return (0); } /* 20 bits for the fractional part */ /* xfract should be in 12.20 format */ xfract = (X & 0x000FFFFF); /* Read two nearest output values from the index */ x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ]; x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1]; /* 20 bits for the fractional part */ /* yfract should be in 12.20 format */ yfract = (Y & 0x000FFFFF); /* Read two nearest output values from the index */ y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ]; y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1]; /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */ /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */ /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */ out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4U); acc = ((q63_t) out * (0xFFFFF - yfract)); /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */ out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4U); acc += ((q63_t) out * (xfract)); /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */ out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4U); acc += ((q63_t) out * (yfract)); /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */ out = (q31_t) (((q63_t) y2 * (xfract)) >> 4U); acc += ((q63_t) out * (yfract)); /* acc is in 13.51 format and down shift acc by 36 times */ /* Convert out to 1.15 format */ return ((q15_t)(acc >> 36)); } /** * @brief Q7 bilinear interpolation. * @param[in,out] S points to an instance of the interpolation structure. * @param[in] X interpolation coordinate in 12.20 format. * @param[in] Y interpolation coordinate in 12.20 format. * @return out interpolated value. */ __STATIC_FORCEINLINE q7_t arm_bilinear_interp_q7( arm_bilinear_interp_instance_q7 * S, q31_t X, q31_t Y) { q63_t acc = 0; /* output */ q31_t out; /* Temporary output */ q31_t xfract, yfract; /* X, Y fractional parts */ q7_t x1, x2, y1, y2; /* Nearest output values */ int32_t rI, cI; /* Row and column indices */ q7_t *pYData = S->pData; /* pointer to output table values */ uint32_t nCols = S->numCols; /* num of rows */ /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ rI = ((X & (q31_t)0xFFF00000) >> 20); /* Input is in 12.20 format */ /* 12 bits for the table index */ /* Index value calculation */ cI = ((Y & (q31_t)0xFFF00000) >> 20); /* Care taken for table outside boundary */ /* Returns zero output when values are outside table boundary */ if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) { return (0); } /* 20 bits for the fractional part */ /* xfract should be in 12.20 format */ xfract = (X & (q31_t)0x000FFFFF); /* Read two nearest output values from the index */ x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ]; x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1]; /* 20 bits for the fractional part */ /* yfract should be in 12.20 format */ yfract = (Y & (q31_t)0x000FFFFF); /* Read two nearest output values from the index */ y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ]; y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1]; /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */ out = ((x1 * (0xFFFFF - xfract))); acc = (((q63_t) out * (0xFFFFF - yfract))); /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */ out = ((x2 * (0xFFFFF - yfract))); acc += (((q63_t) out * (xfract))); /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */ out = ((y1 * (0xFFFFF - xfract))); acc += (((q63_t) out * (yfract))); /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */ out = ((y2 * (yfract))); acc += (((q63_t) out * (xfract))); /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */ return ((q7_t)(acc >> 40)); } /** * @} end of BilinearInterpolate group */ /* SMMLAR */ #define multAcc_32x32_keep32_R(a, x, y) \ a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32) /* SMMLSR */ #define multSub_32x32_keep32_R(a, x, y) \ a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32) /* SMMULR */ #define mult_32x32_keep32_R(a, x, y) \ a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32) /* SMMLA */ #define multAcc_32x32_keep32(a, x, y) \ a += (q31_t) (((q63_t) x * y) >> 32) /* SMMLS */ #define multSub_32x32_keep32(a, x, y) \ a -= (q31_t) (((q63_t) x * y) >> 32) /* SMMUL */ #define mult_32x32_keep32(a, x, y) \ a = (q31_t) (((q63_t) x * y ) >> 32) #if defined ( __CC_ARM ) /* Enter low optimization region - place directly above function definition */ #if defined( __ARM_ARCH_7EM__ ) #define LOW_OPTIMIZATION_ENTER \ _Pragma ("push") \ _Pragma ("O1") #else #define LOW_OPTIMIZATION_ENTER #endif /* Exit low optimization region - place directly after end of function definition */ #if defined ( __ARM_ARCH_7EM__ ) #define LOW_OPTIMIZATION_EXIT \ _Pragma ("pop") #else #define LOW_OPTIMIZATION_EXIT #endif /* Enter low optimization region - place directly above function definition */ #define IAR_ONLY_LOW_OPTIMIZATION_ENTER /* Exit low optimization region - place directly after end of function definition */ #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) #define LOW_OPTIMIZATION_ENTER #define LOW_OPTIMIZATION_EXIT #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #elif defined ( __GNUC__ ) #define LOW_OPTIMIZATION_ENTER \ __attribute__(( optimize("-O1") )) #define LOW_OPTIMIZATION_EXIT #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #elif defined ( __ICCARM__ ) /* Enter low optimization region - place directly above function definition */ #if defined ( __ARM_ARCH_7EM__ ) #define LOW_OPTIMIZATION_ENTER \ _Pragma ("optimize=low") #else #define LOW_OPTIMIZATION_ENTER #endif /* Exit low optimization region - place directly after end of function definition */ #define LOW_OPTIMIZATION_EXIT /* Enter low optimization region - place directly above function definition */ #if defined ( __ARM_ARCH_7EM__ ) #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \ _Pragma ("optimize=low") #else #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #endif /* Exit low optimization region - place directly after end of function definition */ #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #elif defined ( __TI_ARM__ ) #define LOW_OPTIMIZATION_ENTER #define LOW_OPTIMIZATION_EXIT #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #elif defined ( __CSMC__ ) #define LOW_OPTIMIZATION_ENTER #define LOW_OPTIMIZATION_EXIT #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #elif defined ( __TASKING__ ) #define LOW_OPTIMIZATION_ENTER #define LOW_OPTIMIZATION_EXIT #define IAR_ONLY_LOW_OPTIMIZATION_ENTER #define IAR_ONLY_LOW_OPTIMIZATION_EXIT #endif #ifdef __cplusplus } #endif /* Compiler specific diagnostic adjustment */ #if defined ( __CC_ARM ) #elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) #elif defined ( __GNUC__ ) #pragma GCC diagnostic pop #elif defined ( __ICCARM__ ) #elif defined ( __TI_ARM__ ) #elif defined ( __CSMC__ ) #elif defined ( __TASKING__ ) #elif defined ( _MSC_VER ) #else #error Unknown compiler #endif #endif /* _ARM_MATH_H */ /** * * End of file. */
257,001
C
33.909264
185
0.611161
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Include/arm_common_tables.h
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_common_tables.h * Description: Extern declaration for common tables * * $Date: 27. January 2017 * $Revision: V.1.5.1 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. * * 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. */ #ifndef _ARM_COMMON_TABLES_H #define _ARM_COMMON_TABLES_H #include "arm_math.h" #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREV_1024) extern const uint16_t armBitRevTable[1024]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_16) extern const float32_t twiddleCoef_16[32]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_32) extern const float32_t twiddleCoef_32[64]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_64) extern const float32_t twiddleCoef_64[128]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_128) extern const float32_t twiddleCoef_128[256]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_256) extern const float32_t twiddleCoef_256[512]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_512) extern const float32_t twiddleCoef_512[1024]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_1024) extern const float32_t twiddleCoef_1024[2048]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_2048) extern const float32_t twiddleCoef_2048[4096]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_4096) extern const float32_t twiddleCoef_4096[8192]; #define twiddleCoef twiddleCoef_4096 #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_16) extern const q31_t twiddleCoef_16_q31[24]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_32) extern const q31_t twiddleCoef_32_q31[48]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_64) extern const q31_t twiddleCoef_64_q31[96]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_128) extern const q31_t twiddleCoef_128_q31[192]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_256) extern const q31_t twiddleCoef_256_q31[384]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_512) extern const q31_t twiddleCoef_512_q31[768]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_1024) extern const q31_t twiddleCoef_1024_q31[1536]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_2048) extern const q31_t twiddleCoef_2048_q31[3072]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_4096) extern const q31_t twiddleCoef_4096_q31[6144]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_16) extern const q15_t twiddleCoef_16_q15[24]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_32) extern const q15_t twiddleCoef_32_q15[48]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_64) extern const q15_t twiddleCoef_64_q15[96]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_128) extern const q15_t twiddleCoef_128_q15[192]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_256) extern const q15_t twiddleCoef_256_q15[384]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_512) extern const q15_t twiddleCoef_512_q15[768]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_1024) extern const q15_t twiddleCoef_1024_q15[1536]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_2048) extern const q15_t twiddleCoef_2048_q15[3072]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_4096) extern const q15_t twiddleCoef_4096_q15[6144]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32) extern const float32_t twiddleCoef_rfft_32[32]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64) extern const float32_t twiddleCoef_rfft_64[64]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128) extern const float32_t twiddleCoef_rfft_128[128]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256) extern const float32_t twiddleCoef_rfft_256[256]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512) extern const float32_t twiddleCoef_rfft_512[512]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024) extern const float32_t twiddleCoef_rfft_1024[1024]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048) extern const float32_t twiddleCoef_rfft_2048[2048]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096) extern const float32_t twiddleCoef_rfft_4096[4096]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ /* floating-point bit reversal tables */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_16) #define ARMBITREVINDEXTABLE_16_TABLE_LENGTH ((uint16_t)20) extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_32) #define ARMBITREVINDEXTABLE_32_TABLE_LENGTH ((uint16_t)48) extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_64) #define ARMBITREVINDEXTABLE_64_TABLE_LENGTH ((uint16_t)56) extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_128) #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208) extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_256) #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440) extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_512) #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448) extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_1024) #define ARMBITREVINDEXTABLE_1024_TABLE_LENGTH ((uint16_t)1800) extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_2048) #define ARMBITREVINDEXTABLE_2048_TABLE_LENGTH ((uint16_t)3808) extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_4096) #define ARMBITREVINDEXTABLE_4096_TABLE_LENGTH ((uint16_t)4032) extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ /* fixed-point bit reversal tables */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_16) #define ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH ((uint16_t)12) extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_32) #define ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH ((uint16_t)24) extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_64) #define ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH ((uint16_t)56) extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_128) #define ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH ((uint16_t)112) extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_256) #define ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH ((uint16_t)240) extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_512) #define ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH ((uint16_t)480) extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_1024) #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992) extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_2048) #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_4096) #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_F32) extern const float32_t realCoefA[8192]; extern const float32_t realCoefB[8192]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_Q31) extern const q31_t realCoefAQ31[8192]; extern const q31_t realCoefBQ31[8192]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_Q15) extern const q15_t realCoefAQ15[8192]; extern const q15_t realCoefBQ15[8192]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_128) extern const float32_t Weights_128[256]; extern const float32_t cos_factors_128[128]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_512) extern const float32_t Weights_512[1024]; extern const float32_t cos_factors_512[512]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_2048) extern const float32_t Weights_2048[4096]; extern const float32_t cos_factors_2048[2048]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_8192) extern const float32_t Weights_8192[16384]; extern const float32_t cos_factors_8192[8192]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_128) extern const q15_t WeightsQ15_128[256]; extern const q15_t cos_factorsQ15_128[128]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_512) extern const q15_t WeightsQ15_512[1024]; extern const q15_t cos_factorsQ15_512[512]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_2048) extern const q15_t WeightsQ15_2048[4096]; extern const q15_t cos_factorsQ15_2048[2048]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_8192) extern const q15_t WeightsQ15_8192[16384]; extern const q15_t cos_factorsQ15_8192[8192]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_128) extern const q31_t WeightsQ31_128[256]; extern const q31_t cos_factorsQ31_128[128]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_512) extern const q31_t WeightsQ31_512[1024]; extern const q31_t cos_factorsQ31_512[512]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_2048) extern const q31_t WeightsQ31_2048[4096]; extern const q31_t cos_factorsQ31_2048[2048]; #endif #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_8192) extern const q31_t WeightsQ31_8192[16384]; extern const q31_t cos_factorsQ31_8192[8192]; #endif #endif /* if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FAST_ALLOW_TABLES) #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_RECIP_Q15) extern const q15_t armRecipTableQ15[64]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_RECIP_Q31) extern const q31_t armRecipTableQ31[64]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ /* Tables for Fast Math Sine and Cosine */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_F32) extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_Q31) extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_Q15) extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ #endif /* if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FAST_TABLES) */ #endif /* ARM_COMMON_TABLES_H */
21,036
C
54.506596
116
0.707834
Tbarkin121/GuardDog/stm32/MotorDrive/LegDay/Drivers/CMSIS/DSP/Include/arm_const_structs.h
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_const_structs.h * Description: Constant structs that are initialized for user convenience. * For example, some can be given as arguments to the arm_cfft_f32() function. * * $Date: 27. January 2017 * $Revision: V.1.5.1 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. * * 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. */ #ifndef _ARM_CONST_STRUCTS_H #define _ARM_CONST_STRUCTS_H #include "arm_math.h" #include "arm_common_tables.h" extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; #endif
2,961
C
43.208955
92
0.701114
Tbarkin121/GuardDog/stm32/AnymalNet/Core/Src/stm32g4xx_hal_msp.c
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file stm32g4xx_hal_msp.c * @brief This file provides code for the MSP Initialization * and de-Initialization codes. ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ /* USER CODE END TD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN Define */ /* USER CODE END Define */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN Macro */ /* USER CODE END Macro */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* External functions --------------------------------------------------------*/ /* USER CODE BEGIN ExternalFunctions */ /* USER CODE END ExternalFunctions */ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __HAL_RCC_SYSCFG_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE(); /* System interrupt init*/ /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral */ HAL_PWREx_DisableUCPDDeadBattery(); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ } /** * @brief CRC MSP Initialization * This function configures the hardware resources used in this example * @param hcrc: CRC handle pointer * @retval None */ void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc) { if(hcrc->Instance==CRC) { /* USER CODE BEGIN CRC_MspInit 0 */ /* USER CODE END CRC_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_CRC_CLK_ENABLE(); /* USER CODE BEGIN CRC_MspInit 1 */ /* USER CODE END CRC_MspInit 1 */ } } /** * @brief CRC MSP De-Initialization * This function freeze the hardware resources used in this example * @param hcrc: CRC handle pointer * @retval None */ void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc) { if(hcrc->Instance==CRC) { /* USER CODE BEGIN CRC_MspDeInit 0 */ /* USER CODE END CRC_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_CRC_CLK_DISABLE(); /* USER CODE BEGIN CRC_MspDeInit 1 */ /* USER CODE END CRC_MspDeInit 1 */ } } /** * @brief TIM_Base MSP Initialization * This function configures the hardware resources used in this example * @param htim_base: TIM_Base handle pointer * @retval None */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { if(htim_base->Instance==TIM2) { /* USER CODE BEGIN TIM2_MspInit 0 */ /* USER CODE END TIM2_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_TIM2_CLK_ENABLE(); /* USER CODE BEGIN TIM2_MspInit 1 */ /* USER CODE END TIM2_MspInit 1 */ } } /** * @brief TIM_Base MSP De-Initialization * This function freeze the hardware resources used in this example * @param htim_base: TIM_Base handle pointer * @retval None */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) { if(htim_base->Instance==TIM2) { /* USER CODE BEGIN TIM2_MspDeInit 0 */ /* USER CODE END TIM2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_TIM2_CLK_DISABLE(); /* USER CODE BEGIN TIM2_MspDeInit 1 */ /* USER CODE END TIM2_MspDeInit 1 */ } } /** * @brief UART MSP Initialization * This function configures the hardware resources used in this example * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspInit(UART_HandleTypeDef* huart) { GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(huart->Instance==USART2) { /* USER CODE BEGIN USART2_MspInit 0 */ /* USER CODE END USART2_MspInit 0 */ /** Initializes the peripherals clocks */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2; PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } /* Peripheral clock enable */ __HAL_RCC_USART2_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /**USART2 GPIO Configuration PA2 ------> USART2_TX PA3 ------> USART2_RX */ GPIO_InitStruct.Pin = USART2_TX_Pin|USART2_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF7_USART2; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USART2 interrupt Init */ HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART2_IRQn); /* USER CODE BEGIN USART2_MspInit 1 */ /* USER CODE END USART2_MspInit 1 */ } } /** * @brief UART MSP De-Initialization * This function freeze the hardware resources used in this example * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { if(huart->Instance==USART2) { /* USER CODE BEGIN USART2_MspDeInit 0 */ /* USER CODE END USART2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART2_CLK_DISABLE(); /**USART2 GPIO Configuration PA2 ------> USART2_TX PA3 ------> USART2_RX */ HAL_GPIO_DeInit(GPIOA, USART2_TX_Pin|USART2_RX_Pin); /* USART2 interrupt DeInit */ HAL_NVIC_DisableIRQ(USART2_IRQn); /* USER CODE BEGIN USART2_MspDeInit 1 */ /* USER CODE END USART2_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */
6,316
C
23.675781
80
0.589772
Tbarkin121/GuardDog/stm32/AnymalNet/Core/Src/main.c
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "app_x-cube-ai.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include <stdint.h> #include "network.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ CRC_HandleTypeDef hcrc; TIM_HandleTypeDef htim2; UART_HandleTypeDef huart2; /* USER CODE BEGIN PV */ union obsUnion { float floatValue[48]; uint8_t bytes[48 * sizeof(float)]; }; union obsUnion obs_data; union actUnion { float floatValue[12]; uint8_t bytes[12 * sizeof(float)]; }; union actUnion act_data; ai_float in_data1[AI_NETWORK_IN_1_SIZE]; ai_float out_data1[AI_NETWORK_OUT_1_SIZE]; ai_float out_data2[AI_NETWORK_OUT_2_SIZE]; ai_float out_data3[AI_NETWORK_OUT_3_SIZE]; uint8_t data_flag; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_USART2_UART_Init(void); static void MX_CRC_Init(void); static void MX_TIM2_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ data_flag=0; /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); MX_CRC_Init(); MX_TIM2_Init(); MX_X_CUBE_AI_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Receive_IT(&huart2, obs_data.bytes, sizeof(obs_data.bytes)); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { if(data_flag) { TIM2->CNT = 0; HAL_TIM_Base_Start(&htim2); for(int i=0; i<48; i++) { in_data1[i] = obs_data.floatValue[i]; } MX_X_CUBE_AI_Process(); HAL_TIM_Base_Stop(&htim2); for(int i=0; i<12; i++) { act_data.floatValue[i] = out_data1[i]; } data_flag = 0; HAL_UART_Transmit(&huart2, act_data.bytes, sizeof(act_data.bytes), 100); HAL_UART_Receive_IT(&huart2, obs_data.bytes, sizeof(obs_data.bytes)); } /* USER CODE END WHILE */ MX_X_CUBE_AI_Process(); /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4; RCC_OscInitStruct.PLL.PLLN = 85; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { Error_Handler(); } } /** * @brief CRC Initialization Function * @param None * @retval None */ static void MX_CRC_Init(void) { /* USER CODE BEGIN CRC_Init 0 */ /* USER CODE END CRC_Init 0 */ /* USER CODE BEGIN CRC_Init 1 */ /* USER CODE END CRC_Init 1 */ hcrc.Instance = CRC; hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; if (HAL_CRC_Init(&hcrc) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN CRC_Init 2 */ /* USER CODE END CRC_Init 2 */ } /** * @brief TIM2 Initialization Function * @param None * @retval None */ static void MX_TIM2_Init(void) { /* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; /* USER CODE BEGIN TIM2_Init 1 */ /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 170; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 4.294967295E9; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim2) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM2_Init 2 */ /* USER CODE END TIM2_Init 2 */ } /** * @brief USART2 Initialization Function * @param None * @retval None */ static void MX_USART2_UART_Init(void) { /* USER CODE BEGIN USART2_Init 0 */ /* USER CODE END USART2_Init 0 */ /* USER CODE BEGIN USART2_Init 1 */ /* USER CODE END USART2_Init 1 */ huart2.Instance = USART2; huart2.Init.BaudRate = 460800; huart2.Init.WordLength = UART_WORDLENGTH_8B; huart2.Init.StopBits = UART_STOPBITS_1; huart2.Init.Parity = UART_PARITY_NONE; huart2.Init.Mode = UART_MODE_TX_RX; huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart2.Init.OverSampling = UART_OVERSAMPLING_16; huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1; huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if (HAL_UART_Init(&huart2) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART2_Init 2 */ /* USER CODE END USART2_Init 2 */ } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); /*Configure GPIO pin : LD2_Pin */ GPIO_InitStruct.Pin = LD2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { // We will set a data flag here and execute in the main loop data_flag = 1; } void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) { } /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
10,424
C
25.392405
82
0.622122
Tbarkin121/GuardDog/stm32/AnymalNet/X-CUBE-AI/App/network_data_params.c
/** ****************************************************************************** * @file network_data_params.c * @author AST Embedded Analytics Research Platform * @date Sat Jan 6 20:35:01 2024 * @brief AI Tool Automatic Code Generator for Embedded NN computing ****************************************************************************** * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. ****************************************************************************** */ #include "network_data_params.h" /** Activations Section ****************************************************/ ai_handle g_network_activations_table[1 + 2] = { AI_HANDLE_PTR(AI_MAGIC_MARKER), AI_HANDLE_PTR(NULL), AI_HANDLE_PTR(AI_MAGIC_MARKER), }; /** Weights Section ********************************************************/ AI_ALIGNED(32) const ai_u64 s_network_weights_array_u64[7747] = { 0x400d32ae00000000U, 0x3fc2d3e33f8dd3b5U, 0x3de75e2b3ea6b58eU, 0x3d6c0f3a3e0e3d67U, 0x3c3d36473d6e727eU, 0x3f9051ac4011ef61U, 0x3e55bc613e11d6dfU, 0x3e6c8c063e892695U, 0x3e8473e03e56eb46U, 0x3e5237f13e57a328U, 0x3e689abb3e815d41U, 0x3e9a4ac63e3e3beaU, 0x3df26afe3e71e574U, 0x3e87209c3e45ee69U, 0x3e312a373df7b8a9U, 0x3df20c3d3e8750caU, 0x3e85ad1f3e2fef75U, 0x3e3b2cdd3deba259U, 0x3f09df8c3e89279aU, 0x3f30e1693f1aa0f1U, 0x3f0e93b43f06323cU, 0x3f008fa13f202020U, 0x3f2100413f018674U, 0x3f18ff0e3efb6c14U, 0xbd1771a63f2fec1aU, 0x3e261e543d14179eU, 0x39a79a95bb02081bU, 0x3996888a38ea2927U, 0xbf7f1ed9ba7649f9U, 0xbbe9326f3c90c0aeU, 0xbc44ec103b08bc08U, 0xbebf7ea83e9a8aedU, 0xbec04e2ebd8e44efU, 0x3d9262d03eb67008U, 0xbecacdfc3ea686aaU, 0xbe9a23eb3d279b40U, 0xb9d411de3ea3a7c7U, 0x3c3f22f7bb2e4817U, 0x3a9e4241bb06d475U, 0x3a9f527bb9d96947U, 0x3b734fc0bb0d905aU, 0x3b3051273aafacc9U, 0xbe053045bc203bcfU, 0xbe95705d3edc6117U, 0xbf087060be8b757bU, 0x3e6a06893e987e2dU, 0xbea9de1d3f02a164U, 0xbeda8b173e83026fU, 0xbef306043e1bef47U, 0xbeef5b5fbef130b2U, 0xbeebb0bbbeed860dU, 0xbee80616bee9db69U, 0xbee45b72bee630c4U, 0xbee0b0cdbee2861fU, 0xbedc4541bededb7bU, 0xbed8f711bedb30d6U, 0xbed5b0dfbed78632U, 0xbed2063bbed3db8dU, 0xbece5b96bed0b04fU, 0xbecab0f2becc8644U, 0xbec6ec15bec8dba0U, 0xbec35ba9bec530fbU, 0xbebfb104bec21144U, 0xbebc428ebebddbb2U, 0xbeb8cb00beba310dU, 0xbeb4b116beb66d19U, 0xbeb10672beb2e8ccU, 0xbead46fcbeaf3120U, 0xbea9b129beab3f0eU, 0xbea5cb2ebea79d11U, 0xbea31dffbea3afc5U, 0xbe9e97e8bea0745eU, 0xbe9bb871be9cdbe9U, 0xbe9737b2be99aa08U, 0xbe92e4f0be9542bcU, 0xbe9028a6be914171U, 0xbe8d1fb5be8ee7dcU, 0xbe88ce8ebe8a5560U, 0xbe848f83be86c419U, 0xbe819282be82c62aU, 0xbe7b52edbe7f848bU, 0xbe73266bbe7768a4U, 0xbe6cc16cbe7092a0U, 0xbe653c4bbe6930a9U, 0xbe5e57abbe624836U, 0xbe562aafbe5a5940U, 0xbe4f36c5be51ab88U, 0xbe47d9febe4bcb0dU, 0xbe407eb6be43c8acU, 0xbe396661be3d25d8U, 0xbe32013ebe35df02U, 0xbe2afb38be2ec78eU, 0xbe23852bbe273b80U, 0xbe1c540abe20575aU, 0xbe1498d1be18895cU, 0xbe0d4002be10ac5cU, 0xbe057219be0953daU, 0xbdfb8edebe0180f0U, 0xbdee29d6bdf4ab27U, 0xbddf8575bde6435bU, 0xbdd1c9b6bdd914e8U, 0xbdc43186bdca91e8U, 0xbdb4f172bdbcb6fcU, 0xbda5f843bdadf7f3U, 0xbd96bd27bd9e106bU, 0xbd885844bd8f81baU, 0xbd72f49fbd81229dU, 0xbd55f12ebd641f73U, 0xbd39a745bd47ae4eU, 0xbd1b438dbd2af319U, 0xbcfacd54bd0c9b70U, 0xbcc03443bcdd37a6U, 0xbc8661eabca23392U, 0xbc18d034bc534f89U, 0xbb09ae31bbbfecd4U, 0x3baaec6f3ad971e4U, 0x3c48e0983c0d6403U, 0x3ca0787c3c82139aU, 0x3cdbdb3e3cbeeb09U, 0x3d0aafe73cf71e3eU, 0x3d29a2993d1a700dU, 0x3d4870da3d38ac4dU, 0x3d635c463d54e347U, 0x3d7f7ec63d70d239U, 0x3d8e54843d872a24U, 0x3d9c15d43d94fe31U, 0x3dacb7243da4a8c3U, 0x3dbaafd93db3d4aaU, 0x3dc7c8c33dc0f581U, 0x3dd75fd13dcf90c3U, 0x3de584353dddef2aU, 0x3df4df683dedbeb6U, 0x3e012cab3dfc1d39U, 0x3e08d0613e050afeU, 0x3e103d163e0c9b28U, 0x3e16ec2c3e13642fU, 0x3e1ecdc43e1b3ef7U, 0x3e27055e3e23440eU, 0x3e2e10393e2a9842U, 0x3e3583023e31a88eU, 0x3e3d1aad3e3a42b6U, 0x3e43c5ed3e40bbe4U, 0x3e4b40d43e47441eU, 0x3e520de33e4f4f1cU, 0x3e5955a73e558c5dU, 0x3e617c033e5dbcd9U, 0x3e6a5e4b3e64b0c6U, 0x3e70695b3e6d384dU, 0x3e7657c33e7339daU, 0x3e7e844e3e79a19fU, 0x3e82a5fd3e81014cU, 0x3e8685eb3e84bc9aU, 0x3e8a3ce63e887784U, 0x3e8db7c13e8c3e90U, 0x3e91a2203e8ee7deU, 0x3e954cc43e93b290U, 0x3e998dcf3e976cfdU, 0x3e9c8dc23e9a8a08U, 0x3ea010bc3e9dabe4U, 0x3ea3d3d43ea1b544U, 0x3ea7dbae3ea53988U, 0x3eaba93b3ea9774eU, 0x3eaef7443ead21f2U, 0x3eb2a1e93eb0cc97U, 0x3eb611843eb4773bU, 0x3eb9f7323eb821e0U, 0x3ebd7f5a3ebbcc84U, 0x3ec17b233ec0538cU, 0x3ec4c3c63ec30b30U, 0x3ec8a1c43ec6cc72U, 0x3ecc4c693eca7717U, 0x3ecfb6b73ece21bbU, 0x3ed3a1b23ed1cc60U, 0x3ed830363ed57704U, 0x3edaf6fb3ed921a9U, 0x3edea1a03edccc4dU, 0x916850803ee076f2U, 0x2ada84869189a25bU, 0x61b6818f6c737b8bU, 0x696f669f92b46069U, 0x828e53808b8e8a72U, 0x7290907b7d86828eU, 0x567279c261748e9bU, 0x764d588869787b64U, 0x7758549b7fb5675cU, 0x708e608972756081U, 0x969487a06a73846aU, 0x8080725f747aa66bU, 0xa0b458a07d856893U, 0x63f63a5b7a7f6c8bU, 0x937b89976682a593U, 0x837374929b8e8a92U, 0x69a49282767d8397U, 0x8c988f817b91a58aU, 0x8c4ba7a46c868887U, 0x96807352a08a9e94U, 0x9d839075664d6a72U, 0x7b898397c86c7150U, 0xac77b1507369897bU, 0x8a9196a8a4607d6aU, 0x737e94a765576c90U, 0x5d7bce678e6c5c90U, 0x959455a6638a7a9cU, 0x7a92b18c72845d91U, 0x82bba99e6e976e97U, 0x847276805c8f9372U, 0x686a81b9b85a7d6fU, 0x73758069718b5d5aU, 0x8e6eaf5a6f786b84U, 0x81a8787582a39379U, 0x99908d76837a9899U, 0x8d8d66615079637bU, 0x6a5d7c7c6a827f82U, 0x6a9f664d72757285U, 0x886a959ba1999a67U, 0x7f6d537fb5778995U, 0x98ab945b7691938bU, 0x659d917f6d5c887eU, 0x5b62ba7da8806aa7U, 0x6b70aac58f726395U, 0x72869f8177bca262U, 0x5581917d76656976U, 0x715e9180769c92bbU, 0x5c7b6eada36b7f84U, 0xb373633d86989686U, 0xc56be25a8b8f7f5fU, 0x5f8f6089a3506d89U, 0x8e88997996a9954fU, 0x817c948c5ea69990U, 0x8e838c8784929b8eU, 0xa37755987394717dU, 0x93b3d5c492897f6cU, 0x7f8194ae877f888dU, 0x8073969d9399798dU, 0x75807874757c8186U, 0x9b899b9494906891U, 0x6a9592ac80a36c9eU, 0xa971873b8f9b9b81U, 0x99a785a480a28078U, 0x6a8d937a95756cadU, 0x607daca99e9e81a5U, 0x6f5966586b526c78U, 0x857780677494956aU, 0xb64da8848d794c8bU, 0x49707669a1878d81U, 0x8470917592b87861U, 0x90ada58a8488805aU, 0xa2867197748f885dU, 0x8273756570778275U, 0x6c87ac95735b8960U, 0x82ad668986515c50U, 0x7798698a6b8e7f4dU, 0x997b7e88ae8692b3U, 0x799485919a628769U, 0x9f3282aaa07a6ca5U, 0x7e6d94b976736b5fU, 0xbe7e83578b3cc673U, 0xa260cbb0b491b779U, 0x9c816a7b795fab86U, 0x9db264ae9c999d5aU, 0x9f888c7879777cbeU, 0x599c7a3b658e7a71U, 0x9d9d6965b29a936aU, 0x56a96679a79e9aabU, 0x6ba884786895926dU, 0x67727964ab5f98adU, 0x839fd33f6782a459U, 0xa9629c417b866a6aU, 0x7187665d927b5c79U, 0x6e8e539aac6fa760U, 0x83698785a15e786fU, 0x8b7175a9898d5f80U, 0x9a70a490649b8e91U, 0x687da46a746baf9aU, 0x8556787382c08098U, 0x4d725b9569898862U, 0x7b80b99086838279U, 0xa3a09a939f6ca667U, 0x8bb18a6b849c648fU, 0x9261bb979281367cU, 0xaa95889682b0898aU, 0x8f9198827aa5bbafU, 0x6a7b868180c0866dU, 0x7b7da298908c8e8eU, 0x6ac3a6af99817e7fU, 0x9d6e9b3a8287997eU, 0x70ad847ca27f72b1U, 0x6e8d976769826f6cU, 0x6674837e6377776cU, 0x6e8d8ba57361a66cU, 0x5a727d61909e776aU, 0x6aa3b6998d7dac84U, 0xb2ab93756b94739eU, 0x8879776ea8b566a4U, 0x93877183958f988dU, 0x7e787f90707a866eU, 0x559d9a7b747c687bU, 0xa5739c3f9d7e7f78U, 0x719677b15f5c6a70U, 0x8b894a725d9b6c99U, 0x8b808e6f775e6fb6U, 0x87877c948a97727bU, 0x5d6f8573809f6b6fU, 0xb56aad4ca7a0a086U, 0x71749e8897aca0a9U, 0x61746e6b7764847dU, 0x90925f7296a08e8bU, 0x9d7aac6087a89357U, 0x9789b054996ea969U, 0x827bb7605783966dU, 0x628f686b9baba170U, 0xa563918db38e52a6U, 0x696e8f7b76ac786aU, 0x696d76895a837e81U, 0x6c5b6c9fa86c7d94U, 0x76d5b7a29a79b8b4U, 0x78817775897dbe75U, 0xa59a91a0a79d767aU, 0x949e7c81715e8583U, 0x66796fa196789492U, 0xc17a885c887c7974U, 0x73b3d7bf898b608bU, 0x70967e939e72b397U, 0xa09a728b848ea065U, 0x80a78e8393957b8dU, 0x758a89739b8a9072U, 0x54769d6b7a7092aaU, 0x7a81ad7ea1778176U, 0x975f90a76682b28bU, 0xa160967c97836771U, 0x7b7d826ca48e999bU, 0xa2a48e955fada760U, 0x908881479fa17eb2U, 0x7ea9a14c6f818074U, 0x74b98886ac948783U, 0x8d8b8d757b628584U, 0x8b6a8f73a3975f5aU, 0x7aa785959f5fb4b7U, 0x9f5a6b868b91717eU, 0x60af5a958879595dU, 0x8b5e8c6170869948U, 0x957e7e8e6e6f6286U, 0x98a38a9b84906375U, 0x816572b257a4638dU, 0x84a68bbc9d755f5fU, 0x8176329b636e978cU, 0x8c7e73747b766e67U, 0x977a7b718871667eU, 0x788970806c8f8c89U, 0x8b779d8696ab7879U, 0x6b5b84758e6b8f87U, 0x76c86263908f5653U, 0x4d8491a47494976dU, 0x7e91846e6e739c5bU, 0x7d74a592678fa995U, 0x5873827f73787c74U, 0x7d53b358aba76f7aU, 0xacc9ac407e644072U, 0x98965d8d6d8077abU, 0x77958b949b6e8d9dU, 0xa198899a72a1899aU, 0x9a98976d808f7087U, 0x715a638566808871U, 0x7989abb5a795ce83U, 0x7e948cad8a6f6e60U, 0x70ad9e9579676675U, 0x8ca38c848b75898eU, 0x6c81947a768b7672U, 0x848299a18d7e817dU, 0x4e8c3c92957195a1U, 0x8460af5ea15a747aU, 0x89749f93a0759b7eU, 0x859973797c9c6c7aU, 0x6b9269a88da47d6eU, 0x7f5d7e716f8da19bU, 0x8a73c9838f8aa35fU, 0x547a6b9464c26c7dU, 0x74b04b8d62a2728aU, 0x8d6778659a906691U, 0xa980a65c85558c8bU, 0x9396a86492925a71U, 0x7e529c3b646b8576U, 0x7a7d9d8d7154a3b0U, 0x8c929f9968a59765U, 0x848e8a8caa9da19bU, 0x70549c927aae7189U, 0xbd72609769a19d79U, 0xa2778b6f89836a8bU, 0xbb8285a5997b8585U, 0x7f8dc2827eca9e9dU, 0x7e5b8378a69d76b7U, 0x738fa9a4b58c8370U, 0x417b44638fb68c6bU, 0xc1c9b48a7a757e8eU, 0x75889758755e5b4cU, 0x7a99666a8cb07a7fU, 0x7992739b74738b74U, 0x89806c928a8a9b6fU, 0x76b567c191899172U, 0x6cdd4b5d7f8aab86U, 0x758d9783699c9a76U, 0x5c8b887c93ab9064U, 0x9b685b7b9c8d879fU, 0x78a0915e97857d7fU, 0x836b78a28f9694a6U, 0x9dd93c7983918354U, 0x8fa48292788e7986U, 0x799c86986374876eU, 0x7864a1958d778191U, 0x837071877b768f6fU, 0x624c81726f9a797aU, 0x654e9fd57c918ac1U, 0x799a75b5685e9c63U, 0x755aae8f87a072a3U, 0x987389779b7881b3U, 0x8978869388b0815fU, 0x80a38176ba6e6970U, 0xa4a28a268d7b657fU, 0x7d6b748e939e8a92U, 0x816267b29e878771U, 0x88957979836d8a77U, 0x808d717c84806f8dU, 0xae737aa25b707875U, 0x6013afa972896296U, 0x7e88686296b5ad8dU, 0x83877094a4958064U, 0x997a998ea68d7f9aU, 0x647f9289846a7e83U, 0x4ba69b906fa38e84U, 0x897bc132a3828a9eU, 0x6987a365a39b8a91U, 0x73916a8a6e75a48eU, 0x6f7e7ca26673989bU, 0xab84957e7a7d809fU, 0xa4a2b38687948374U, 0xc88a7baf969eaf92U, 0x8a83bbc674a07c85U, 0x5e7762a2a072a457U, 0x7293a48bb0918bc1U, 0xa9ba5c7171818f99U, 0x7bb67b4a72649a93U, 0x8ea7b7d5826a6ea7U, 0x9a7088977ab27c5cU, 0xa9789b996f71826eU, 0x6a936e7c796e7a60U, 0x7c776ca4a993848eU, 0x778c72b6a97e8e6eU, 0x9d91455598699874U, 0x798861847d9c7c9aU, 0x64877c834a9b65a3U, 0x62938a865e82979aU, 0x7f5b9b866c508d96U, 0x5f91739da27f6e60U, 0x6e84398c749b8966U, 0x75809b9bab61aea2U, 0x7e65776f6a836a6aU, 0x8b929a7a8299798aU, 0x7a5a6192939a6f6bU, 0x564f60846b798594U, 0x6988a4929287a986U, 0x98ac717b62965e73U, 0x778f5a73947ea195U, 0x7e8680926ab28961U, 0x8876838f6e6589b1U, 0x82819ba19169826bU, 0x726c417d8b8c9f91U, 0x799d9f76b692a2a3U, 0x81938e6d826f6c62U, 0x60b49e75737d8a7eU, 0x6e7d5c867e7d6f8fU, 0xa23c7d62637d919dU, 0xa37a8f4764a06788U, 0x976bbb569b586e9cU, 0x7c7b90b79784796fU, 0xad6c9a616f758f7aU, 0x60886c8060af7d8cU, 0xa38b6a61977888a4U, 0x788cd0d1806c75a4U, 0x70b27c86aeb28f9cU, 0x767b9e88777e61a6U, 0x7893877c659394adU, 0x8b81929ca2756f74U, 0xa4b4c7cb75767e8eU, 0x8f3e4251717a6dbcU, 0x7495a58697647c80U, 0x9874809a7fb9937eU, 0x789791868f789690U, 0x7c9e8f86869f837fU, 0x887b638b9970829aU, 0x517367c979938660U, 0x949d8d63749cc280U, 0xa082918498709d74U, 0x96575e776ba59b6eU, 0x70867d8470979375U, 0x8c9f84b58c8984adU, 0xb2af3c6274b1998dU, 0x7ba57e839085ad71U, 0x627f9c9e94745892U, 0x8b7da4708871679aU, 0x7a84a98c85a46e8bU, 0x70939e67918283a3U, 0x8c6654c87f72a15eU, 0x7682659767744497U, 0xa554688275637f73U, 0x8d44736b937b8574U, 0x83816f9a6f955f87U, 0x94a5a28e9869a86bU, 0x7aaf55aa759c4e62U, 0x936e65688674a0a5U, 0x64a3c89b568e818bU, 0x7396a889b378a29bU, 0xa6885b9764a36983U, 0x7fa2a7b76988b077U, 0xa043aaa78f88417fU, 0x84a4a09d91b0ba7aU, 0xcb72b4be729890a4U, 0x8b5e8279895d7e73U, 0x7170af778d73736dU, 0xa46070a965a57d8bU, 0x83c3334e7c7a8678U, 0x679ad5989584a4a5U, 0x816f99ba8c94627bU, 0x9d7680877488937dU, 0x899f7d5cad838392U, 0x8ca78f70759d719eU, 0xa1cc85ca8c746a78U, 0x8f5a7e7c8cbf6468U, 0x6e7e7c9271b686a2U, 0x83979a7b81a66c6dU, 0x738aaa9aa27b859bU, 0x6d448551a3766c62U, 0x676eab546082b378U, 0x8296a38f93796e76U, 0x9974578ba0678e79U, 0x916a61986d769894U, 0x938683a0868f9a70U, 0x7a8cbabc82887683U, 0x3844b2a67e76ae7fU, 0xa778a3bf9770a26fU, 0x917d818484ab92a4U, 0x9789687c7d66698fU, 0x6d99746e6c9a6c6cU, 0x9ba780776e6d7493U, 0x8595a352968c83b3U, 0x6b7f7783796c6a7aU, 0x6d9688bd9258a96dU, 0xae736a8b977b6fadU, 0x909b9f8f5f959489U, 0x82926e8e64a5716dU, 0xa9b5699784aa7a70U, 0x83706b796e778163U, 0xbf946165a0958d45U, 0x8d796e91b18e88bdU, 0x45997b8288829d7dU, 0x62738e789b668dacU, 0x5b79aaa27a7ca97dU, 0x789d8f7eb69a8e6aU, 0x977a9f519a97b07bU, 0x9e859c8e7a5a8fa3U, 0x79719d7e817a7c74U, 0x81958752607ca360U, 0xb66cbe78848b587bU, 0x80947f767f757d8aU, 0x5c8a898b814b6c6fU, 0x9f73805b8f937680U, 0x8a748f8681998b7aU, 0xaab67cbc6e7d8d53U, 0x8ba12a838785659eU, 0x8d7c8c8e74966272U, 0x947a9b80ab6a6f7bU, 0xa88fa0878da9759eU, 0xac9b6a91a5a2aa6eU, 0x7291899492908180U, 0xcc404c8580848c5cU, 0xa78093787a8fa06eU, 0x828586696846a698U, 0x7981819578679e8bU, 0x797c6c928f7a9a85U, 0x827a69595ea07e8bU, 0x61548b538c5bbf78U, 0xac808166a26a8a61U, 0x917986b6a889a773U, 0x737d9d769389a086U, 0x896a93707d8e5d83U, 0x7c859c72709c9b89U, 0x5f0e94b57c898a8aU, 0x6ab46989556c6160U, 0x997373888e5d878cU, 0x817483746c8e867aU, 0xa6708a8e8b9f8879U, 0x6bb1879a71ac8483U, 0x4c6fa2dd65888a70U, 0x77a2b85f91925666U, 0x8582626fa89177a4U, 0x917d7d88717f7b55U, 0x5d8d5587909c6a8aU, 0xaa5963706e85a0a1U, 0x4a94427b7c835c63U, 0x5f7b559a9d95928aU, 0x799d9b9947876bb2U, 0x743d709e736e6f77U, 0x7f997d548d6dad90U, 0x818f8a7cc168726dU, 0x8f2147c89191957bU, 0x8e96706b9aa8ad7bU, 0x749282996d5f8e6bU, 0x647d75988aaa8e9cU, 0x816b848d797b878aU, 0x3e9b9c54947e8674U, 0x558ec9987e7195a1U, 0x6573a27b747e7469U, 0x7064798482a08a62U, 0x7c8e6e7f8e99a08fU, 0x718a54878ead8d93U, 0x6a96656f858c998eU, 0xc8d8d0946a787f5bU, 0x7c799f9199767265U, 0x98a0745d90536ed2U, 0x8282778faea07f8bU, 0x7481997e60a99899U, 0x6ca06ead6c60a36dU, 0x5d8c9d8f99a36980U, 0x9a5f7689a573a173U, 0x6a7985a399918b4fU, 0x829a6e71698c9b7dU, 0x7d618d9c99a6a394U, 0x749c899e8d779d88U, 0x76ec3f907d938a97U, 0x878683646c64609aU, 0x7f7c7a97484b9299U, 0x86947e8f79867791U, 0x8f97697e969c957eU, 0x546f776e968b6379U, 0x678e5a9461a2a376U, 0x81ac9a63b2907977U, 0x93bc4eb0ab8f8d8eU, 0x7b9b9761978fb064U, 0x8b9c7c9e90757e6bU, 0x9b5e9ea85c806587U, 0x795c63695d8e8f9bU, 0x89836f9b80975e7eU, 0xa27578a355a37b9aU, 0x6ca192a4b0699c7fU, 0x9169849d64979580U, 0x8d72659da47c524bU, 0x4e496291a8956a9aU, 0xb3939ab676583b9cU, 0x6d778d8f966c8089U, 0x956da26c98817a7aU, 0x739b80a3908e909eU, 0x63788064909e9482U, 0xbbc75359706c8f8aU, 0x838364658765a679U, 0x9a78966fc0ba8085U, 0x8c93966380688846U, 0x8d8e7ea9569e9d6eU, 0x6d829bd38d667bb5U, 0x7d564d7480877980U, 0x617d58593f8a768aU, 0x7e918487afcb8c90U, 0x87a1898096737193U, 0xa4869a76857d7797U, 0x738e7a9170938367U, 0xc59ba7c5648db283U, 0x80c1819272b46196U, 0x839a589953948d81U, 0x9475816093829e77U, 0x94869f8ea3438c8cU, 0x6788a85d8d8392a0U, 0x7087b5ae93796189U, 0x847e9cbf6d70858bU, 0x867b617a86b0866eU, 0x89a75a8a9fa68175U, 0x868fa6768f6f9f7bU, 0x936487a17c858874U, 0x9876a79e6ba48a8eU, 0xa2919d5ea26da79eU, 0x9782649aaa669259U, 0x9c945b84a292bf7fU, 0x67928266a0929b8eU, 0x898d649a877069a1U, 0xb16d854972755fa4U, 0xa8a0aa5b8d698f6fU, 0x56575b869e6ea985U, 0x97898a74ab798c83U, 0x8a707eaa83979691U, 0x76775b536f936e82U, 0x4562cc6e8573b590U, 0xb496785a9f9e6c9cU, 0x90a07a6a979b7d83U, 0x6b7f839a849a8477U, 0x778d6e889084a87eU, 0x8a6d958d8a6b796eU, 0x6db7a0627caeb367U, 0x976781a9c0b17a7aU, 0x73859d84778f998dU, 0x6d48a4739071928bU, 0xaf985da29e88be8dU, 0x84b06f60a4766c5aU, 0xae829e8067a54a6eU, 0xb56d6ca569a56877U, 0x93a7889e69b8629cU, 0x9c879fbc5b87988aU, 0x8956aa739854798dU, 0x8d732676a49f894fU, 0x8b9237839b9b5aa6U, 0x935fa3a0bb7e9290U, 0x597896885c877f86U, 0x7b8992778c7b8e92U, 0x76718679837d728eU, 0x8faf84827899a38cU, 0x5178b17f627ea86cU, 0x936a8a577a74b176U, 0x89759f8e99919e94U, 0x788a867e8b63ae5aU, 0x8685686b646d9d8fU, 0xbc8b4c51888d788cU, 0x5d717dca96818c62U, 0x35976ca18490809aU, 0xb36e60a76c74917bU, 0x946a796e859ea792U, 0x6e76b970999d7079U, 0x9e0049a46aa57991U, 0x578a8294ac625383U, 0x7a687781a14b7c70U, 0x8d877d7eb79c7e48U, 0x865f8e6d8d937870U, 0x978c9f636c656b6dU, 0x8e4f916f757f8d91U, 0x7298509c688b8aaaU, 0x8f8867857981567aU, 0x878a9e6656a09674U, 0x987f677a7ba08e6bU, 0x88689c736c978e5eU, 0x6287caa59b66984dU, 0x881e4d49cc727073U, 0x9a82807d8696778bU, 0xa0726f8a95a0aa83U, 0x85998891907d938aU, 0x9e7c9f7d6d9f9476U, 0x63928b5474606b87U, 0x38ee61b2738f7a93U, 0x667672775d8e8495U, 0x717a74a56eb27f7dU, 0x7368648064b29268U, 0x958479807a7da180U, 0xb7a230af7a7a8579U, 0x775660a989a0957eU, 0x68b08e936cc06781U, 0x6f748c70b483a678U, 0x5da59b7b9c7a9392U, 0x5c93959882698d82U, 0xa48f6fb7888ba57eU, 0xd0de65748d7988acU, 0x9b747a84a3877c6aU, 0x8d7b7f67837f99baU, 0x6c798a81c0936d89U, 0x898c838e88918d93U, 0xce9d9d6c7e958392U, 0x7b0cc4738a9a6f65U, 0x7e779b91a9879d95U, 0xb97c6b8a9072ba84U, 0x78948b8f7771a978U, 0x7c837960616c8c9eU, 0x60a6799c8881a06fU, 0x6a885c6b7580bc93U, 0x566eabaf697961aaU, 0x79818a796c9b9573U, 0x787a80707a9290adU, 0x817bac79718872a0U, 0x9f739341985a656cU, 0xba41b77ca2867a9aU, 0xa96b68a18da0747cU, 0x826b6e797fb5a665U, 0x7f988d6ba6976e88U, 0x749f79956a69a6a9U, 0xb87c72549f66948eU, 0x8385858a9a89a18eU, 0x7aa190a382949e7cU, 0x757f7fa2b39c9f58U, 0x71867d91758ca681U, 0x8e7e79918e7f6e63U, 0x79699aa1739f8482U, 0x61f093779675585bU, 0x59637c969c99817dU, 0x92965e735f857167U, 0x5a907ca18793797fU, 0x6964c37f756b8f73U, 0x7ba58fada4899480U, 0xa278a47c9c957997U, 0xa383858d6a84a2aaU, 0xa4727384b55e6386U, 0x9f6379a2926e7d8dU, 0x64a39f595c549d6bU, 0xbe9090c08c5c7ea7U, 0x6ab159997a7aa86eU, 0x6e9e4369a2a09dacU, 0x8d968da2ae709985U, 0x809ca78a867e9ab6U, 0xa07c799197718781U, 0xa578ba53586aa167U, 0x7f446abc9a89b98bU, 0x6b8b8970715671b5U, 0x8588917bb3638c67U, 0x8f81907f5d929184U, 0x74767d8d85949999U, 0x49b06fa48a6c6e92U, 0x71a87a45af82a9a7U, 0x8e938aa8a5777e76U, 0x8a948599a182867bU, 0x844961968d62939fU, 0x6d82906b95976b9fU, 0xa1b99cb38fa6659cU, 0x94a96e6b8dac6f9eU, 0xa07e88997ec1799dU, 0x7277729c85a9847eU, 0xb4a37f996c6ca29bU, 0x5da377b2969b6884U, 0x865e776c6893a191U, 0x956eae7c8085917aU, 0x759eae5ba6649496U, 0x7a8b7e6579726199U, 0x7f6c649f9d9a7b9dU, 0x6089936764b0779fU, 0x69768a768b6d7b9fU, 0x768834a8707fa687U, 0x90859f8783b6615fU, 0x6571889588b183bfU, 0x7d7c9a7a66646c88U, 0x8275655d91806b9aU, 0x8891e052a778657aU, 0x8c4bb65796a28562U, 0x6e4db5a08a609599U, 0x8d7d8d9d74697e6fU, 0x86857f7a748a9a7fU, 0xa96c5aa07f7a6c71U, 0x46a2949b65849c78U, 0xa5839a6557a973a7U, 0x78ab9a91a1777665U, 0x8eab676a55aea9bdU, 0x749e8b815d5270a0U, 0x9b8e7d8a72719d9dU, 0x8f86685c6795aa91U, 0x84d0974f60728f90U, 0x8e8e686caaa0a698U, 0x868db19277927169U, 0x738a976b8a648a67U, 0x837b768281977b90U, 0x6f53756c6d8a74b3U, 0x4b7e6792a3887786U, 0x677881536048b290U, 0x5f8ba0aa716c9398U, 0x70b0777da5739ba7U, 0x8968689b917b7b74U, 0x319973a4a5657682U, 0xa7cd7391998f7b83U, 0x7d7cb264765f9455U, 0x42928a838b899562U, 0x8482869b896f9b8bU, 0x819f8b7e81987992U, 0x7a4b87a17c929488U, 0x8d5e7f746a9aaf89U, 0x6bb9b16a98919095U, 0x999197859479c098U, 0x66897e80729b749cU, 0x719b89a19483716bU, 0x97af798da269a374U, 0x609b7f69a18ca2a9U, 0x71636cb1a561ae7dU, 0x697985736ea27297U, 0x9e8570a16e868474U, 0x916ac17275a29282U, 0x6189a080946e85a4U, 0x8c8d499c88ab787aU, 0x93696ca6a29176a4U, 0x4e82826a7c87a680U, 0x8c5f866f98919981U, 0x7772ba8fb068b9a4U, 0x72be8a698378635aU, 0x5b98914a7b836fb7U, 0x796a74908d7b81a2U, 0x778c7f9a967d9672U, 0x70c8aa91a27564b0U, 0x8a729b5db288ae6bU, 0x83a87880a1895765U, 0x8172c8d9a59fab87U, 0x7f7f6ca35cbb9073U, 0x7474bb77ad688971U, 0x827d94729a769195U, 0x85857c7c86a0ae90U, 0x69c270a48e927a7cU, 0x6fc46c985767b63dU, 0x63947b976b999897U, 0x688d717c4a745165U, 0x744f838e7d7d7185U, 0x7d8cb0746e8a63a2U, 0x49a59498b06c6271U, 0xefb788a86c966c58U, 0x8376b58c646bc09bU, 0x6b6f7fa16088837eU, 0x838b79816f7e7068U, 0x969562a3608f8857U, 0xb1a98477726691a0U, 0xa28d62237e6e715dU, 0x8f7d6fada1a55d7eU, 0xaaa178a555c7a9b6U, 0x94827f765ca58aa6U, 0x9b8aa47066677a9aU, 0x9f4e87be6e82968eU, 0x7779b19b669b739aU, 0x94737fa07687b76cU, 0x888e7e658881779fU, 0xa55e88817cad9772U, 0x6265616f918d787bU, 0x6baec1726e806f7bU, 0x735dbd42a38e8770U, 0x7a8d908fac6b7977U, 0x689981986f6fa871U, 0x73869383a09677abU, 0x68797c7b688f6c85U, 0x52a9876662615672U, 0x7f6b9d487aa66257U, 0x9575a8858e3c94acU, 0x756f5e857b936b76U, 0x6f88937f68817e5fU, 0x779d6c7f639d6080U, 0x989b757880648888U, 0xa4b7a6a9a3766993U, 0x89aba4735667a2b8U, 0xbb9a7990b28e6c4eU, 0x97756f9f6fa17c61U, 0x5d767ca4757d9358U, 0x6893b68d55938081U, 0xbf5782b5858c6381U, 0x4e85798699a39956U, 0x758887678486b252U, 0x867a8d5c90908470U, 0x816e857687617d8eU, 0xb0509953767865a0U, 0x9b5f9d58888e8257U, 0x7d6c80867da78290U, 0x906f8e6e487f89b1U, 0x978d92758e9a876dU, 0x7497a35776409c7aU, 0x7c607b48c75b7759U, 0x928eb29499ac6f66U, 0x6c73745f85678c62U, 0x5e6f89a2706a6c62U, 0x84735e9e7aa39074U, 0x8788746b9c997861U, 0x866b979f5da26890U, 0x9f7d599ca47b865eU, 0x968d6fa0549e7a78U, 0x867a859b62a35d67U, 0x9ab0955e81968b7bU, 0x9d84885b7082a28aU, 0x94489691779c888cU, 0x7a32b0839d894576U, 0xa67585897f708680U, 0x917a9baca282ad4aU, 0x817a7f909e91776cU, 0x6d8e86768b776671U, 0x98ac737f86a59f88U, 0x417ba3b986819697U, 0x8d88795d6f7a715cU, 0x586665637b7d8f68U, 0x783c7c9c83af8d6dU, 0x9c696f7684a25a7bU, 0x989b59ad7c9d7a8cU, 0xc24f7cb4847a8f9eU, 0x7d975789a29c6d78U, 0x7e7d9a7f76b39ca1U, 0x8686808877907793U, 0x7c89a995787c8c78U, 0x989b9660b2737d8eU, 0xa594d2a76a8a6eb0U, 0xa162868160aa8989U, 0x758e73a08c7c65b0U, 0x8a8f9b968f8c76a2U, 0x7ba28e76aaa88765U, 0x3f98bb706d808c8cU, 0x7c99b18e796d877dU, 0x859365baa891ac73U, 0xb76fab7573a2b37cU, 0x7c957572ae96836cU, 0x8ca6b96d9d7a9d81U, 0xa6827d8989909f74U, 0xc52ccda38f7f548eU, 0x967e86698d8198a4U, 0x8366738b9a686f67U, 0x889d8f756086746aU, 0x929e7c8f9f998d8dU, 0x8a69a6a48b96a085U, 0x4d7b95948b94aa79U, 0x66a281c1745c50a2U, 0x6e8b649a7da17b68U, 0x80a09a7b726f8e75U, 0x958fac97988f8d7dU, 0x5660a68a8a7b786cU, 0xb48a61839880af91U, 0x8f798a718a8560a1U, 0x6182987388874d6eU, 0x6fc6818471888fa1U, 0x8aaf6798966a939cU, 0xa65c85aa93a861a2U, 0x74875998577ea9a3U, 0x9b5c837a78465da2U, 0x98888c817c99987aU, 0x9a998b7d767c8479U, 0xa9926b7ea3899070U, 0x967f5caf798f8878U, 0xa0ff573f5a8a757aU, 0x829b7ea982939067U, 0x9c807b82b07c9a82U, 0x71809b8460618a9aU, 0x868d8b6d6f9c7288U, 0x8c7b628a8d8091a5U, 0xe0c3bbb4878c5781U, 0x8278866092a19a7dU, 0x887764749f59a69dU, 0x978a8784a0867e7bU, 0x758a6d79a695628dU, 0xc3a472b969738487U, 0x535961966d787d58U, 0xaf79785f8ab9ac91U, 0x99958c72748b63a1U, 0x777b947da2a26640U, 0x9981bb7f81866b6dU, 0x4e769982878e7d77U, 0x7bcdce856895785dU, 0x3c557a8952b5807bU, 0x787b7c75898f7e4eU, 0xa68f769f9c60809cU, 0x857b757c87759f83U, 0x8da1b689838c9b6bU, 0x7ab62961a765917cU, 0x93886da394867c96U, 0x87869e8dbecc7b8cU, 0x7668a9807e8c8d8cU, 0x8e747d837f7e8788U, 0x7b6db5799898657cU, 0x75b4957b669f94b5U, 0x5b78635b8f6f36b5U, 0x8c526879a27c8194U, 0xa99b86987c6090a5U, 0x7080a1868ca46583U, 0x83854dca77947683U, 0xc7e87a96ba7d6e6cU, 0x6c7a4f838077c0adU, 0x7177897d95737e5aU, 0x8197978278ae8f68U, 0x8b9f7a9084a37f85U, 0x808f67a489767b5fU, 0x3ab3768c74749d81U, 0xa0ab8a9c8967817cU, 0x8b808a9c87438594U, 0x868e8665898d9f93U, 0x65868a806d718275U, 0x88918b9c7b8098acU, 0x5fa29678a89f99abU, 0x578b7484bbb06757U, 0xa299b07a816a6a94U, 0x5c9a639f9da96e7aU, 0x9d887e6d7896a774U, 0x8d6da4ad5c649485U, 0x6b9ab8907a7dbf8cU, 0xb14a895ea768c183U, 0x8b7a8762aa788364U, 0x877373718ea1947fU, 0x858e6da6606d996fU, 0x8e75863b8d7fa681U, 0x4dcc8f9f8c818268U, 0x47768a81864d516dU, 0x7d7b849b6b866e63U, 0x8b8898816e7a8b70U, 0x898171816c917e89U, 0x857bb47b839f829eU, 0x9dbba1a48291a75bU, 0x2d998f7e91be933cU, 0xb1899e9a645b812cU, 0x856476738e65856eU, 0x7c99a0928b6da58fU, 0x88b55c9d827596a4U, 0x7a9ab89d7a9963b0U, 0x5d9c8871857f7995U, 0x8a6b5d8c9a76857bU, 0xa1606b6872a97da6U, 0x61a291868d666c99U, 0x5c99b57467985f9aU, 0x807947996e958496U, 0x9a6869616b7c5a64U, 0x809870726e7c95aeU, 0x9aa16f9a87658b90U, 0x656680887b837b91U, 0x83b2726f5a8e8f7dU, 0x6b9a738493a154a4U, 0xa07a7f859250a96fU, 0x8988a47fa7609357U, 0x97839f955f7f8a9bU, 0x717e696d64ae6e7fU, 0x8599a0b68aa5917cU, 0xc775ca4f7a915980U, 0xaa72948c937c5d95U, 0x97878e7ea4a68195U, 0x8072937c858e8279U, 0x7a83837e8ca18e98U, 0x7d6481a98f736690U, 0x8c8d5741887c929bU, 0x75a7907a90789a74U, 0x8287997196938f84U, 0x70697495838daa6bU, 0x6c9067798f9ba55fU, 0xaaa85a509b5da38dU, 0x958c9f18816e969dU, 0xa1639471637d9591U, 0x77868e767aa75b5aU, 0x7b9a92615e9b72a6U, 0x9a6a8b748a9b7b91U, 0x65747d8c726ca6aaU, 0x70822e9367869683U, 0x567d8f9f7494568bU, 0x66805e74548b84b1U, 0xa06295b0a48e7c67U, 0x64558b889a5c7878U, 0x9695a7cc8584818cU, 0x89b471799077936eU, 0x9a95b69c844a6a6eU, 0x958fa8639f8e978aU, 0x6d7b5a8a95a18e91U, 0x948c7a8e728e867dU, 0xb7836a5c8c697964U, 0x825e93919a759a9bU, 0x738578bd6bc55695U, 0x7f8364a7569b6fb1U, 0x6f9b729ca1a36790U, 0x7683d175a972a371U, 0x648367768b6b7177U, 0x97b9465d9b5d6294U, 0x6e886d558a78896bU, 0x987e9b5f9b83668bU, 0x716d907d8770808cU, 0xac6da29a7090606bU, 0x745c6959688c7183U, 0xa798b2654e5f7a8fU, 0x6d788980975e9f7dU, 0x9f62857ca5678772U, 0x8896996c69687b72U, 0x86746c9896bc758aU, 0x757d876f598d7877U, 0x7a99c56daf716876U, 0xa1939667a6705997U, 0x83918f8574619a91U, 0x9f97747d92909b83U, 0x82625f85a57e9573U, 0x926f96bb8e9b729bU, 0x8acd3b9976708e90U, 0x767e608b628b9887U, 0x6b9c8c92bb89926dU, 0x8991a57a9b8f7986U, 0x76867d7073749275U, 0xb19d7eac7564898eU, 0x757939c67c778164U, 0xa5955f8b8f7e8778U, 0xa588617bb26e8a76U, 0x94a480988f8f7479U, 0x868899736e7d9d9dU, 0x5a6950716fa67a8bU, 0xa1dc8361a381688aU, 0x9f609496c2486a6fU, 0x836257717b887b6dU, 0x8f8376706c629b7dU, 0x799985836b786384U, 0x93b5908f66878b81U, 0x39b58e78817dbda2U, 0x8c4a62b370cab86aU, 0x5e9db172aaa87766U, 0x548c99806e9b6d88U, 0xa188a39a736b7d86U, 0x7363a0cb916d918fU, 0x6c354f50667f72adU, 0x675b84a0b1a6b498U, 0x9784848c7d8b8184U, 0x708f858277989492U, 0x8c8a638d887ba379U, 0x8b6eab6d7e6d857eU, 0xa299b66da1af5f8eU, 0x94789c7a72a69598U, 0x969a938e9f8f9371U, 0x618198738e658660U, 0x9a8e8e968567819dU, 0xaab17e7f9d9b979aU, 0x8c7f74bdab695e70U, 0x5d797d83716c728fU, 0x83a46697b4747da9U, 0x878a8a9a517e82a7U, 0x6f6f5395905d7976U, 0x5ca33ead5c849783U, 0x7cba99848e96bc70U, 0xb353a3a3bc7b7187U, 0x8b6dab89a66f93a7U, 0xa99a6274b5a37d90U, 0x8167a0a66b817e8aU, 0xaa83c2709170689cU, 0xb83a7481858dbb88U, 0x5d956a83a55e6eafU, 0x757b6b90a0807065U, 0x967f9b85a1ae736aU, 0x7c90a08777999d7cU, 0x9d5f99777a676181U, 0x84a0b7779272c27aU, 0xa592829c669da55cU, 0xa77b6692a1747a79U, 0x969d889995738f86U, 0x8767967f61867d7bU, 0x9fb9a57472a29b8dU, 0x6b7c654e6e6ea58fU, 0x569e8574a77e989cU, 0x7f76837b7d6a90acU, 0x83b388ab5b8b95b6U, 0xa89878867e9b988aU, 0xb26680ae9faaae71U, 0x7a705eb1778f506bU, 0x5a7d9a697f985b93U, 0x849b717f89a4a46bU, 0x8482b98491b49772U, 0x6e646f917672717dU, 0xc7aaab8d817f698cU, 0x9958545b846b738cU, 0x85604ca5827d6b82U, 0x81928d91919e8777U, 0x737daf9363a371a6U, 0x967a9f7da2806992U, 0x7169749b7c9f6e70U, 0x797fa2bb7faa9784U, 0x78a1758f9b929890U, 0x6387a5737c9ba9a9U, 0x6480959d68686f6aU, 0x768d6b73848898abU, 0x684567bb8c7e924fU, 0x5d973eac90a67471U, 0x6eb4a488c17f8997U, 0x677c828861aea685U, 0x7f897f7e84857266U, 0xa977948a8d7c8f84U, 0x9a899982ae817188U, 0xa9934d7276835b9fU, 0x917c6954995d8969U, 0x8a9374638e6b8a5bU, 0x90758a8f9ba699b2U, 0x54868f959284987eU, 0x8b84bec36b7869adU, 0x64803b7f7c797574U, 0x5b77766b86746882U, 0x6c92738ec0bb68a9U, 0x8c5f8c8b769b839dU, 0x786e987595768078U, 0x9e4ca266628a9d6fU, 0x8496737da3987697U, 0x8f62642e8f8d3e95U, 0x7b63ae89769b678dU, 0x9e7b647fb3708a66U, 0x9380875f77908972U, 0x8c60828a7c5c658cU, 0xa1ccb45673a88086U, 0xb48f5c995d8bb19fU, 0x847e949da77e936fU, 0x7da095916f8f7ab3U, 0x886e6c53a172617eU, 0x748b576e7c9a6f88U, 0x7dfabbaa8076b971U, 0x7782a2b57b87ab88U, 0x7d888f7d577676afU, 0x6c58819c809f728fU, 0x8e7f649071746884U, 0x794b5b74a6885d67U, 0x90aa9f516b718299U, 0x899085968f7e9d90U, 0x68736d8d5aa38a9dU, 0x5777a9929d5c8293U, 0x72709f8897a0a287U, 0xad8955aeb0986f5dU, 0xc39664d77f6c608fU, 0x5a5e638587a36a8aU, 0x839da56c63517582U, 0x8dae96605c767e9bU, 0x7763a5728e6da38dU, 0xca97a5aca38e7565U, 0x31779272aa8ca948U, 0x77c29596a5ab9f71U, 0x79b875459baf5d61U, 0xa5919a807e828066U, 0x8c93888b83b2878aU, 0x47863f9b5a95698bU, 0x3ec1907395a8a19eU, 0x6e7ca6b07e545b79U, 0x7c936d6f90738eaeU, 0x6d628e745da77a9aU, 0x9e69888785777271U, 0xba76ce5987959f7dU, 0x6c47ca91707981aaU, 0x8193718d8f9f9277U, 0x82a5a6747e8fa15fU, 0x617d9b926c9597adU, 0x85878768798b8298U, 0xa4a53f46a2965d7fU, 0x5f8dc98d7a838893U, 0xb59a7061af7c66a8U, 0x708679707a6e77b0U, 0x9ba39d8968777387U, 0x8fa9a58fad818e94U, 0x6e9a514e7483a99aU, 0x8edbb21890908561U, 0x74ae70616c5d4e85U, 0x87897f6b9e96915fU, 0x85a98c7464815f9aU, 0x8e8b957175828e9bU, 0x7a73ac65896ea085U, 0xa18743d29281b684U, 0x90a2877fa4b8aa6cU, 0x9b8ab2805f65b38aU, 0x9b7f958c9c8d938bU, 0x959b998683947594U, 0x728354ad84948273U, 0xbb9c806568a5b59cU, 0x8b687a6e87916097U, 0x6d95c2805ba75f80U, 0x6fa79097bb938088U, 0x7d8c777a7f59a0a4U, 0x788a816f7d9f7094U, 0x6ba1c8388b9f677bU, 0x705d5d775da56672U, 0xa79d6175938a95a4U, 0x7a916b93989886a1U, 0x8b7f9d9989896a86U, 0xbeae44475e69944cU, 0x5ea1baaa96858070U, 0x72a68478715939a7U, 0x6a7ea1aa6fa6b7b7U, 0x88af888b9f8985a6U, 0x82786e79879b797fU, 0x5e9da74a7594918fU, 0x87b95d799b7b3c57U, 0x749b6b6181b8b68dU, 0x9365bd7e5a6f6673U, 0x8a9078908e5a865dU, 0x9789839e87798582U, 0x78636e47a46b96acU, 0xbc468a90827a7b97U, 0x5a7fa2a6c0695f5eU, 0x7c9fa2735b4b9279U, 0x635d5c717b977968U, 0x817aa57482649173U, 0xa5ae725f6e758b89U, 0x76c638837c6c90adU, 0x8a7ea48095929574U, 0x8f726d9e52558aa2U, 0x6da585908a788a60U, 0x86849a8591af8886U, 0xae8d74b7959c7489U, 0xa5394d7c9f96a27dU, 0xa98b64929e799dbcU, 0x6ba8b29b80808d77U, 0x9782a7a18aac9188U, 0x91977a707e8a7c99U, 0x65a79c5f8a94877cU, 0x9caf737b99a55c87U, 0x7988a1a87f898c67U, 0x7a8c8577a2a16b8fU, 0x6f6a7c8c81666d7cU, 0x888265648b478784U, 0x9363849698858a7dU, 0x7877697b9885b2aeU, 0x8d56ac7aaf745491U, 0x8c6b6e7b9d8d9664U, 0x8f9993819f7579a8U, 0x8fbb9f946976647fU, 0xa09e2d616491968cU, 0x61ed92768c9a5795U, 0x5da1976c75779299U, 0x9b9a9e8f627a994dU, 0x6764957e7d808f64U, 0x878a77956c546c6dU, 0x58ab68659f768685U, 0x7b928b7478969f76U, 0xac6b738b776ca9a4U, 0x84ae716893719cabU, 0x719aa68385955a8cU, 0x687e61aa70696f5fU, 0x7f9d9a7047a9adb3U, 0x9c423aa390958f83U, 0x8b69756f93b18f98U, 0x9a74975590619d76U, 0x8b8f7a888e636e70U, 0x6e9395669875909aU, 0x807a61808e90966dU, 0xa8adbc7f60696baaU, 0x6678805b9ca7b584U, 0x8fa97989958cae75U, 0x8d5b65a3a18d8172U, 0xa66b90a276926f75U, 0x40b169a9a0a07f81U, 0x9cda6890977a63b7U, 0x9c845f7a77778361U, 0x718e936874857485U, 0x8899a8a6964f947fU, 0x9965a88e95947f68U, 0xc59ca34a7f947c6fU, 0x9a57ae45799ba7bfU, 0x62865aaf50675e73U, 0xb082727095787861U, 0x896e988c6da183b2U, 0x77809f7d9a8a7686U, 0x7474af655e7e6da6U, 0x6a4743807b9da489U, 0xa88d957a9b6b8381U, 0x6f599c638e589c7bU, 0x8a62aa9095a8858aU, 0x66718b6b69888774U, 0x9073906881a26296U, 0xd0bfac859d9829a7U, 0x607d52668c966080U, 0x628d876cad629096U, 0x96764b9753995aa7U, 0xa08e8c6a8b928c6bU, 0x7c797da68486747fU, 0x8588399c958e6968U, 0x905d73616b609c9cU, 0x9a76a2a78482686bU, 0x8e99837c8470889bU, 0x70739a6470856d84U, 0x5ba0948b69729a7aU, 0xae816fb295935d5bU, 0x70a5a5838c7d8080U, 0x8391737da9666fa0U, 0x759e846e667d978cU, 0x7c5b84a6a0a455a1U, 0x9c6d7eb6799f93a2U, 0x9b76539262749d95U, 0x69a889795a8e7796U, 0x7d695f78a48d719eU, 0x90645e6f6da69c86U, 0xb4648097807d7385U, 0x7d7e92986194a88eU, 0x47913e889782b867U, 0x877771529c607186U, 0x959370aaa7539097U, 0x736c5d9679807465U, 0x7a93887d7f81769fU, 0x6978aaa578868677U, 0x937552b482855e59U, 0x83876c747c6e9b9dU, 0x636f6f8f5b73637fU, 0x966a7f8f69ae7ba4U, 0x7d6aa78b758d7e6bU, 0x9470b55a81947a91U, 0x5b5e868aa294b0a9U, 0x8f526b5c7371519aU, 0xaea095a164615a6bU, 0x5988908da28b6a6dU, 0x8d8d90746b5d857bU, 0x9587acb474a38f6fU, 0xc31b79ac8c955c8eU, 0x809a6f5c8a709a85U, 0x8f88817cb8ae9598U, 0x7b7094937472956eU, 0x9b8171897a956d8bU, 0x9c99c448878f706dU, 0xbc44b14473766083U, 0x75aa99a19a50563cU, 0x84707b6380627762U, 0x6a997e937682706cU, 0x7a9b966c938f7992U, 0xa47bbe9c9776b286U, 0xb08e628d7f74c584U, 0x93446d845e717393U, 0x83826095c1dc7a88U, 0x867d667e6b90915bU, 0x986485938c7f8774U, 0xc62e77949b7c8f66U, 0x4b8c8636799ca64fU, 0xa38c80906f6a678cU, 0x786f5ca1a7b68885U, 0x8a95937f7888877fU, 0x5f7e73879c85a3a0U, 0x8c7c84b36a7680a7U, 0x7c80724f9f97629bU, 0x916594a28faba49aU, 0x9f5d91a1a2688b7bU, 0x66927b7a826c9e7bU, 0x7e6f6b8c825b7ea7U, 0x59759fc1a2936a8aU, 0x519b659a77738bb1U, 0x7573adb376b78e99U, 0x7d9274754e549873U, 0x7554839c778b9b9aU, 0x958e9492818e6f92U, 0x8762a78287966e77U, 0x50d7d0817fa6825fU, 0x726e896b6b96aa9eU, 0x69a3897b81a1a77aU, 0x87859c715f7b938dU, 0x7c716c6780898b83U, 0x69a19380948a8b85U, 0xaa709d4e865c5b6eU, 0x88706d909b997879U, 0x6491628564996499U, 0x929871ae6882ab6bU, 0x897f7367a09d708fU, 0xacbaafa0ad987494U, 0x4f1841659d95ba89U, 0x80576b9e7d858c7aU, 0x5a8472a3a5b18174U, 0x847e5b716fb06c85U, 0x75778d808d97817eU, 0x7a94bba8877a9596U, 0x6c355b79656f7e7aU, 0x839a9ebf7a809f9dU, 0x8a7faf7d817d7c62U, 0x66686e648a9d799dU, 0x7a7c8b888974a09fU, 0x865da15ea8a897a2U, 0x897e8f5d95749a8fU, 0x67865e688382927aU, 0x696c939398556c5dU, 0x8193767485a87f82U, 0x9364a1695f5a9e97U, 0x5c93ab9b886f968fU, 0x8c6aa6809896738aU, 0xa27db273b8ab8986U, 0xa4876a6473818c92U, 0x77907aa297627c9aU, 0x9aa3978c88648179U, 0x9683927c59967b5bU, 0xdb4aa79d8372715fU, 0xa45c9bb28f999f71U, 0xa09495a765677da8U, 0x8a868179a4709a97U, 0x9b746f7779967a67U, 0x66b874ab866b9c9eU, 0xba75446ab5936465U, 0x9770719563a4805fU, 0x9891697db57d966eU, 0x6d845e759fa0868cU, 0x807f8f8a85828b5eU, 0x8d949b6c8574918fU, 0x9f7eaaaea394569cU, 0xa089a97aa2bc5d7fU, 0xa4967b6d808f5160U, 0x8d7aa46c82867455U, 0x9b8d71a36e8d6a6dU, 0x839c9f69a1986c5cU, 0xa19b8a718d7fb37cU, 0x8fa4b88c9ca19a8eU, 0x76828d70a5718c81U, 0x8183697b858e8d8bU, 0x83685f7671909670U, 0xb182805c56646168U, 0x7d8fcec576885f98U, 0x8681647fa593728bU, 0x8e84919495a57da9U, 0x96879b8b958e8f84U, 0x858291857a6e747cU, 0x60587b34679f7376U, 0x7271aa5a8491689bU, 0x9479615e879c7aa3U, 0xa3919f6d8d7d8291U, 0x8d715684a7a07e48U, 0x89739e83904c8b73U, 0x9dc381ba9aa6ae8bU, 0xb4af40ab7b705e7eU, 0x95a6848f86716c8bU, 0x9f5a7575708f995eU, 0x8593927f776d7d7eU, 0x789d736e8caa9d89U, 0x917a4b9c689265a6U, 0x794a3d868276a4b1U, 0x53a399a0828c8362U, 0x657f7badb89ca35dU, 0x9c6b90886f7b9294U, 0x9a7b707f88868d6aU, 0x7d9ab6786c8b8277U, 0x926bb9a49285828eU, 0x779c9c6c9f5fa2a7U, 0x8e75768f8c92abafU, 0x9a9177756e709279U, 0x6a649e737aa99c79U, 0x5e67ab757e6a7579U, 0x7d63669671945d61U, 0x9e73bdc39d685893U, 0x96949c7c8273847dU, 0x70a55572b1576c88U, 0x9f768e978d7b9666U, 0x9587a98686809971U, 0x79c1a8b7a3725083U, 0x7d9c7d8c74896b70U, 0x729eb2987d9993b2U, 0x9767778a6c917b88U, 0x78739a658f77798fU, 0x9d725dd09c975d6bU, 0x88a4374a7676816cU, 0x7d72978d648ea192U, 0x968598777d6e8a8bU, 0x8581749772aa6e81U, 0x968883909d7a6889U, 0x60776e9e6a99a15fU, 0xdf85b077767b37a4U, 0x9d6abac1a08e8752U, 0x939e8a7b8393ab7fU, 0x7e938489827a8684U, 0x88807d848770695dU, 0x518e71959f84757eU, 0x7bc843819b97a892U, 0xa77883945e7f7b9bU, 0x8976a695708a8871U, 0x7a895c819b60706fU, 0x859099a780799c8eU, 0xa0957c5daa738778U, 0x937d55a9969d8552U, 0x677db36ab478a290U, 0x6768518f93695386U, 0x9a82707e94ac9180U, 0x8085839860af5981U, 0x81839e57736b7885U, 0x9f76b2497e869b87U, 0x709e84947b7f96b1U, 0x628792a374717da9U, 0x8c89779287867c7fU, 0x9c97647d925b646dU, 0x6d97aec581849c5cU, 0x205379ad707a9eabU, 0x95ac88ae3b8592a9U, 0x6982b28d856e6eb1U, 0x8386629c7e81767dU, 0x776b8a70728c8b8fU, 0x627f649694748e6bU, 0x5c63a8739075b259U, 0xa38d629d638052c4U, 0x7e7c6c498e8ea499U, 0x55789b9d84907479U, 0x8a69a39081669881U, 0x7b856a797e9f7d7bU, 0x759e27cd91a18a84U, 0x637e78607899829dU, 0x8a7d7c5249635cb3U, 0x8d7f8c8058959582U, 0x85937a806b778e95U, 0x8b7a62918a65a56dU, 0xa75c2b9176655d97U, 0x61789d9da4619271U, 0x9182aa74737f996eU, 0x7d74666578948b60U, 0xa285569698ab8798U, 0x8c66817d707477acU, 0x7fa24da479906778U, 0x7f7dab6eb17e8b8fU, 0xad98ae79ac488866U, 0x9681976b8d6e9e4fU, 0x867d856581a59a8aU, 0x53a7a37a8094a883U, 0xb45e3c65757b796aU, 0x92685481918b7464U, 0x60997d977d885d76U, 0x767d6c9672856a77U, 0x9290a7769a838685U, 0xa3716ea39997946bU, 0xb5a2664f67813f80U, 0x8287998897877986U, 0x6c7f7c8480aa976dU, 0x78aa9395689b6e74U, 0x979b9f90675ea67fU, 0x776aaace916d9468U, 0x7c8f676978a88f60U, 0x4ab360919f9e60bbU, 0x96a55476518092a7U, 0x5f696fa589ae5195U, 0x8281944c96797da4U, 0x6d6f9677967e885dU, 0x96bd3d7e74a186a6U, 0x9c8f8198565da47dU, 0x6f88817fae8a6b9bU, 0x777b6aa2b0ac8490U, 0x817d737ba375816bU, 0x90794868798e906eU, 0x7ea9a0549b7b7c89U, 0x8f8462a379629f71U, 0x687b7575ab987187U, 0x8f7e85768a928cbbU, 0xa16f8a7b9c8a6285U, 0x68a9ab5c6971736cU, 0x786e948a8b67a591U, 0x556c7c948470b86eU, 0x846c756c82615d89U, 0xa57fa18e8a9c7c83U, 0xa47c6aa0729b6670U, 0x9888807b71aa8c7dU, 0xa13939979b90a580U, 0x97997b69799aa086U, 0x8084ba6aaca5ae60U, 0x919093688e937a8eU, 0x8b8b82887b9d745aU, 0x5827bf89776f7e95U, 0x7433a86290983664U, 0xafaa9cae90836980U, 0x6b8fa7846b848a74U, 0x9a9d6b7a7f669bbbU, 0x767f858e876a9983U, 0x8248889e847988b9U, 0xa370474982924779U, 0x776c7a9c728e606cU, 0x997d907cad7f67b2U, 0x5f5f8a93787a7ba8U, 0x8774a37077769c9dU, 0xbe45b2657281865aU, 0xbd4f09403e11ec0cU, 0x3dde29533dc58b50U, 0x3e2e56003e434df2U, 0xbd4711f43dd375a1U, 0x3e4db2ffbe365f8aU, 0x3e002dfdbe279a9cU, 0x3e239f083e1e2ec2U, 0x3e075d7d3bfd9b02U, 0x3e2674c5bddfafb9U, 0x3e087b3ebe2255e0U, 0x3deac0273e2256fcU, 0x3d4f9839bafb3f9fU, 0x3e2e80c73e0a2034U, 0xbd8ac7cabd5af015U, 0x3dc50ebbbd8c4ae2U, 0x3e202e053cdacf20U, 0x3e0012f33e00bd1cU, 0xbe1a0eda3e2b883aU, 0xbdd82d4dbd9e211eU, 0x3e45ef523dd85049U, 0x3db9d33cbe3b4762U, 0x3ddeb74c3d7b0cc1U, 0x3e0ecf8a3e4a601fU, 0xbdf3e0143e2f48d6U, 0x3d8dacfe3de6b82dU, 0xbe4f35debcf3d05fU, 0xbdfc44cf3cecf38eU, 0x3dc6f9fb3dba185eU, 0xbd3b9c89ba96faebU, 0xbe13e0773df69963U, 0x3ce173ba3ddbb3a0U, 0xbe4077183dddf7dcU, 0xbdf0a6293e03a36eU, 0xbe3796bf3e034b37U, 0x3d483d233d19d0eeU, 0x3d9ddb90be2c116bU, 0x3e14fbcf3cb745ceU, 0x3e12db46be043281U, 0xbe505d283e257514U, 0xbd860e5c3d1a0b97U, 0xbe05bdb13df92dc2U, 0x3e3e09fc3e19a0bdU, 0x3deb03f3bdb90902U, 0xbe09757b3e07afcdU, 0xbe034d553e08d555U, 0x3e0a2e263e13fd61U, 0xbe167d8e3dade8e8U, 0xbde18da8be12ec13U, 0xbdd96505bc0b5976U, 0x3e1829333da5fe96U, 0x3e09e90ebe078667U, 0xbe1aca0fbdf55515U, 0x3e1880d23e172de9U, 0x3de2b5e63e0050e7U, 0x3da9cd23bc1ff4d0U, 0xbdcfbf743c15ddf9U, 0x3e1d58ecbdab4d75U, 0x3e18c5b43e1786b6U, 0x3dfc4c663e1cd8f7U, 0xbde176233e16f4f0U, 0x3e100bcb3e318439U, 0x3dcc8a313e09b09fU, 0xbdff4c463e1a5688U, 0x3e08099b3e3449e1U, 0x3ddefab73e221126U, 0xbe3234513cc370c6U, 0x3e1465d63cfd6216U, 0xbe3700cabde3c671U, 0x3e085119bdaa5b7bU, 0xbd9ab5bd3dbc11f3U, 0x3bf8b8cebd945067U, 0x3d12bcb1bd29be9cU, 0xbe4520103e41219fU, 0x3e015f153de9b4f1U, 0xbc8170acbe3c5626U, 0xbe2777703dab1925U, 0xbe190e0e3df717c3U, 0x3e284ab93e25176eU, 0xbe1112b83cc4387eU, 0x3de215033e23797fU, 0x3e0b945c3e18f391U, 0xbd7523a7bd3eb754U, 0x3da1eb07be33801aU, 0x3e1ceaeebcea92bbU, 0x3dd5a2823de2c642U, 0x3da324adbe15687dU, 0xbde708573e18df65U, 0x3df0dbc7bc9522cbU, 0xbd1773963e03003eU, 0x3dda2c5cbcb7dc94U, 0xbe145c923d9e53baU, 0x3e10d4c03e3f4f33U, 0x3baf37c0be10e094U, 0xbd0802493d96460cU, 0xbdea6203bd8e5fddU, 0x3dcc2dfe3e36b0d9U, 0x3c31b8ba3db16f42U, 0xbdfeb9efbe1576f0U, 0x3e0f5d13bdfd4c1dU, 0xbe45b0c0be146983U, 0xbe1632923daeb628U, 0xbcd903c13d88f5a2U, 0xbdca38613dcaa20dU, 0xbc84105fbd361087U, 0x3e0e81f73e12cd78U, 0xbe0022653c7e6e49U, 0xbe1b11403dded6deU, 0xbdc3b15bba578c69U, 0x3e1d10ac3db8183bU, 0xbdc5ab87be2e9edaU, 0x3cf11cd53e20ffe7U, 0x3e24de91be1c63c3U, 0xbe12b9133e09234fU, 0x3e0ec3503d87a418U, 0x3d60ea3d3e04afb5U, 0x3df893c8bc9f9787U, 0x3df77362be173debU, 0x3e232be5bde4fd9bU, 0xbe3eb3543d3fa573U, 0x3d21f55a3dadcff5U, 0xbe1daef43e31a6feU, 0xbdaa11fdbcf78dbdU, 0x3e0bd4803e18b3baU, 0x3e17005cbd2e0afdU, 0xbdf185063d917a83U, 0x3de51abf3e07d8f1U, 0x3d6a6241be0ad0f9U, 0xbeae78503e129e0fU, 0xbeabf323bead51ddU, 0xbea935b0beaa946aU, 0xbea6783ebea835d2U, 0xbea3bacbbea51984U, 0xbea0fd58bea25c11U, 0xbe9ddbe3be9f9e9eU, 0xbe9b8272be9ce12cU, 0xbe98c4ffbe9a26d8U, 0xbe9674e4be96e55eU, 0xbe934a1abe94a8d3U, 0xbe904654be91eb60U, 0xbe8e4d6ebe8ebae5U, 0xbe8b7421be8c707bU, 0xbe87f132be891b16U, 0xbe85c035be86f595U, 0xbe82931fbe840e96U, 0xbe805021be81b4c3U, 0xbe7a94e1be7cf042U, 0xbe74c451be7704d9U, 0xbe6f9a50be72a1aeU, 0xbe6a1a5ebe6cbda5U, 0xbe6558c1be680a2dU, 0xbe5ff637be63576fU, 0xbe59f9f4be5c9894U, 0xbe54dca8be57a84dU, 0xbe4e7f5fbe520403U, 0xbe499dcabe4c4d94U, 0xbe43be2dbe466800U, 0xbe3eb9b2be411587U, 0xbe38dbe7be3bd20dU, 0xbe337784be365a0cU, 0xbe2d38d4be30d0b0U, 0xbe279f42be2a49e6U, 0xbe22ba09be253ce4U, 0xbe1d8769be1ff936U, 0xbe179dc5be1ab9a6U, 0xbe12a08ebe1500c2U, 0xbe0d198dbe0fd038U, 0xbe07590ebe0a5105U, 0xbe020ddcbe04ac52U, 0xbdf9b32fbdfee5f0U, 0xbdef63cabdf4b1dcU, 0xbde34f53bde91ff9U, 0xbdd7c9d3bddd5874U, 0xbdcd901abdd2a534U, 0xbdc31f31bdc8b382U, 0xbdb78d4ebdbd92b0U, 0xbdac2cbebdb1e145U, 0xbda1467dbda6bb4bU, 0xbd964a56bd9b5b56U, 0xbd8b734fbd90c383U, 0xbd7fd56fbd85d59bU, 0xbd6af664bd750df5U, 0xbd555458bd5fcd21U, 0xbd4027dabd4adb8bU, 0xbd299e74bd34ab12U, 0xbd1345a6bd1e61d8U, 0xbcfb2360bd089b7eU, 0xbcd07005bce5b2a8U, 0xbca52429bcba71baU, 0xbc74eddfbc903027U, 0xbc1c67c1bc47e70cU, 0xbb851226bbe19e8cU, 0x3abcec38baa6331eU, 0x3bda06603b802ec3U, 0x3c4558983c19cb4fU, 0x3c8d3d5d3c6fce82U, 0x3cb971b93ca2d6edU, 0x3ce68cfa3ccf83ffU, 0x3d08a0ce3cfc81ffU, 0x3d1dba013d12f523U, 0x3d34232a3d28b535U, 0x3d4ac47c3d3fb895U, 0x3d604e2a3d55af14U, 0x3d76ee553d6b6b0aU, 0x3d8642353d80de0aU, 0x3d910fc53d8ba7e0U, 0x3d9bd2b13d9683f5U, 0x3da76e0b3da16c46U, 0x3db2e48d3dad7d29U, 0x3dbd87eb3db81477U, 0x3dc83c5c3dc2edb5U, 0x3dd2cc933dcd6c23U, 0x3ddd51e13dd84e3eU, 0x3de8a5cb3de2bda0U, 0x3df3ccbd3dee63c4U, 0x3dff0c583df97b02U, 0x3e050fa63e025d98U, 0x3e09d1003e0749dcU, 0x3e0f4ef93e0c8739U, 0x3e1537663e1235ecU, 0x3e1addeb3e1815feU, 0x3e200d463e1d69fbU, 0x3e2618133e230c1bU, 0x3e2b43643e28aac9U, 0x3e30c9173e2dd044U, 0x3e35ba593e331d5eU, 0x3e3af0cb3e380804U, 0x3e4130783e3e166dU, 0x3e47293f3e438e10U, 0x3e4bcb803e496f70U, 0x3e5138103e4ed7f6U, 0x3e56d1e33e5324b4U, 0x3e5d65a23e595c02U, 0x3e625bea3e5fd642U, 0x3e6783253e64f206U, 0x3e6d44fb3e6a9e60U, 0x3e731ecc3e6ff80bU, 0x3e7764d13e73d9d9U, 0x3e7c56133e7aaf89U, 0x3e81ccf53e7feb23U, 0x3e84a1173e82d2eeU, 0x3e8692523e8551c1U, 0x3e89ac8d3e883a99U, 0x3e8c79363e8ac5a2U, 0x3e8f27723e8db156U, 0x3e9163d83e90862cU, 0x3e94a2583e93439fU, 0x3e96f76b3e960112U, 0x3e9a1d3e3e9913beU, 0x3e9ce4d93e9b7bf7U, 0x3e9f98233e9e396aU, 0x3ea255963ea0f6ddU, 0x3ea513093ea3b450U, 0x3ea7d07c3ea671c3U, 0x3eaa8def3ea92f35U, 0x3ead4b623eabeca8U, 0x7e78746b3eaeaa1bU, 0x89804c815a7c7569U, 0x566c9b718b6c8755U, 0x605e8a767938a465U, 0x5eaa69838a59698dU, 0x7f9996627a798377U, 0x6a65747788797273U, 0x835e5994625f77a2U, 0x9ec164a2a97a9175U, 0x7b888974ac696fa1U, 0x897a7c816e8c5b77U, 0x638ea390674e82b7U, 0x5f96a5979645a48fU, 0x93808494778f4166U, 0x8399698a719f936dU, 0x6e828e6e49876291U, 0x877a57928a938092U, 0x55716c628f67868aU, 0x7e89618c5e54988cU, 0x867e7695748761a3U, 0x6b85b28a99648779U, 0xa19b6e70736390adU, 0x569b758a5f657671U, 0x41836a8e6e3b7487U, 0xcc6c676f658e4e89U, 0x8fae996c934a8e89U, 0xa3a57e7b7e996d80U, 0x847f667698a46e5cU, 0xac959e738b8e5e5eU, 0x7a9299848f457254U, 0x7f776f8e7899954fU, 0x68617f6e9e7d8767U, 0x9d6b86647a6e7c96U, 0x7580706b95867aa2U, 0x5f9179917ca0767eU, 0x8a75a19278966e90U, 0x7e88878d778d8661U, 0x97807a8d7c7c4e51U, 0x886a8e727a937b77U, 0x7d9f6e7c79618154U, 0x9480887784738a83U, 0x568a988f55867360U, 0x6c8980837485a393U, 0x9f547b57927b5c95U, 0x7d5a946f787f767bU, 0x6f8e5c587e82878dU, 0x747b737e7b98b374U, 0xa9a295ab7a749c74U, 0x80b0a27f7b616986U, 0x76908479918f8c56U, 0x7a847e5a5e789072U, 0x897a7f6e78685f95U, 0x7da48f7b738d6684U, 0x568372a0967d6a73U, 0x5c639680886d9093U, 0x9a6a8a7d86819868U, 0x7a69898c83816d4fU, 0x83597b4f6593768fU, 0x706e696e7c7b5672U, 0x7f98756e94807e8dU, 0x7f83a27a7e62997eU, 0x7e70616c6c7f9896U, 0x746d9f7c83936f98U, 0x6d607ea578886658U, 0x7a7583b08f9f5c8dU, 0x726c835d747f6aabU, 0x71999ca08166895aU, 0x71769c9778915e29U, 0x55807c8a82919f5dU, 0x846f9f6a7e8e8658U, 0x656982ab948f768fU, 0x8a4096888b8894cbU, 0x895b5956486d7a7aU, 0x468d1f79978a5f80U, 0x949180519f825c77U, 0x888a8d6b916db166U, 0x886f9a446ca47c86U, 0x55b48daf72a769afU, 0x78844968a04b8763U, 0x57857072997d5970U, 0x6f8a72636d62c27eU, 0x8a78879f8e7e6a55U, 0x5b8e6d6e82659b36U, 0x80628246848b7790U, 0xac4b566b84596c83U, 0x944158a89da885baU, 0x51526d8e766a7ca8U, 0x8f358f5a594db47cU, 0x559b464a6a736161U, 0x89878c8f6373a288U, 0x907c62812ca29953U, 0xaba3a79c5193bd83U, 0x6d7c5fa2ac8f70a6U, 0x4a62a9908b668295U, 0x7e9a8e649f6d747cU, 0x53918c6580895e8cU, 0x665a5aa85a67767eU, 0xa25b99b45d68816cU, 0x9e6d9b5a7f68639cU, 0x638860795f896a63U, 0x734bb356606f8584U, 0x5471a8528f708c85U, 0x7772715b7c503968U, 0x927d54754d904b7fU, 0x8d896973a28f6278U, 0x635381947c6a7ca7U, 0x6b9a7a9d6c897d62U, 0x93a57161657db170U, 0x968ba562a38d9470U, 0x6e4b789c72586e93U, 0x5f9971565a606175U, 0x64817f5e6967497fU, 0xa193765382b57774U, 0x775b808882a250d1U, 0x6d5b4a7c889c678bU, 0x70905872907e825eU, 0x5b795156727e6163U, 0x90756c80785f7b6cU, 0x945c7e7a79aa4d57U, 0x96798a6c50846a73U, 0x8e3f989c467a9570U, 0x7a8a43977b627e58U, 0x7886595765838575U, 0x615f98a1b2947949U, 0x6168634497875282U, 0x6067a7717b885d7fU, 0xad72555d45a55d7eU, 0x7a758e925a646750U, 0x8857814d4e6d854fU, 0x9784826cb3888a7fU, 0x9089868068847578U, 0x8c7aa88a61958b6bU, 0x7990956d63668d6dU, 0x798d59668e826f74U, 0x786b7f7f5e7f6998U, 0x728f467d9b5f4c58U, 0x56787e70887e8a9bU, 0x687b71aa7b7c8352U, 0x819879758d7b8077U, 0x6b36884b829a6f66U, 0xb07c6c6654877a89U, 0x6c7c56656b5e847aU, 0x59806d938496b97cU, 0x956693a6739f988bU, 0x5c776d7e97906d95U, 0x568d74726583895fU, 0x68775b4d87ba5e77U, 0x827b6e717e646677U, 0x88846f556f936a90U, 0x6262797d88a26266U, 0x5d7b77729b82848aU, 0xc256878859a9727aU, 0x7f8f896f7b7b7d54U, 0x6a857680568a3b54U, 0x34476154807d6370U, 0x92765d7b81646389U, 0x62768a72b58c76a7U, 0xbf635e6a948b8f9dU, 0x80718f6a667c5b86U, 0x797a738298807c58U, 0x824e898680a7628cU, 0xa596b6e17d918d86U, 0xbe728db4907d78afU, 0x86898dccaeb5b2a8U, 0x8c8fe246a6667d5aU, 0x948fa4779c6267d1U, 0x2da17e2fa16064b1U, 0xb08771706c687276U, 0xa1622685b1b6659bU, 0x4d86b7aa815a8191U, 0x98c59363a955929aU, 0x8d80916f95a1c378U, 0xc069c18a63806d68U, 0xaf805b6b2e9593a7U, 0x9a7d9f7a79878f6fU, 0x988884a1879c8d68U, 0x978a79beb8957b9dU, 0x78626e85a494a0b9U, 0x7d5b6c7361ba95a9U, 0x6b7b606287afb28aU, 0x69808165985c568eU, 0x77657ab45695af4cU, 0x47647283547d6ba8U, 0xb58f9e6dbacb7f65U, 0x857aa1aa7986bfc3U, 0x93767ab37c844e4fU, 0x5954615f7971b270U, 0x533b8382ce787b67U, 0x66a191a03f65a9b6U, 0x84b36f449db57aaeU, 0x8a4e8f7845a34282U, 0xa0536e877b48475cU, 0x8999628b5a68868cU, 0x73ac6882375b94a2U, 0x7b88848796907665U, 0x7079956f6d9a7f97U, 0x9dafb291637d6a89U, 0x678777a6606f9c55U, 0x955f785e82718a47U, 0x6c6e919790866d78U, 0x9c6eb38e85778972U, 0x818a5d518b996d81U, 0x6f605ec487696a6cU, 0x82a17d6d927e7286U, 0x7a9d89818f6daa89U, 0x85a09483ad935f7aU, 0x968d4c68725e5456U, 0x638e8b6296828d85U, 0x98bb7e567f38956bU, 0x87875a949f8e7375U, 0x9b69a085964fab7aU, 0x9c9fa659715c4b70U, 0x766d71a295846c88U, 0x6a7897877f8431a8U, 0x83867c7aa07f9f71U, 0x5c767771695ca38eU, 0x4e8490d295728f73U, 0x937c936e6962bd56U, 0xa4b48185937fa754U, 0x7a969b995c7e8983U, 0xce68638e77ae9e89U, 0x548c72926e68918cU, 0xae8f827c6d6ee099U, 0x8c909da26f765e89U, 0x735b8c5bbd56a864U, 0x6b7380966a658a50U, 0x95857c66b0779d82U, 0x7b946e5a749e829bU, 0x727f93607470708aU, 0xa57f468874a963a6U, 0xa27e97806e7c6ba5U, 0x8198718f6f9a9d6fU, 0x88bb708d8d7e7b80U, 0x8956b09394738b9eU, 0x7a769e7ca1689f7cU, 0x4a866c9e9a795988U, 0x8b8380ae736f9f85U, 0x8c61779d4c83718bU, 0x6e89936d8d94a37cU, 0x9a5e9eb35e628182U, 0x8b6280a17b867d75U, 0x748794768092a57fU, 0x7f627f8374707890U, 0x71ab609676b4786eU, 0x709e9e86849e7479U, 0x8f52808873388a4bU, 0x799373596e57638aU, 0x794b516d846277a2U, 0x939a718a5d91737aU, 0x858a766d5ba87ba2U, 0x7093838690919380U, 0x9068686e9c938162U, 0xa1ba867980599b5dU, 0xa6a06e889863a090U, 0x5c808d8c8ba9427cU, 0x7d9b6f5bad7c7c89U, 0x826a62aa8593797fU, 0x787e7195508f685cU, 0x85984a69999b7695U, 0x7c90806f6e8e9077U, 0xad9654929488776dU, 0x7e7457938594a58bU, 0x794b997268997670U, 0x8b70a7759d87957bU, 0x844e73677f9a776bU, 0x5d736b78777b8949U, 0x7478576fa072888aU, 0x88706c9c7c948185U, 0x92824471847c4c65U, 0x887e8d61615e8ba1U, 0x7e669b9591747491U, 0x767f848d70887f89U, 0x787c7fa05c607ba9U, 0x8d7b697f3f943b71U, 0x5a6e8e60b35f6064U, 0x90659c736154796fU, 0x657b6ea144a4738eU, 0x699a81595b808573U, 0xa08287827b799780U, 0x417c8d2a65855f6aU, 0x5772714d765a895dU, 0x75608b85979b857fU, 0x8873996b347e5c88U, 0x747177996c666698U, 0x6f776e6b93988566U, 0x7f57898978699485U, 0x734f879b907b7164U, 0x9e8d6b899270926dU, 0x6a6b5caf587f9396U, 0x7e8ab8ba93848181U, 0xd3799c8e9c9b7c90U, 0x6a7c93ab789e7386U, 0x8b888f72a9a27c6dU, 0x7a8f7b8b7f78548dU, 0x289d7c6bab7a469cU, 0xa966787f7e695b93U, 0xa7644ca789788a6dU, 0x6e95b69f654c9384U, 0xa690773e6458698fU, 0x75848f4e91a0c29cU, 0xad698f716e61405eU, 0xa2807e8567768da2U, 0x68658d7dae6eba55U, 0x99728c746caa8c5bU, 0x8a945bb4735a9b90U, 0x7663816c8e6b955dU, 0x6b87787f379462a1U, 0x4f927c7f7d90a092U, 0x57a6967a8e573aa8U, 0x6e7677885e708962U, 0x447c408065615a9bU, 0xa174934b939e937eU, 0x728caaa1865da4b0U, 0xa84995815569496aU, 0x755f6c577673a65eU, 0x7654b75db8457d73U, 0x4e9f80854c39ac81U, 0x7e915f558bb28e7bU, 0x6d719b7358782f84U, 0x8f5e487051844b69U, 0xa48f7f8a517f6477U, 0x708d5b87927c8678U, 0x6f8a519a83838c8aU, 0x8b918f807f668f88U, 0x927a9e8e78558770U, 0x68619d7588787a68U, 0x7958846ca796715eU, 0xb55f868073726b95U, 0x88657e598ba98e4cU, 0x4f98358e7993816dU, 0x8677916d77896d7fU, 0xb4a7707f77656da3U, 0x7d736f7c99788178U, 0x997b9798a4955899U, 0x78a4899195755b60U, 0x728d8856577f917fU, 0xa4897876864c966fU, 0x96937c5b8065576aU, 0x6f7c7e998165797cU, 0xa8749f729e7c5e82U, 0x8f707e7a7d7e8292U, 0x6e689c8a89746083U, 0x6e769d84756e9086U, 0x91757e85a95caa84U, 0x6762698188757a40U, 0x99868f8d84807562U, 0x75aa6a828c87947fU, 0x6184b18a476c777cU, 0x9163638990955b66U, 0x5187b088736d6a65U, 0x8f61696676649668U, 0x996d78744f9a915eU, 0x7ca370af9e998a5aU, 0x8c5e93b97c82786eU, 0x8c537461a0978781U, 0x846d99997a857783U, 0x7f697389b184a55dU, 0x7b7f657a618f7ba9U, 0x438d9c4e66827e83U, 0x7a8c943e7865a96aU, 0x6f666392519b9e57U, 0x7093b6965a666c84U, 0xa16a79489a68617cU, 0x8596838d838f7c9dU, 0xae7b79c77e6d396dU, 0x83886a764e83888cU, 0x8170ae7b9c76806fU, 0x738982a675896a55U, 0x8b5b8da46a869886U, 0xbb547b8a866ba0a9U, 0x7d979e886c7b4fb6U, 0x7ca8a280939fc18aU, 0x7c8391976b795b84U, 0x6a9a9870286bb050U, 0x52ac677b536a6e90U, 0x5a85597e8f7f8f62U, 0x5171a08d9a6ad0b0U, 0x834389ab717f837fU, 0x5d618482b173bb6bU, 0x57548364ad4d3e6fU, 0x66986d99223c8e8bU, 0x588166805d746e7dU, 0x71228092657f585aU, 0xa4854d7c77686d84U, 0x527296a36b656a70U, 0x9c61c07c637a6e69U, 0xb8977c7d635d7b59U, 0x675d8e5466698573U, 0x686f8e769846926dU, 0x64854f7476a58dacU, 0x776d5a626399949dU, 0x7697747f8d88828bU, 0x657c7a8e89724a80U, 0x7e6d61936870858cU, 0x589a9881867e9791U, 0x586d7d84947b5650U, 0x6f8c5f748b977e7fU, 0x5e9b8078525a8f96U, 0x815ba16794a98e9fU, 0x635969ab83a33895U, 0x7e5f90936f948d97U, 0x5f7083b56f7c56aeU, 0x669781587f9b6b80U, 0x5e606375847f975aU, 0x4768667b9089a85dU, 0x5768786b917aba63U, 0x6c4eb4946e7f6966U, 0x35a4817b7f9d6869U, 0x7d756c4fa571544eU, 0x5b75668e9096757fU, 0x6e93a36065775993U, 0xa65f5f68738848aaU, 0x73767f378f959985U, 0xaa749da0446f82a4U, 0xa98f717e9688756aU, 0x73946e699f789d9eU, 0x758886976e9b886dU, 0x70938961a2828a4fU, 0x9974718e6b739a85U, 0x728b956283717679U, 0xb29e70ab66546385U, 0xa46c867071a29a77U, 0x8d646c7275889783U, 0x778dacb99b7699bcU, 0x8d99a747b5859298U, 0x889d718f91bd7480U, 0x706d93907a8b9e87U, 0x8059919070ab8e84U, 0x72827b9486bc908bU, 0x8e99877ca3825b8fU, 0x878885679e959da4U, 0x6e81b09cbbab419fU, 0x978b9c886372956aU, 0x8d856b5b68847ca4U, 0x7fad6f4ebb839b67U, 0x9e928d8a8f99887aU, 0x737a8d8f72738795U, 0x39a98879a5926899U, 0x9973808c9c847068U, 0x5f848da07db57b80U, 0x8583835e9bb54b59U, 0xb2aa838c6e829c60U, 0x96b86d88377f5888U, 0xa18677aa4d7a7688U, 0xaca499739c8d5d7eU, 0x8d84ad884c708276U, 0x777c5a6b9c8eac7fU, 0x8f5a7885937d9fabU, 0x68748e61a5899877U, 0xc48481a99e757a8dU, 0x8e87b763a0988c4cU, 0x7d887d955291708aU, 0x717f647268885485U, 0x646fa35e8c604b91U, 0x99a1906c8f637789U, 0x77a23e7791978580U, 0x83c16c9b7769678cU, 0x926d79759d6c6fb7U, 0x7a95828f9f828076U, 0x6875837395626582U, 0xb274ad8c886b9695U, 0x6e6a41bd7c7b7491U, 0x658e6885559d9667U, 0x837193722e92568fU, 0x76817d988fd5608cU, 0x637a9c7fc0799babU, 0x927780b65a7b94afU, 0x7ab283a66b78867eU, 0x69919a7c87627178U, 0xd26599909762799dU, 0x938678928c969a5cU, 0x975b719c515d679eU, 0x94708b9773a25ba2U, 0x64bc8a5793619a85U, 0x787ea889e589916dU, 0x8a66677eb4a29d99U, 0x868591ada2a27f8fU, 0x939a7a57bca968a5U, 0x728c967d5fb25a88U, 0x5987af8b938a848bU, 0x6f775d868fa0b56bU, 0xbe568da64b8b5147U, 0x82616357c5b28c84U, 0x7d8549a49fa87263U, 0x7a64527a816271a2U, 0x336d949255717ac7U, 0x5256958b5a7c747dU, 0x599876698a9aac97U, 0xa97e4fa68da3735aU, 0x858f827e81817d8aU, 0x665d547bb86e7393U, 0x7aaf8cbca93b866bU, 0x7654928681ac7179U, 0x6b5e7b77a057897fU, 0x8e897c94a1796d75U, 0x6b2f8a8885586357U, 0xa6857fbb67a89babU, 0xb07354678b7a54b3U, 0x6290a7816e7c8fd5U, 0x648fac9b7f98cf66U, 0x7384af91526c4790U, 0x7486af623c6aa18dU, 0x95ab5a689e5b8771U, 0x54465e695386508eU, 0x74c88d927e71d399U, 0xac838fe179817c8dU, 0xa966859db9918989U, 0x2d30768998ae529dU, 0x8e9952784c7a827fU, 0x8a9f798bc3a65976U, 0x8c4e4bab718d876eU, 0x8f885f7aada89599U, 0x6c40658e4241aa7cU, 0x809699deac816da0U, 0x8394878e9e9c9aaaU, 0x45bba69f91ab9f81U, 0xb3b1b656ac927828U, 0x6eb76c939b495897U, 0x36c49b3ba86d839fU, 0xaf7a59a56e6c5b64U, 0x904b248db381839aU, 0x32acb8a94695755dU, 0xa789ba26914d6b8eU, 0x9a759a4db0b2c180U, 0xc04a867c566f7673U, 0xa783ae74659e77a5U, 0xa28a7268c49fba84U, 0xba99756080b5a38dU, 0x9584619f9387a0afU, 0x7789808a778d9ea8U, 0x8354777b4d9c726cU, 0x83b47c4394b196b5U, 0x59a2a25b8f585798U, 0x6d916aa26f958346U, 0x4466569f6b4b7cbcU, 0xb6876d749e729a7eU, 0x92a79b838b83949fU, 0xc0528f8b5e9b8345U, 0x4c578f41806a906eU, 0x4d76859ca7678c58U, 0x71a8a0a25665a4b3U, 0x6bb449587aba7fa9U, 0xa37d937154ad3698U, 0x9a6a6d6f53793b5eU, 0x6b9b54a763906a84U, 0x4d75ab964d70775aU, 0x867d7b8d8188917fU, 0x5a826673626b6a6fU, 0x9089617e74927961U, 0x756f569f5b9e9c6eU, 0x575470677d7e767bU, 0x9765aa6885aa778fU, 0x8b788967607d8098U, 0x7c7e927f46958f61U, 0x71667c5397936a78U, 0x54688f8f8d9e748fU, 0x648f51b67d9f486cU, 0x8396b175766d667eU, 0x966c726d8e61877eU, 0x6f7d768ca2826092U, 0x9a59589d63509c8dU, 0x9aad729767899866U, 0x7a9c968c816b8f89U, 0x628f836b7f86a48bU, 0x80a39a8a7d8b8475U, 0x60c06e634685a68aU, 0x6b73787b55557e90U, 0x33bb8c3f98a97ca9U, 0x6f74a4828a72a190U, 0x8867b89c94639384U, 0xa087626e71918b77U, 0x6e80a6824b586e58U, 0x5f728d617e5d6567U, 0x77696a76706e8e70U, 0xa964a46eab759f80U, 0x938d7b6359966672U, 0x65936c9157626369U, 0x887ec08f827f7f8fU, 0xa26fa9948e82739bU, 0x748080a6998b8264U, 0x7b6189587793985bU, 0x978b6e906e738ebfU, 0x45a56c5bb35852a7U, 0x818f567c71836883U, 0x83836c9c819f7a98U, 0x7198acac6169856bU, 0x6e7d9e82b3733361U, 0x49768c767f9fb47aU, 0x98738fb37d8c5679U, 0x8d6c9c6b8f9e8c83U, 0x745a855aa2968d46U, 0x7f9257947c99696fU, 0xa7543f8e80918478U, 0xad6a577d8f8ab497U, 0x7f8dac8557b68ccbU, 0x79b86179a09dba97U, 0x9ab3ab7f578c5494U, 0x61a68d8b6c8fb858U, 0x474d4a76376940a9U, 0x7aa662899fc8987bU, 0x7c7f92a36975d8c7U, 0xb54a9fb17c8c7285U, 0x6b6d6f438f4e9a9fU, 0x7c6b818a758e5461U, 0x738874646a4179c8U, 0x487d426e86a78186U, 0xae95894d82d76f7fU, 0x9274646e18664b56U, 0x498e6890714c6392U, 0x8a5bc093a8594855U, 0xd263935f5974809eU, 0x867279aba471567dU, 0x796b89669e617c71U, 0x67668c4fa98962b3U, 0x2bb282647e6559b0U, 0x6da1718c989665b3U, 0x77a73e8f849c869eU, 0x9a868080aa7a99cfU, 0x73a69d4692906f84U, 0x579f909a926e9969U, 0x953f738282a23b8bU, 0x7d725686778b789cU, 0x6d77b08fa292a778U, 0x58704cad76a2707cU, 0x907a87916f9fb476U, 0x7785785cb087bfc4U, 0x6aa05f5c637a9998U, 0x4e7495957ec2ba71U, 0x8669a1788a5e4979U, 0x6982937e579eafa2U, 0x466b65743d5e538eU, 0x815d6c9983cb786eU, 0xa68b8a6491b39ec7U, 0x82778cb76e6b808eU, 0x6d886d828e7674aeU, 0x67526881738b8799U, 0x56ad7a8a714a5765U, 0x838160916da45997U, 0x74895d7780a1468fU, 0x81993f635f78709dU, 0x818586a54c739f8eU, 0x8a736c7e5a717752U, 0x829b695aa0916877U, 0x7e93525a86928270U, 0x784a7e8c9c6e77a7U, 0x5f5a4983739a79a7U, 0x6c728c9e8da09c9eU, 0x8b95776192a56f94U, 0x7991659871855f6eU, 0x926f806b9d977b8cU, 0x6c7c816f998f6e8fU, 0x6a8576a09a6da364U, 0x66854c82699e6f9bU, 0x857ca1815e85937dU, 0xa1607b758e7d5e90U, 0x7c538d7b9d697185U, 0x976193a0756b6e9aU, 0x7c64a17d7d925990U, 0x8d9f6d81b14d8e88U, 0x809080af6575ad72U, 0x737271967d809c6eU, 0x81928d575870bd91U, 0x6273627886757960U, 0x4a867f8d8d85616fU, 0x90955d5d82a1818eU, 0x7bb29085839073bcU, 0x98917f99848d72adU, 0x85646397a29a957eU, 0x9169896f807f8f60U, 0xa6648e8da07e8b99U, 0x83826e889f995f8aU, 0x6a877971a0718dacU, 0xb9647e8d7d688479U, 0x567e88579888b49dU, 0xa0825f78486dc58bU, 0x866a925ec07b877cU, 0xa99155bc7a876971U, 0x537f45738a676871U, 0x8167b0839b7b8e60U, 0x753f807a7c7f6a81U, 0x7c55904c7e7172bdU, 0x78a25d903683987cU, 0xb36862709d8f625bU, 0xbe7581623e89839aU, 0x665c517976616678U, 0x9d91ab6a70984a65U, 0x749e8c7459724c57U, 0x66bf7283749d7f91U, 0x799882967131a08cU, 0x7dc4a46c75617766U, 0x6f94a29d594e7d61U, 0xbc8fa44d9f7472bcU, 0x78bfa26f45b0647cU, 0x39ca7b96876db57cU, 0xa377929c5c845c9bU, 0x66a1887da66895b4U, 0x5d64888a9a407582U, 0x5a1ea26081557848U, 0x919286a65a75696cU, 0x75aacc8a32578381U, 0x6b4b759068697279U, 0x69ae728a6d6e6d70U, 0x779a796a8d78be79U, 0xac74739c46938f55U, 0x858b62a392924a62U, 0xb570c5a55b9b7b77U, 0xad8789774d73946fU, 0x6e899bb0b06a9065U, 0x9283727da48b905cU, 0x8486867a855b97a4U, 0x3cb199737b8a6e98U, 0x8a92ad79665c6f6dU, 0x745e609f86a26965U, 0x8876a3a34d745095U, 0x7fab834991746063U, 0x779891ad8c64a479U, 0x96897eaf8ba14d80U, 0xb15e7387408f8593U, 0x72579088a0679357U, 0x697661857ca17f61U, 0x574c638d9775b47fU, 0xa06187817382918eU, 0x9b8aa3893e856d7cU, 0x8d889b4f8c93938cU, 0x678ab2889956629aU, 0x7daf7f68638ec453U, 0x3c8866624a6b698fU, 0x519671958ac58180U, 0xac81797fa08aafa9U, 0x8a50a6b691666f83U, 0x4154737e615ea96bU, 0x6c70895c7b426974U, 0x5e82808560397a72U, 0x8a8a7f7da9a57f5eU, 0x7e417588908c785cU, 0xa18c3f9a51937d74U, 0x5938788c4f596673U, 0x8391ad8db6536299U, 0xa471a0608a686980U, 0x589e7e97997ca886U, 0x717a9543ad8a6f40U, 0x70a4a96ea95b498dU, 0x39af8c70a9666cafU, 0x727751ac488a3092U, 0x996d45a5b2657a85U, 0x3d73a8838f649287U, 0x7590984a66904e69U, 0x8c9281758e96cb6cU, 0xa6839d709389786fU, 0x98729a83759f6370U, 0x6d7c776a759c9a8bU, 0x7da2839684a27883U, 0x89998981988c6d7dU, 0x558b666f90919285U, 0x867d416959a77a9fU, 0x6c9c58517a9c777dU, 0x6da08459ab62526cU, 0x4b8965a68480664dU, 0x331b589a4f586b96U, 0x849e5b8768987770U, 0x748bafa3886087b2U, 0x8b80907e72688e56U, 0x6c77746c865b936aU, 0x7f846a9084787d59U, 0x5ead8482863b7a87U, 0xb38d706993c47b7dU, 0x9ca4855b64b52e94U, 0x744f89584c714e5eU, 0xa95c604e7bad6173U, 0x906e6790ae5d9c9eU, 0x54a5797bb35e7f70U, 0x6e7aa6686b8b8491U, 0x68a248a55385699cU, 0x5e8c977567424b6bU, 0x965390734785546aU, 0x7e6c4667847f707cU, 0x7d626c9c427d9d64U, 0x7175369f8932858dU, 0x7771588694884372U, 0x696a641f5a766d87U, 0x7e72663e2c4d8d7eU, 0x918768a85a827066U, 0x838279847d8ab457U, 0xa87561754a4e7d63U, 0x95a0678a707d999eU, 0x399489929977843dU, 0x8a4968b3754c5543U, 0x96778e8a955a7e9eU, 0x7c79958e49615693U, 0xd83e6a9188827168U, 0x927d4c5496828a6aU, 0xb148751c4b3e819dU, 0x67642b7551775151U, 0x5b558b2e7f7e754aU, 0x7c9d776f9d8cc257U, 0x86637288928d8d8dU, 0x5c6f8d968ba48093U, 0x50987254747c9582U, 0x4474a388615d587fU, 0x8b85725a9c528365U, 0xb27f957d68ac78abU, 0x67816468a49f90a9U, 0x9e9567968c88a9a3U, 0x916081767b956183U, 0x717a536970609279U, 0x8094776e9c9d886bU, 0x788d8f9e7f6aae86U, 0x7b80608e8d90818eU, 0x90a16b5884678695U, 0x966e2e899ea96f6cU, 0x5d727e7983b07c5aU, 0x777ea18c7e9a8086U, 0x9b8487588a638d77U, 0x6d8a8f877b9a7f66U, 0xa96887a68873809eU, 0xa8837f7b8d7e6473U, 0x717b796289776d92U, 0x635391746a7f69a0U, 0x948e4a57a47c744fU, 0x9d6d88948b6a7794U, 0x766a458c7a636282U, 0x66607c7da8ac5a72U, 0x71867c9f7c5b7ba1U, 0xad619a6583717b8fU, 0x7aa978556583729dU, 0x4b8f7284667d6375U, 0x8f6e639f788d8e87U, 0xb79d9e79948980a8U, 0x878e6b959893a774U, 0x917a54777a51886cU, 0x7da7825e9e6a589aU, 0x79638569927c779bU, 0x5a7349b56ed49892U, 0x8374a3849671586fU, 0xa052923f6e578b85U, 0x81954f9e62776b56U, 0xa0666485a66f9e73U, 0x834c9c595d9c8a7fU, 0x769777a6778a579fU, 0xa07d817f749d7da2U, 0x8d8586ad74648ba2U, 0xb562897d927c7e9eU, 0x737772595799656fU, 0x7aae63ba677e9a59U, 0x8699947e94856a65U, 0x767673a05b557f9eU, 0x4e747b7c755db38aU, 0x7e746d626d8f5058U, 0x84945f66766f7467U, 0x716a86929c5e7b9cU, 0x70b36864745f8e8eU, 0x697d77a2946aaf5eU, 0x60868557808e705bU, 0x6a779b426d617c80U, 0x7b9672828c7e884aU, 0xae93978740ab7542U, 0xc865bf6653b455b1U, 0x64967dbf916782b8U, 0x84597d646d8f7664U, 0xaa6b767da3867b7fU, 0x51a2645c7f887f65U, 0x6b4ca2697e7b5b8eU, 0x70848b996c7d8562U, 0x65846e486a7e88a4U, 0x6274919053689879U, 0x799b8c80737772a9U, 0x859f939a6b7c6f7aU, 0x7293806e7a767693U, 0x6076a63d8ba29a68U, 0x67b6458c7ea2787cU, 0x7790664ea848aa85U, 0x6ea5898a75765646U, 0x42676a946448786bU, 0x7a5f9f566183756eU, 0x7a94b09074579f7cU, 0x86577f67c1a7664fU, 0x77897a90567c7e7fU, 0x5f67785b6e6fac63U, 0x9969677571688d5fU, 0x78b17a9fa47072a6U, 0x7b829d83b76e7358U, 0xa96d79bf5a807f6aU, 0x906cbb6764af9e92U, 0x62864e726c856d7dU, 0x7c9c507d827f9874U, 0x6a775f97759c8a62U, 0x6d6392a25e755991U, 0xa27169a49fcaa685U, 0x5b8e9a929577a060U, 0x8c7263632b6b826aU, 0x60757f5cb34f53b9U, 0x9a8190826d847a7cU, 0x6f78807d82359ab8U, 0x89914e579189857dU, 0xb9b091608f77a1a0U, 0x7373a4975e7d7470U, 0x7791a97c7e723f5fU, 0x95779a654993aa8eU, 0x768c5a8f6694877bU, 0x835e728bac648c88U, 0x756ea99f8e5f6692U, 0x658255a962919aadU, 0x9349ba916f8f7f66U, 0x7f717b4b634d6a5bU, 0x98456a7274897b6fU, 0x7e906f8e6260826aU, 0x88827b7ea161878bU, 0xa88a997e5381a293U, 0x898a7a978f747092U, 0x8a9a975363747e89U, 0x8381b06199866880U, 0x6c928c736f829b71U, 0x7a9d896072557483U, 0x87b38f8c9e646c90U, 0x7f79956779808d65U, 0x909a70777a706d98U, 0x7b72817984977ba5U, 0x83927895718d9c81U, 0x57748c815c756c84U, 0x447ebb92a0736c6fU, 0x6d5e837f99659971U, 0x7c697a95ae61937dU, 0x7c8c70893b7a5aa4U, 0x699dac908b608f3bU, 0x94736c773d808b71U, 0x6e588985905c84a5U, 0x6d506a80a7907954U, 0x816f9e826c84755cU, 0x517c5cb65e737d6cU, 0x874fc69f4c686d9fU, 0xbe6cad9885559893U, 0x796088868e6e4490U, 0xaca381666a717e84U, 0x7e59b75f76958d84U, 0x9b7171486a344f95U, 0x47a8758e896e6298U, 0x89757c6b97999c8cU, 0x927e738e67777a97U, 0x88747aac72869151U, 0x479d7d7666928673U, 0x797985aa9c6c6c6eU, 0x49995f6b88658489U, 0x6a5c826f8c7a9362U, 0x7f8d6b7a67958c57U, 0x7c87656046978865U, 0x7d7967c3ae6696bcU, 0x48867fa08daa9ea4U, 0x3ed0727e88759193U, 0x846b8259739c6779U, 0x8c927b6f5182b0a0U, 0x70746680a28f439cU, 0x9f5f85936e7bab7bU, 0x575cabad687f878bU, 0x7c996692a43aa96eU, 0x3890497766549e8dU, 0x91739d8a6cac706cU, 0x89ac782d83716b9cU, 0x667b8f8c67cb656bU, 0x9995534886b17291U, 0x7a796d825e4f5259U, 0x936782a8516bac55U, 0x764d849362876f49U, 0x91845884ae875b6fU, 0x818c547d8f979670U, 0x487387838a90947fU, 0x5480759d6b88899eU, 0x988d9baa92888384U, 0xb75e98306f916f99U, 0x6f7f639e75498a4bU, 0x9d489874859a7ea9U, 0x6d77786f9a783a77U, 0x97be4cad57737d68U, 0x75aa7e907e855b77U, 0x7e6e82b065828989U, 0x8e925a9783629972U, 0x8a4f894d696d7b63U, 0x605243857a8e8084U, 0x698877956d4b696eU, 0x8c805b986c7b3c86U, 0x7561878776a8ca8bU, 0x7974b37b7e7aad5fU, 0x856f7875785ab36bU, 0x6f8261896b7e8259U, 0x58806f8f72785a92U, 0xd0808e79708aa588U, 0x779379c1928580b3U, 0xa69970849d8ba46bU, 0x7c718e8db872837cU, 0x576661a6667b6e99U, 0x75618d618e698b7fU, 0x636cb28f6b688f5eU, 0x76709e7d829da4acU, 0x628f789e6b57757fU, 0x7e5d746d9d9f9e5eU, 0x85616e866b726c6aU, 0x776f7692757f9453U, 0x8092988e8b5da569U, 0x8974b38e8b5e959cU, 0x708ca889a9768b64U, 0xae65a64a538861a2U, 0x676f5e77817f7771U, 0x65655c8670788478U, 0x989b837a7478738aU, 0x9c6d448458658584U, 0x9791825d9f776290U, 0x917e6190606383a3U, 0x7da57c8d488b7390U, 0x4166715f596e4579U, 0x7d6d917d907aa969U, 0x888f6896655a596eU, 0x6d7e76677077538aU, 0x956173657e748465U, 0x885389768855a56aU, 0x6668a7868f677c7dU, 0x8762b9786dbe836bU, 0x929d856c857d6f5fU, 0x80605f76765d5452U, 0xa56269998d664365U, 0x82ab917f797b7b56U, 0x94a2aa8f32655a6eU, 0x77716f716b71667dU, 0x7c7ac970878b8688U, 0x666a898e77898062U, 0x908974834d8d8f82U, 0x957a8499717f6773U, 0x6e765b6a918a7c4eU, 0x7f48678777866c93U, 0x957d635e61507473U, 0x6f41835fb47e9397U, 0x9e736c728a955f7dU, 0x4f6f8c87ab707f54U, 0xa591776882798679U, 0x7a7f92a8828b8886U, 0xa15c7761aebb5fa3U, 0x657b755e90888870U, 0x8d756692719ba67eU, 0x847e698b868c92a3U, 0x8e5991707c669874U, 0x5e7b68b28b5f49a2U, 0x82636c8083836298U, 0x9880658094873d53U, 0x756f728a6b5b5c65U, 0x7f8a617c7a616e77U, 0x86595e856e81a06cU, 0x837876867f6fa05dU, 0x8271596d56766e91U, 0x79988d98659c7488U, 0x89876c847c9557a7U, 0x9282567163aa9882U, 0x8f7d6d709f776a80U, 0x90676372809e7d84U, 0xac7d758355979881U, 0x6b855d997d644464U, 0xa433776ea7708890U, 0x83827b8f9d75736cU, 0x7e93a2828f7f7ea3U, 0x67a870bda4977668U, 0x7166b99587708f8aU, 0xc786647e654d8265U, 0x7a6c9f9ebb6b9668U, 0x717d7c9d9f678872U, 0x728980748b8db8a1U, 0x518f56837e767cadU, 0x60a564ac7d8e71c4U, 0x6b677273a07f7da1U, 0x8b93a2be9a698797U, 0x7d9b8677738b616aU, 0x499495964a7ca75dU, 0x73957e8262c04c7cU, 0x66896f9f7a6ca370U, 0x6d90a8a3747a749aU, 0x8b8b4dc97fbe6b6bU, 0x796e5f875d9ca996U, 0x647b8a6ca08b7b82U, 0x6d83ac657cba6a9aU, 0x68706e688f89b386U, 0xa871a17348816379U, 0x72947e807089994bU, 0x454d4f9431625d7dU, 0x5e7b577f78c4846bU, 0x75a88d6f9cac9293U, 0x916e91bf6d719482U, 0x9d5e7a736f544d83U, 0x8a5a406528716773U, 0x8289834d85684c90U, 0x538a94904b81975dU, 0x7aa37573adb28c84U, 0x4a91427955716f96U, 0x7a6b7a49321a7981U, 0x618e547eb1749586U, 0x7d787182717a86a0U, 0xa4669b6e67978990U, 0x8a778c8d73737e7fU, 0x708f8252c68074b2U, 0x3e6f90529e5c607dU, 0x9f7c607272a26980U, 0x79788b95a55f6e98U, 0x7750b9978376958bU, 0x7c8a9a677a9c9686U, 0x915078496ea1a390U, 0x9c738c885b80aeb2U, 0xa848777b4995756fU, 0x6aa08e924b7c9295U, 0x98b83cab6b835585U, 0xcf8086a1a6925b63U, 0x3e6b679c7e906e8fU, 0x7b635c7e4f756dadU, 0x90726f8864516e89U, 0x6c94656f74998c63U, 0x835e58848e5c773bU, 0x8a74969e4897527aU, 0x99c66759a6c56a91U, 0x9d5f698e3fa6746dU, 0xa88e79618483856fU, 0x99a77358aa856a67U, 0xb65d86859cb77288U, 0x70886f689368728cU, 0x91a07b489160808fU, 0x9bb99178777d5999U, 0x909b954571797f7cU, 0x5e767753a898659eU, 0x8a8c9b94688a7177U, 0x978585935a88677bU, 0x706a956f8876867bU, 0x9d84717a81789768U, 0x8f6c8580956a5e72U, 0x716870856e849970U, 0x69826b7b5e6e7256U, 0x8a74638f64716c7eU, 0x407488645f8a7180U, 0x8783977e838a9875U, 0x7c62757c8f6e9686U, 0xb8878f7d79826874U, 0x656c5d585d849d88U, 0x7e79635c7074717fU, 0x8f966e7368808b88U, 0x70889c7297867984U, 0x8297969b968d8b82U, 0x5c6a8b4c7b807682U, 0x6179824f74815c69U, 0x8862886791757e95U, 0x878f866e78687f5eU, 0x5c5272a187986493U, 0x9179837c8698847bU, 0x6c756c8193616876U, 0x836176617e80804eU, 0x468478777772747bU, 0x778f8587837f7159U, 0x83936b7d67816870U, 0x736f966a7b7d926bU, 0x985d8683757f6382U, 0x947d5f8d768c867aU, 0x68878782818a9567U, 0x38a2627a716e8166U, 0x44a962928d9e637aU, 0x759f656e637e86aaU, 0x8e7e8e825a7c9292U, 0x6cb0398a4b9a8d63U, 0x8f68859369898f77U, 0x9267937292637247U, 0x988165627c6b6e8aU, 0x8e6c5f6777805f56U, 0x6b48906373676987U, 0x878f65888e985e86U, 0x6c95866c556e8d8aU, 0x819faf5c9186749bU, 0x916c6c7687868d87U, 0x8a72b85979639374U, 0x90897c7892618379U, 0x8e6d6a5d536f794bU, 0x7e6c706ea1697163U, 0x9165736d8f766d5eU, 0x7a7e838e916b919eU, 0x576b8e7f6a639681U, 0x7f8d93859451a77cU, 0x799d9e6a8c6e9084U, 0x8e75759073616772U, 0x7b7b7e698b956788U, 0x846f745d507aa06fU, 0x688b7c908b698769U, 0x755b8f7961848388U, 0x748f7ba361719d7cU, 0x8444a08186488772U, 0x828eba858f6b7273U, 0x87934f8b72747c84U, 0x677b6c8884776179U, 0xa1746c5faa88518eU, 0x8f8c58667b96619aU, 0x627a71649a997e78U, 0x908a7c7b6f8ca9b8U, 0x5ba34677777d7e9bU, 0x61a1616288939685U, 0x8d56919983689276U, 0xb94f999173829c8fU, 0x4a77857e75857693U, 0x426773987ea69b5fU, 0x4296665b85c1708aU, 0x6f72a48c9260827cU, 0x6c7a98759c7587a6U, 0x964d6a7e9773a597U, 0xb24f736667767d84U, 0x876e82835b767279U, 0x9ba974a99d9e8369U, 0x66848aaf8b6a9967U, 0x757c76a070957e81U, 0x7b8275755989798aU, 0x8376868079687976U, 0x7ccf8d7a78b170a5U, 0x6f9797a48984e3c4U, 0x7c83a0bc63917c9dU, 0x906d8a6492778280U, 0x9a42377c57687f72U, 0x7c7282626d836a8aU, 0x7d7c677294aa9b6fU, 0x74929a72836c54adU, 0x87a3963b98523281U, 0x70855da965447f91U, 0x806eb4859b645394U, 0xae579076776972a9U, 0xafae8997a8766f82U, 0x7b628263a6a2af5fU, 0x6776616476aa83b0U, 0x50b48b65a5629abaU, 0x76c77c51899f545bU, 0x6a6e6ab753879754U, 0xae719d9389ac4d8cU, 0x8983995c81a06680U, 0x948b6ab2a290a265U, 0x84738faba89e1e97U, 0x8f65616a82889b68U, 0x68907db4916e4a63U, 0x56806d7a75b0837bU, 0x7b65509a925e7961U, 0xa782897e806e98adU, 0x8f9da87d7eb264bbU, 0x4a917f676caee690U, 0x8cb28c6daa7a8170U, 0x65a7839d3c7ba86bU, 0x5271708c61917373U, 0x7c9666bf9ade80a4U, 0x9da5d290ad77b6b4U, 0x9e7167ef89655698U, 0x683b514d834c7e92U, 0x85778d99995ca257U, 0x80764c70464078bcU, 0x8866465bb0ca738fU, 0x957395648aaf7892U, 0x7e48918052647385U, 0x888b9d8a5a56507aU, 0x7a7e73878b85917eU, 0x667f7587669f678fU, 0x886a8e9679815965U, 0x8677649e6a757186U, 0x8c8e81758668a080U, 0x80908666696b8f82U, 0x617e6558785a8f83U, 0x7a6291648b89a669U, 0x7f908ea381887679U, 0x8567718360648f6aU, 0xa08a7f8873836493U, 0x67766f729b857e5eU, 0x789a866da3737299U, 0x8f7f8d94597f4765U, 0x729a84658b8c8b64U, 0x888d7d637e698b71U, 0x9f628160806fb084U, 0x809797a16ca08c77U, 0x7e75a77c955a5f75U, 0x848d8a7d8f777991U, 0x6791926c96b67fa6U, 0x818c617e9680a7a5U, 0x8d8180a76c548c62U, 0x465d978997639f99U, 0x744c797c89735c6fU, 0x7c95856c8f6280a3U, 0x8173865c6d735e84U, 0x94858393578a857fU, 0x3878a5985e8d8e67U, 0x6a55617575818762U, 0xa771629866837c75U, 0x816993779256797cU, 0x838c6c5f66918563U, 0x55847195a0867361U, 0x7b818a8d66879d8aU, 0x748d868c947f7887U, 0x8c8367b852859565U, 0x9f7e948d6e6d8697U, 0x83a89b9f638b905aU, 0x7975a17c6a7d9a6eU, 0x6980977a556d8b77U, 0x867c727b666f9f79U, 0x8c93767a8c89649cU, 0x9872797183569377U, 0x97968a74789d7d73U, 0x7e968468807c809fU, 0x929aa068759d7c9cU, 0x798c9973767f6d7dU, 0xa76377708d918076U, 0x7e7091ab818484afU, 0x9e80807ea3766683U, 0x90697c8676719d8aU, 0x8a878a9880837771U, 0xa572966d79758e7fU, 0x5a8786966b47a065U, 0x617d7fb17b618b6fU, 0x9460854c908e6b7eU, 0x83868a7e8677938eU, 0x649965608f7f756eU, 0x908792707c839b66U, 0x7a837f9d4b7f8f90U, 0x8d696e726a94797fU, 0x72619270897e8461U, 0xa0563d5e846f7875U, 0x8e5072ae5dac5b60U, 0x99838a91ab807e97U, 0x6a918e9465966d8dU, 0x94a383679b957857U, 0x9e917a9098796692U, 0x9d5e9b6e5487385aU, 0xbb6c7160658b607dU, 0x96937468a4a8887bU, 0x875e82a68b7d6757U, 0x80a3716c98708779U, 0x768b7e878d9bbe71U, 0xa97296684a6a7158U, 0x815d9ca95b5e7582U, 0x767a6579808ad066U, 0xb3777c6e5d55847aU, 0x5e9c5e7b9685509bU, 0x797b8da193816765U, 0x83793e879e61577cU, 0x838c7a6c568d789eU, 0x53969d706f896a91U, 0x9c7d61967a6ca267U, 0x9596514d9f5c6f88U, 0xb8777f3f7480828eU, 0x756074745e9d7d9cU, 0x71977356c1778b7cU, 0x87466e4c7292be4eU, 0x74899e9b9e888a7cU, 0x69887166967a8289U, 0x9183816ba686737bU, 0x6884786f5b814566U, 0x7f72806486686355U, 0x7399776671a77985U, 0x75a06c7367576d66U, 0x8296755e938d566dU, 0x77784f63777b9d8eU, 0x89888d70769e6871U, 0x9c9840a445827294U, 0x647367936588a294U, 0x569b989c73608b7aU, 0x87c06fac447d946aU, 0x925a90699d624a43U, 0x7574847a8845756dU, 0x5e70898c923e7183U, 0x79808baf5d8c818dU, 0x8f747fa491775a72U, 0x77809779a1768a69U, 0x8f5baca2706869a0U, 0x687d6f989a938070U, 0x7468bf5e90908fa3U, 0x874f9580886678a1U, 0x64815e9676a9626cU, 0x6a697a98ad86769bU, 0xa97b817159568b60U, 0x629341798f4e9586U, 0x7049719f9f9c628eU, 0xb48e8683907f9771U, 0x839a9a6d826f9581U, 0x999a92a0a774947dU, 0x859637988e808387U, 0x9e9d779e6c8b8c5cU, 0x6f8d707ca9488c80U, 0x6a869bad8f939a70U, 0x79727c86a16d8787U, 0x8562aa649b657898U, 0x6176726a7782af8aU, 0x7aaea78f5e8c7a8cU, 0xb19f69677e8aa581U, 0x9088b68788968f7aU, 0x628a28797a7e60a0U, 0x6a5e926ea966aaa6U, 0xc38ca07f7d796193U, 0x9c8e848280567668U, 0x958463787bb2715dU, 0x7792a6567b5aa896U, 0x87409c74bda36b82U, 0x69788e71619aa495U, 0x6c8b76514a957774U, 0x977f84777a997881U, 0x5b91c3847d4982a0U, 0x74758f81bf6f9193U, 0x818d75784d864091U, 0x7984835d8b878c64U, 0xac6b896e6b9d8774U, 0x6d866e9e9175768eU, 0x43776faa907b9087U, 0x7a77bc94706a7172U, 0x7a898c9ea687789aU, 0xaf9b3b7a9984764cU, 0x998e7a8a3c92506bU, 0x8a985c8d748a4471U, 0x68a08d7f6d6d6a7eU, 0x99817f8882938e84U, 0x8a9a7093ae4f837fU, 0x78668d77968e84a0U, 0x77749bcd8ea99d86U, 0x7c6b8a92999e8250U, 0x85828dab7f786d65U, 0x7680776e816c5167U, 0x626e50586f92978eU, 0x7d7eb37b913c8d84U, 0x5773bf7090997a8aU, 0x80747d90648a8164U, 0x91689b8c699f819eU, 0x799f65a3767e747bU, 0x9c745e64ba75869fU, 0x5e638bae6a976087U, 0x899f5d8f7e688a65U, 0x8ca69197a87f6e73U, 0x8a818d99806c6495U, 0x799d7e7170638577U, 0x766790477c955174U, 0x9488718b7c9c758cU, 0x7c7b67838b467b95U, 0x6786606b8b577064U, 0x7c79777890888349U, 0x754684849577968dU, 0xb37e86736a568b8bU, 0x9d6a6b799297767cU, 0x8a898f946b7c5973U, 0xc86674758f80697eU, 0x749a53a688869b98U, 0x9d92739a71a7936bU, 0x937c89a69f8a9592U, 0x6d875f7a94ac6c76U, 0x5c67aa8e774e7c70U, 0x7e9b779c71848969U, 0x608d7f75a87f848aU, 0x9b9d867592679892U, 0x4e7f6f74677e9597U, 0x936f4e7e87827493U, 0xc4707146955b84b0U, 0x7c74717b886d728bU, 0x937a6457ce7890aeU, 0x5c4c8e69907b7b76U, 0x947c725470858e69U, 0xa7899c81848aaba9U, 0xb35e8077777186a4U, 0x5d735c7774b19c85U, 0x75548754788b959bU, 0x678a80805a657aaeU, 0x7e8da16c3f73526aU, 0x897f7e8c5b7c768bU, 0x7ead6a818a868d7cU, 0xc275717c7b457aa4U, 0x82ac747589609260U, 0x8e8d7d984e6a748eU, 0xa5579283673e8a7fU, 0x889b767775779486U, 0x6db674746a658578U, 0x7d595a7e5887789bU, 0x7faa834f90b26898U, 0x5556b175717a75b5U, 0x7660bc7b9d7c5d9aU, 0x8cb15e5e85877587U, 0x8f6aa86b70747468U, 0x757e89633a757f65U, 0x588a6969814f7875U, 0x8b978984a474b382U, 0xa9bf83516e564556U, 0x86ae9d65888072b1U, 0x689349646c62799aU, 0x719275925f947678U, 0x7a7c8d68976a6b8fU, 0x988174917d9f61a0U, 0xaa864a738a7e8377U, 0x869278898e968c99U, 0x83877b80895ca787U, 0x8a9794809f788772U, 0x90a4706d98807754U, 0x764575936678837bU, 0x6284789ea1818a8bU, 0x5e8569857b7e888aU, 0x66acaa73cd874964U, 0x699a817b81ab4c84U, 0x8b5e7e606c8aa175U, 0x706d866e86705f66U, 0xa79caf6b6a7b948bU, 0xa8a4899a9870786aU, 0x925fa286817b5382U, 0x84687f8e7a7e858dU, 0x7b9196718aaa4d79U, 0x74679d8d8877b97fU, 0x6db077ae8c5fba7fU, 0x8e76499091877498U, 0x65949b6c6b97848bU, 0x738d858ba0918f96U, 0x8584624f594e856bU, 0x8c777c928a757174U, 0x7c869b9692648473U, 0x7e757553a66ba765U, 0x868499787d839a8eU, 0x786975b68c959766U, 0xb75d6e9c58697e70U, 0xac46836ba1606d7aU, 0xa56286696877669eU, 0x83979f7a78996e7dU, 0x6e6d8681a67c6bbfU, 0x6754a0559d616972U, 0x8c8d71706c915e7eU, 0x8d8f5c8b698a5a60U, 0x897a77947b5e7d99U, 0x639863a6a7a18b9bU, 0x81787b9e945a8d7cU, 0x8f83777c81a58789U, 0x8660619b76797f6aU, 0x696390927d848e8aU, 0x6574758763626e79U, 0x748d7c83736a7e7fU, 0x5e977e8280668cadU, 0x5b786f9762826b63U, 0x758f70937476b26bU, 0x7e61999f8f7b9e99U, 0xa3647e7b785f9a6aU, 0x787162636fab636dU, 0x6a7f686785838aa1U, 0x777c8ba17c7da172U, 0x758881966f6a8e77U, 0x6e84749f74969386U, 0x7b49ae897c8f9a93U, 0x7c79457a70726f8eU, 0x8d6aaa6aa6956477U, 0x8b926f8b7e815779U, 0x98ab5d8277648487U, 0x9a7978619b81a179U, 0x72825f5562666275U, 0x6ab0637d90705937U, 0x72434f407e7c6c87U, 0x6a6088996e5b56bcU, 0x7872627371978ec0U, 0x89596991636a926cU, 0x64a27b5976aa8e86U, 0x6579a8886082687aU, 0xb6877c6f88849a65U, 0x4c686d86838a7c8eU, 0x345d6e5f8c807165U, 0x6dba5f90559d9788U, 0x7f7f9d9a6e746476U, 0x797a887e748e7fadU, 0x6f627fa29c4063aaU, 0x86538d46687c7c91U, 0x6670959c5c677b7dU, 0x7a7557a2926d6f61U, 0x7c8857b98954527fU, 0x8e5f579c90ac8e89U, 0x7590704a8f787c87U, 0xb3817c817b6e6953U, 0x43a65f6e6879746cU, 0x675f4774736ca149U, 0x7c646d5382a28589U, 0xa59a7c86a9806182U, 0x8f7851b15e80677aU, 0xa86d663a899c975eU, 0x8f7a97896c6e8a85U, 0x67a880879e62657bU, 0x6fa3a971af74609cU, 0x9250519f95505f6fU, 0xa72e937c91545476U, 0x986492858b528c8cU, 0x7f5e969b7773615cU, 0x9690697f9a715a9cU, 0xa460ce6b976e5477U, 0x92c26b6f2a7141beU, 0x8888546b8a9c7291U, 0x758990878a8f968dU, 0x867786969f549bceU, 0x9eaf995468896670U, 0x79b4929056809a6bU, 0x8b81999883696d8aU, 0x86616ea98274a2a0U, 0x6d60646e7466a57dU, 0x878d52546f9e9186U, 0x9f8b5867369e9361U, 0x5c8a7da7a0729f8aU, 0x9a9f50825473a57dU, 0x4e65927d81b89795U, 0x67809e629f879686U, 0xaa6495746f6b8f7fU, 0x5d7650548d7b7b97U, 0xad55707f53796652U, 0xa272a05f45af628bU, 0x8a998361b14584a1U, 0x597161716d6fb77bU, 0x833f6082af9eae73U, 0x749995657dac648eU, 0x97aeaa8658b18ea8U, 0x5b8a71935a73288fU, 0x73715d4d79797e85U, 0x67812fd324609ab3U, 0x7060d4af6c3a7e92U, 0xb468b5396e8e907dU, 0x56684aa37f314070U, 0x9784626080a95e77U, 0x7c4eaa5d62b26d72U, 0x809f6d62835c4e72U, 0x807786836b71599eU, 0x846f6e8d975e98a7U, 0xaa5f6b8d7c7366b7U, 0x6a98909e73bd675bU, 0x5b89747e59779271U, 0x74889b85c0a46d82U, 0x5d6d7598a4418086U, 0x449261625d6d9063U, 0x856576627f694840U, 0x7b8c7d521776825fU, 0x976b6bc7945691adU, 0x57ca5e6c818b5d8dU, 0x5d9c5e979f709968U, 0x6e7967477da86366U, 0x85798a4f355e97a5U, 0x8b7677929a895688U, 0xa8959a5648a3a64aU, 0x7a55bc6d5d9487b9U, 0x6d6a6abc9a6ea480U, 0x667e5c5074738a7bU, 0xa04dc66992ad3e71U, 0x3d84552eb770449eU, 0x8067989740af625dU, 0x9aa159556a9673a2U, 0x8574709742474b64U, 0x5a818898668aa037U, 0x8f6f86518e7f6ba3U, 0x9b7381a08388766bU, 0x918e8e9b965a7c71U, 0x72775689967d7c62U, 0x8588ac6d8464846dU, 0x97987a8c74755490U, 0x8060707392536781U, 0x6b93849291578cabU, 0xb59d7e999c865a87U, 0x7999408b7c978e70U, 0x8b7184a442a6b567U, 0x6d78a25d8697a375U, 0x8c7c7d778861965dU, 0x938873a4ac7a828dU, 0x8f90585874659e7aU, 0x7c84476c715f658cU, 0x64627b997f96ac75U, 0x8aae6284ad7b9c78U, 0x6b8a7f8c7b7c9f80U, 0x78aa8466816f678dU, 0x749e5c6ac9a06d63U, 0x868e795d8777676aU, 0x9494796a7fa6859bU, 0x84947ca7809765a7U, 0x879a9c868c6a6396U, 0x82415b8555a74392U, 0xbfab8b8969639572U, 0x7a8f818a96867797U, 0x7e686d579a92826eU, 0x759b66858392718bU, 0x82957563646f4669U, 0x798f9b83637a4d94U, 0x8d877c5cb6a49d8fU, 0xa9798288a3957180U, 0xa69a976e9f8d8f6aU, 0x43816f8e945d7c70U, 0x59969a8a7f74838aU, 0x5a7490b9878a7a7aU, 0x8b6d927898848486U, 0x628f80a29d758cb0U, 0x8b886999988e7eaeU, 0x8b5c7ba77085588dU, 0x613b957554ad8d6eU, 0x5c7d9056839b8281U, 0x90707d94978f845eU, 0x578f8e9b7a53966fU, 0x7b8d0097a1905da5U, 0x9360749d7d916f9aU, 0x565395487d755e70U, 0x75bea1639fb9877fU, 0x5f7e90978d959080U, 0xa980858940606956U, 0x899c7b83c991797eU, 0xa9845a80507d7b69U, 0x7c64897552928d7bU, 0xa69e78768b9c8893U, 0x99a7719a70756e7dU, 0x987a839870891283U, 0x9db8669881988998U, 0x98938797b48562b0U, 0x85806e35aa6b8365U, 0x8db199879b8e9576U, 0x68815f47b0796296U, 0x7c646aa574978aa3U, 0xa94fa69a83798194U, 0xa07d988898738a9aU, 0x717fa7ab9e7b8365U, 0x75a46b6172ae8e51U, 0x956d9b8879524f7aU, 0x64a09e65855e249bU, 0x8f7a53507a8f637aU, 0x946466a8757da668U, 0x6da17ba7666577a5U, 0x82895b5c92915f75U, 0x888c8b675d8d9c75U, 0x956b8d50797d6f8dU, 0x7f787f7a8a918479U, 0x434e7f729b71ce62U, 0x84716c804288877fU, 0x878b509e617b8f99U, 0x6d6580839481b875U, 0x60885d947a9b4783U, 0x7095a07e739589aeU, 0x6b9fad7b4f8d4b7fU, 0x946085a25d85a258U, 0x6e745385985b6f8dU, 0xb8617f426a62907dU, 0x87786b9e5c8ea692U, 0x8a799291886f4654U, 0x5a566158a190a270U, 0x64759376b579a266U, 0x56847ea1786b698eU, 0x75716d716fb19474U, 0x5b72a5695f7b2375U, 0x9394404a62706350U, 0x7d8a769959836b9cU, 0x746ead7d7a7d7889U, 0x7968957586537d52U, 0x6f4c8375715ba386U, 0x64876c5d6d86957fU, 0x7f85b76860747364U, 0x6c5780913f856361U, 0x5d6b80a3707b8e8fU, 0x70a562703d7384b1U, 0x8682826c6a86538dU, 0x989954944b747c41U, 0x7b577f9f538a737bU, 0x758a8285604e953dU, 0x8a656f6e9499b263U, 0x7667878c8561954bU, 0x878d449466598170U, 0x54a45655639b5f8cU, 0x7d688278a6618078U, 0x48878464768da5a1U, 0x59b35d82687a8879U, 0x896b5f705e89785cU, 0x96835c8fb1818769U, 0x7d6652596a6f3d9dU, 0x71838d647d8e8872U, 0x6070487d58909c6eU, 0x7d866b75a8659f7aU, 0x7666749f6f737863U, 0xb3b4708c8f8f6081U, 0x8ab49661cb926889U, 0x7c805e6e8b61703eU, 0x90ab587278aaa95cU, 0x96908c658f6b8472U, 0x9668645f7f7d7f88U, 0x87668591766e6b78U, 0x57788a63a09b8880U, 0x918f7b9088867f62U, 0x859c65746b898375U, 0x666770636f6a5d62U, 0x7e7d98907e6f4b6dU, 0xaa4f7c7169607b7aU, 0x97858ba5827b9d49U, 0x5b7f6d6e64817376U, 0x7a72503e6d886d72U, 0x997074858b819590U, 0x843a6b5c726e5685U, 0xa467867f747a5c93U, 0x49957e838d7e9265U, 0x8c725c6e386d685dU, 0x5ba46cab5e70a590U, 0x8a616b60907f826cU, 0x78678359586e6b82U, 0x8b5f89608c44636bU, 0x718eba946d664194U, 0x576693a08e55605aU, 0x536c79819f729276U, 0x8e5471507b638c79U, 0x90737179596c7285U, 0x996f92aa82858b5fU, 0x646f9186ae8b9f74U, 0x4d7c5f3b746b7a7aU, 0x826d7b9c97645b62U, 0x805c7e72ae928c8cU, 0x6b6368985f769171U, 0x8f854b876a9fa473U, 0x5599ad7885a2a079U, 0xa65d735205a65a74U, 0x5f6485678e945f57U, 0x718e45728d7f8584U, 0x7f5bb1806658849fU, 0x687b64b85f7d7a84U, 0xad2e5b917f838c96U, 0x63857ead667e8b74U, 0x8f7f90536e758958U, 0x74724f50a59d6061U, 0x857681bda2509b6fU, 0x8fae6283ac715b7dU, 0x8e6d9dab9173ae9fU, 0x5e8b817a886776aaU, 0x9c7b5f5c767751a4U, 0x626ea75f86678176U, 0x6e7b875e7e937984U, 0x9c9c34886c884790U, 0x814c87808e5aa993U, 0x986d946f7180544bU, 0x96298369a15f8571U, 0x713c758f9e9888a3U, 0x6b65929a9c868b9aU, 0x7f3d7f7b7c5f7071U, 0x797b547870895d2aU, 0x86c16e709d82869dU, 0x8581767876909d61U, 0x73b563bd93a5805aU, 0xc074796c66b8a373U, 0x7583a28d774b799fU, 0x796274868d7f8b7dU, 0x7d6b91aeb185b1a2U, 0x746da27f92389056U, 0x77a9644797819385U, 0x9891989770889189U, 0x56946a649c8f8764U, 0xa570747f6f1f4189U, 0xb2889e8474719187U, 0xaa93528198639190U, 0x628063a677799590U, 0xa8897c4ea24b759bU, 0x638b6a818972b376U, 0x6d46a39096758581U, 0x6f689e867f7b8686U, 0x9071ab9fad4e9780U, 0x81b193848f9e4180U, 0xa08a933d8e886595U, 0x66799c6268a69171U, 0x8a936c5689a07f5dU, 0x63be7857726d9fcaU, 0x957174648c55bc67U, 0x7f89696776a85199U, 0x8b656045a2797ab2U, 0x84af7094afba7e9fU, 0x72437eb370788775U, 0x8383ae716c597c91U, 0x906f9c65a09b3c9fU, 0x7482a2686e85c071U, 0x6cac56674e927f7aU, 0x6b9681a675777360U, 0x7681a08795cc7565U, 0x858b9e706668a076U, 0x94809b529f895f69U, 0x966e6c7e6e687d75U, 0x7a7b76ab5968828aU, 0x8870a99475756588U, 0x81758153736b4577U, 0x955d579172717460U, 0x667c7986817fa377U, 0x8282916f48805d95U, 0x7b6e7a824a6f4f48U, 0x6a83796355995b79U, 0x5f6d648e6e8a7f71U, 0x9a518a9b7859719aU, 0x50654b9075ba6f58U, 0x7280517e456d7c50U, 0x7ba5847faf7e684bU, 0x70677da58e5baa6dU, 0x4b7b7e8172528061U, 0x89544887686a565dU, 0x7e8a5c5678b15184U, 0x735d95ae9b667288U, 0x5c8b6798759c6e71U, 0x6bb350796d7bbc62U, 0x6d977e3b58ac7f67U, 0xa37e6b6d855f8473U, 0x907b5e688db94955U, 0x96ae926062797c67U, 0xa33f6c6b5c6ead83U, 0x617f4fafaf559361U, 0x8869666d81987659U, 0xb18a8e8ba699718aU, 0x77605443a35b4a7eU, 0x786e767d6d875369U, 0xad7d5e6d4d9e8878U, 0x6d798c6c6157796fU, 0x685785779c8f6e70U, 0x9c8b876592617ab5U, 0x4984748874627079U, 0x8e618d777b7c966fU, 0x74788969a1896372U, 0x6ba59e6387766463U, 0x5ca27b9081658276U, 0x72685374795b7873U, 0x7f588d74866d916fU, 0x61805d78577d6877U, 0x936c747e676f976fU, 0x81637b8382638b7cU, 0x98596a807f367b75U, 0x73635058a8928376U, 0x7f8a695f7a877a6bU, 0x8991555f6c7a7b83U, 0x72897f6c926b585cU, 0x559c759e79728a77U, 0x99638a7b4576748bU, 0x957b6b696e786c7bU, 0x758c8e7290625b80U, 0x72805ca7ad865c65U, 0x5b6287a25793788bU, 0xaf767199a9629a7bU, 0x757a6e7d90816c89U, 0x9c487a627c559a77U, 0x4d7683826c5c7e70U, 0x8fa770767f738279U, 0x679c839f866c8a88U, 0x5d5a5b6982906b8cU, 0x8d769752647a8381U, 0x754d9c8f6c6e6c5fU, 0x613e8c82749e6865U, 0x9191b7a69a567192U, 0xa071b29d91798080U, 0x5a7b9a9ba896957dU, 0x9391a873a2907080U, 0x699ebb58d1657188U, 0xa7be798b8443717eU, 0x8d6e59a16f775393U, 0x68767b78976a92beU, 0x67829186907a95d2U, 0xa2789a9c7b799890U, 0x52858568837a9e69U, 0x896b938783618c91U, 0x98835e8487886069U, 0x6ea574618f8a8d67U, 0x98af56866ea76e48U, 0x8977758381a29167U, 0x55789087a792a09cU, 0x8f9d528e4d7e929aU, 0x64b9616d94a89390U, 0x5895735eb0845c77U, 0x877d6f83ae766d73U, 0x724861826f62618bU, 0xa4a3948f657f789fU, 0x8059abb5867687afU, 0x78909d7a8c678c5fU, 0x6eb48b6c64559967U, 0x927f7297a8b48e7dU, 0x5e9b9678b4766f93U, 0x7679556c75886b9aU, 0x8bb5aa4959a1878eU, 0x7b42a63b69436261U, 0x5b7a697e6a9d7781U, 0x8e6895af779f5f7dU, 0x727783838a947f7dU, 0x98867fc699bc8083U, 0x7374907f7b9a995aU, 0x81a8899b70505779U, 0x48b1895aa0666d9bU, 0x8d795e7f635c6379U, 0x86635b9c9f698571U, 0x648e81935c607085U, 0x7ba1736485546c95U, 0x657575418683988eU, 0x894e975c5979696fU, 0x9e735a776168939cU, 0x658d76927c96a96aU, 0xb46279677998a36eU, 0x827888a8828684a1U, 0x5f7368797896a15eU, 0x6e6672992b8a619aU, 0x63777e60a0718089U, 0x60b2ad757355577dU, 0x767276ab3d73895cU, 0x45605f845666a399U, 0xaa8b895e6b8daa6bU, 0x7782a0b57b78c2acU, 0x925c9c736c8a5769U, 0x975b975599669555U, 0x76748775b16d6a6eU, 0x745988a92a648d9bU, 0x74af5255869f8197U, 0x6b59a98e447c3378U, 0x7a5262756574676fU, 0x906d917061816aaaU, 0x818f71606ca87ca0U, 0x777b717c78a56b85U, 0x9b898782809697a3U, 0x749a7d908ea8726dU, 0x7c926faa875e8685U, 0x635e9c70ab819362U, 0x8a6e7a677a878a80U, 0x7d6783944f6e796aU, 0x5f9a7b9376668272U, 0x94a9678e665c8a6eU, 0x895993768f565b82U, 0x728475735c786c72U, 0x907d746a63999d7eU, 0xa47f707a6e7eaa84U, 0x9696968c745d867aU, 0x5d7d927d8b708fa2U, 0x737d788d95776d3cU, 0x8c6d9391527d7780U, 0x915d9068665b5a71U, 0x8477856c6c677aa2U, 0x87688081886b7281U, 0x7e72759d7f7781a0U, 0x736078798463a183U, 0x6a567ca0624d874cU, 0x6a5d905c6d946c6cU, 0x74927a7679626a7eU, 0x68999c6f785f6676U, 0x767777a071979c9cU, 0x6d896f795b7b847bU, 0x65649a877f867377U, 0x956d969e778b6265U, 0x878882e06da36983U, 0x764c8a74887f5c90U, 0x92757786846f967aU, 0xa9c077bca78b628bU, 0x6f6bad598f90c46fU, 0x815988828a838c94U, 0x847f90806f667680U, 0x9494a2888b618dabU, 0x6f628b7d7b938a7dU, 0xad734e7192aa5a85U, 0x7a93848d7d78619dU, 0x87b4798a71859658U, 0x576d617679b4578aU, 0x778268748085b59aU, 0x98925c9ba37b9590U, 0x739f65508f889167U, 0x6391948467797147U, 0xab7374bf7c8b7a87U, 0xa69f84a296c58582U, 0x7d678a5587d3dd7eU, 0xad69a37f987a6177U, 0x7d5f597d7aae7398U, 0x948b7a917b6279afU, 0x8864b4608b90b679U, 0x7692809f66859f89U, 0x8f81468396737699U, 0x6e578472796a9466U, 0x8667ac9b6f8d7887U, 0x747863827f7267abU, 0x8c667a77a389798fU, 0x52946e82867a6e81U, 0x75959e865c8f6c7eU, 0xa462687b718f7a76U, 0xb75e73687b51a1a3U, 0x79aab063ab859d65U, 0x8da4a2a174937188U, 0x5eaa798e4a826380U, 0x698189768b6b7070U, 0xba687b8b5e805a7aU, 0x9c6d669a9f6584adU, 0x7a86757076765ec9U, 0x807b41b36f6f86b1U, 0x9b8b7483a281677dU, 0x76828c4785799d6bU, 0x605ba1647a799a6eU, 0x6f745f856c866d59U, 0x8b7a848092859f6fU, 0x91828e5c5887a65fU, 0x91a88f9c938095a7U, 0x607e777991788083U, 0x87864a7f898bb96fU, 0x7688928770b7929eU, 0x54847c806d914582U, 0x9d445e8a7f8d8288U, 0x7b994e72996ba178U, 0xa460d14a69567678U, 0x8ead65936e768e8dU, 0x77a77d4974827279U, 0x69676e86509c9b78U, 0x705ab196afb6926fU, 0x6e8e899f8dc296afU, 0x96986e87cd6b7c90U, 0x82a2806a79675f79U, 0x4c888063977f774cU, 0x6e8e72ae4f96af8fU, 0x7eafa29a607e9578U, 0xb3847e995d924a71U, 0x84b647769d936866U, 0xb551b456a3b1934cU, 0x6671617952a57599U, 0x4b8a975a9e4cc54bU, 0x72adab7e73416e5cU, 0x54649d607d726474U, 0x774e93205bb5576eU, 0x5969b57e84557b7fU, 0x9d7f7786aaa5a656U, 0x80747ab1817b44a4U, 0x907e784c769bcd64U, 0x899b706f7e664194U, 0x479aa45a6b64698bU, 0x527aa462ba618744U, 0x9798a27e55627fadU, 0x805c7e81b9bc9273U, 0x90a8434a72b6a670U, 0xab6a5580c988a87dU, 0x776184b94fb09f75U, 0x8f4e7b8a879c8089U, 0x8793a7b59cc7c395U, 0x8a806aa7a974c688U, 0x908b809b6e99af61U, 0x64986565c5777473U, 0x8e85b3be49729574U, 0x5a748a90696264a1U, 0x7c52683bd7916888U, 0x8877ac5fa1a3c4c3U, 0x92a4bdb367825496U, 0x7956aa6dae818136U, 0x9683987eb7959668U, 0x67775ca98d88a773U, 0x8567b06f718b9278U, 0xae897573826d8247U, 0xb986978fbf7b7b52U, 0x8b9c6b4f68767787U, 0x8e9489b49b7f637cU, 0x77698e82754095d2U, 0x4da2498a909f789bU, 0x7a9b88a75386a367U, 0x7a73927657c46d71U, 0xa683825c7b7b8a7cU, 0x7c97767b756f9cadU, 0xb16b7b7a8b7bd493U, 0x93ae7a747bb17ea4U, 0x50b1a26989a35d67U, 0x6b859c9993917789U, 0x8b8876718c967055U, 0x7f7f6a7f86857192U, 0x927d7a6d886b727aU, 0x76926993da9b5e7dU, 0x7e497496888e7994U, 0xad725da7745e9586U, 0x86978c5eabb14397U, 0x7b9b863f6c7e6588U, 0x5d6c8c56767f7858U, 0xbdc596ab5da68b99U, 0x8db88673b3a4888eU, 0x8a69a36b419e7b79U, 0x6baf906a81927d9fU, 0x7c81698197688e70U, 0x864c547171a67e9bU, 0x8d72a4a982876471U, 0x817e7693a39b8f7eU, 0x7a9d75806f9a896fU, 0x9188678363895e79U, 0x6589718c8c6d6e81U, 0x6e98977cac755871U, 0x868186793a776197U, 0xa05f6754b0636f90U, 0x4180648e7b55a79cU, 0x8ca19c6f907a6ea9U, 0x917a8b6264727f87U, 0x855a9363806a736dU, 0x895076a3798d759bU, 0x4e95956d8a7e7179U, 0x6397a6866e877f86U, 0x709c789986919379U, 0x79967c859a9f6566U, 0x657c5c7b716f75a3U, 0x7ba96c6e82988a85U, 0x6b92956a616e7f63U, 0x8a8b929c684f7f68U, 0x8f7875a084887a91U, 0x8e79965a84797b7aU, 0x4c5a996c77618879U, 0x8f738a647e636c83U, 0x7a9277556c776d6dU, 0x7f699c91779e6648U, 0x686c71848b798e89U, 0x67b3778783b38c6fU, 0xa26c9f87617a5d82U, 0x775c777c7492634aU, 0x9e618b8b627d7d8dU, 0x63656d54758e8e5eU, 0x87564e72928d947eU, 0xab899153a38e767fU, 0x89779694a562726cU, 0x5c5f987c9d73808eU, 0x7a6b757795788d83U, 0xa192708c586e8289U, 0x96657566978d8f6aU, 0x58825f755b7f6b81U, 0x87787f8d6873ae83U, 0xb8557771786b739cU, 0x718f52927d598a99U, 0x728b827059867f87U, 0x749089946d7b469dU, 0x4d99695f626b8b7eU, 0x857e6b7e776f7c67U, 0x6ea0856b7f73666cU, 0x9364638492927993U, 0x8d7767687392777dU, 0x63738186747c7a7bU, 0x4a84509474669180U, 0x5791a66a717a61abU, 0x6f71979a967a75a0U, 0x6b6857937c825b67U, 0x8d8362529c92297aU, 0x819f88878387859eU, 0x61989a71787a9182U, 0x93518272595c7b7eU, 0x89936b7aa2978896U, 0x7b605f7b799f5c84U, 0x7c9360867d6a7e68U, 0x48bd6ea380af6e7bU, 0x818a8e785f5f846fU, 0x916e69696e82822fU, 0x6b6271766c6e5a89U, 0x7c9c40a3617b4e7eU, 0x9173808d61917f7fU, 0x7b535e6f7b949d5dU, 0x5872858480677566U, 0x977b8e4376489b7fU, 0x829989716770775eU, 0x758055ba65758e62U, 0x486d768e7f847080U, 0x7c718a9997bb856dU, 0x7b7690569e645c7eU, 0x857d978f8b936c74U, 0x745f77999b98807aU, 0x9174886e515d6b87U, 0x849f4c876a94848dU, 0x6ba58560928a6d83U, 0x7d7d83a07f2a5d51U, 0x8f758a7572867b85U, 0x51a3af88926d58a7U, 0x8162907f935b8ca2U, 0x698e6f668175a67eU, 0x2c7978747d69815bU, 0x747e9e7788789e8bU, 0x9fa8979e9f795e98U, 0x79b7876a3d747a76U, 0xb3677c66837c675fU, 0x87838ea35a757538U, 0xa89e8c7ba687c179U, 0x808d639261947e92U, 0x5d887987a06d8754U, 0x6c869d74ae727caeU, 0x958b898c705b7193U, 0x5b64a4ad6c7096afU, 0x9b9073728c819946U, 0x99977555c07da87dU, 0x787a498b599f6776U, 0x51877291676f8e72U, 0x42847c679f639ab1U, 0x9b92969e68577a7eU, 0x61be7d765f80825eU, 0x51597d7b728e744fU, 0x6aaa68857e8e886fU, 0x6080ac7851798095U, 0x90688d8072b2af79U, 0xa79361ab7b98ab89U, 0x6f615d69609c798eU, 0x745e4a9a6c9684a2U, 0x92a3876a92917284U, 0x70a88966838d9f8aU, 0x738b4c718da78373U, 0x63895e8ca5a49237U, 0x5b58697e69848792U, 0xa8b78b5e98afb44fU, 0x86668e68796c9466U, 0x655f9d685ea78883U, 0x2753773078798da4U, 0xba986877a0604f85U, 0x90a57d2ccf728cabU, 0x8d8e758656766c6bU, 0x81b6854d82d67f8aU, 0x709c746966347b52U, 0x987d717a6ea47388U, 0x7390978094887862U, 0x8faf84979c78a88cU, 0x4d857187ac8a6080U, 0x986a9b9090669c85U, 0xb1637ea352818570U, 0x8c7576938a989e97U, 0x8983926789808d98U, 0x827871817faa7e88U, 0x4f9c6b8e8167a07dU, 0xa884894e9c754b73U, 0x9e787f5685967f8fU, 0x7a735c8d80746a5dU, 0x74b1ac898d8e8883U, 0x7e827e66928a8577U, 0x857a9c7a7fa35b88U, 0x829e98704d969a8dU, 0x9e6b977c70827193U, 0x6f939e74945d7d84U, 0x9c84915fb69e71a5U, 0x9e667f565f867c77U, 0x7c6ca98b89819ea8U, 0x9f9d68769f8d618cU, 0x777ba77283627d52U, 0x685e6f5c6e82593fU, 0x7068897f9596635bU, 0x68a180916c8ea764U, 0x8486938d938a6592U, 0xa6777f809c8b8283U, 0x6c6375c13a5f8d9aU, 0x825d5c928972896fU, 0x997e758482789364U, 0xaf58825a5f779483U, 0x81b1775f5e6e9563U, 0x7a7c786d9e9f8361U, 0x7e6b71798f8a817aU, 0x807f169f7c945585U, 0x7f997192776d518dU, 0x8b708797989d537cU, 0x8a8b6f9a658c8d8cU, 0x95a7827299766171U, 0x677a9781514fbe74U, 0x915f705d71855ea5U, 0x79777c3c685b558cU, 0x5f3b49967f4b9a73U, 0x6d9a9177ae906676U, 0x498e9a5d7a9e7798U, 0x8c7c7d9b546d667bU, 0x7b79847c676aa189U, 0x7a8f62709d858543U, 0xb99b9592593b69c5U, 0xa65a8d8b855f4d7aU, 0x798dbb8d4789715fU, 0x7999bb6c724e7d96U, 0x9778888a5d827d9aU, 0x5d764570473c8375U, 0x616f57646b805465U, 0x8577821f7e70627aU, 0x9896be8ec5597979U, 0x5ea35164748c687eU, 0xb78c9d797b3b7f4cU, 0x90a281a562758fa5U, 0x6887727f7a94a58aU, 0x677f797d7ba0936bU, 0xa3887ab26e9c858cU, 0x9e86c4945c888aaeU, 0xa4a5989a66867a5dU, 0x707b6d577f777470U, 0xa778736c7b8d6684U, 0x5865b05d81765c72U, 0x827791848c959044U, 0x66788d8968568c88U, 0x8986828e48454ac4U, 0x777b6b3f607f8d98U, 0x7f7d75ac7f9b9573U, 0x9c82a2a9769caa8eU, 0x6e608e9b77546a67U, 0x696c5d7aa9908463U, 0x6a6b5f657f618453U, 0x79a9708972784b5eU, 0x5e986e4a7f555f9eU, 0x60a47cb0c969767fU, 0x6aac7d668c65d09bU, 0x97e7514d86798479U, 0x6f8f56616fbb596cU, 0x847c656aa150859aU, 0xa65788845d84506cU, 0x6892835a978ba492U, 0x443789847d708ca4U, 0x5b5e696e7358da7eU, 0x91747ea06f713c89U, 0x78a1bfa590bd6273U, 0x487f7f32897084a0U, 0x806574636d8d5592U, 0xa3c07a6c7e84b17cU, 0x9682a09d6b6f6d62U, 0x735c83968b9f6f68U, 0x968d81a393a58d65U, 0x7b70938252969a9dU, 0x8497938d756a7a75U, 0x898bb076847f9c71U, 0x4d75b3629190586bU, 0x808c8c6c826e7d60U, 0x7f61a08f6a657b72U, 0x7c6a7a708d8e8160U, 0x418f416e5d996a73U, 0x72728b9b8a769b6bU, 0xc7695ea67b787372U, 0x956284807b88898eU, 0x7d506f6978629b90U, 0x56ad778286794b96U, 0x4e8d8d466e6f697dU, 0x75aca79993999052U, 0x97889877829e5cb3U, 0x67617e727c6f7063U, 0x9d7d845290897270U, 0x8f7c99897b416f82U, 0x70586a86bb76816eU, 0x9d88beae81a37b5eU, 0xa6726faaa5678361U, 0xa77d527c9f896e4fU, 0x8d76509b828b8b5eU, 0x51b0749385877664U, 0x6e8c877860735b80U, 0x796f749f9c446f90U, 0x716c9e539e817867U, 0x7a3f854f67899470U, 0x806881b67973a37bU, 0x7257b665acb89064U, 0xb5956b748f57799aU, 0x8c719592978a4b87U, 0x956c70626ca9737dU, 0x5e7dc02e7a9c587eU, 0x678bc16b977d4372U, 0x689d5371a950808cU, 0x869556aa7a9c6a70U, 0x6e7f6083b45b678fU, 0x7d749a6e86757196U, 0x798e88cf6d74c173U, 0x675d726a8b95a864U, 0x9e82b5907586c39dU, 0x5d607287aa87897fU, 0x5e7a726c807a7878U, 0x8873627679866686U, 0x6e85926a75996659U, 0x6e7070aaa8ba8891U, 0xa4617b958abfa191U, 0x4aa55c7e39937b73U, 0x989a76797a5a7448U, 0x9a7159819f8a6081U, 0x776c578287817b80U, 0x886787767d9a68a3U, 0x697c72c15da07999U, 0xa2a7796181808f5bU, 0xa16a7e4b867a57a1U, 0xbf9c669c89b0b17fU, 0x768684998d62916fU, 0x74707d49acbc6b97U, 0xb0ad7d6963967064U, 0x676982609d744561U, 0x9c5c6860a4956b92U, 0x886fa7ad958b75baU, 0x67a8917f66919c82U, 0x79829394a290945aU, 0x87698b569994756cU, 0x54a37575777c5d70U, 0x8394905f8b656180U, 0x618262936f4c546eU, 0x6d446e95805a8380U, 0x4994897c36707b56U, 0xa869567a72447054U, 0x7756a052836d809bU, 0x873e8f8f85434d5eU, 0x817753696c909e55U, 0x8a76647d9a89865eU, 0x9e9568708797745cU, 0x6571746b97827b8bU, 0x888387808267935dU, 0x94599264339d8286U, 0x8a958055747553aaU, 0x8a81aa60568a618aU, 0x5c8775be6585715dU, 0x5363759e5b84689dU, 0xa0649d987871926aU, 0x6e8380aa945e7963U, 0x8543878d4e766953U, 0x6d6e5670994c6677U, 0x6a9a87698761994aU, 0x3e647e9a6a4a8aafU, 0x7d87525a86a27b87U, 0x8084706051a47b95U, 0x774a5f8e5976674dU, 0x7d54518597934672U, 0x976a7bb87d97838aU, 0x976f8d9d969f739cU, 0x819d8cca77937c95U, 0x9b9f847e6fb87c63U, 0x7f8483978b435487U, 0x6e9a7d5d92757d74U, 0xbf80595e635f6664U, 0x9e4b5e55a46c8e66U, 0x316d6fa17a807f8dU, 0x71ae6d5371727e79U, 0x68837964857aa97cU, 0xc754b9464f856c81U, 0x8a5d5c954a836db0U, 0xa68845867b80b87fU, 0x8d7385667b8ca788U, 0x688d7b8d8a5d7d9eU, 0x5367627e9aad8845U, 0x7f4c577f67777860U, 0x566d7957893e6496U, 0x56a69e5da15782b1U, 0x8f6d96a35978807bU, 0x4d6e747b7d417ba4U, 0xd981776caa777f70U, 0x6f7b807a676d9dadU, 0x7d73937b9d84786eU, 0x7b656b5a8d6d9941U, 0x59648a7498519a55U, 0x626295b368707e8cU, 0x85b3575f99ab8088U, 0x935cb37a4b514d8fU, 0x88617e7e5e8c595cU, 0x878a75c3798e7387U, 0x957884835c886a7bU, 0xa665496a896e836dU, 0x747f6f809e598153U, 0x806e877fa5898667U, 0x777f628257ba8fbaU, 0x5067a5918eab6271U, 0xa26bad4c897e917eU, 0x766a5c7685857083U, 0xa1919d6b6c88716eU, 0x886391739c6c676fU, 0x8e797dbc5a9e8a7bU, 0x6d9858bf788c6a7aU, 0x7177856a9265878cU, 0x7e869b8794617e6bU, 0x4d767a738557605aU, 0x626d6478725d987cU, 0xaa9476a1725e7b66U, 0x7199b091919e6c95U, 0x7f8f6b8475a5b29dU, 0x9a958d8c5eab7a71U, 0x88a05e799776b776U, 0x85838f7f5e7a568fU, 0x4497927fa4929a93U, 0x6c857388887fbc91U, 0xa26077ab9e918584U, 0x958c6a887b626f90U, 0xa287b3906c67816cU, 0x7b6f7a7e464c5790U, 0x7e556e81816d7772U, 0x87716c97978b8c6eU, 0x8896856a5b899182U, 0x8679596a71546861U, 0x7581967c80946da4U, 0xb483858972627e8cU, 0x91b1849f938ba19eU, 0x61b1ab71b7a16d65U, 0x5ca75f8892645da1U, 0x4db19555815e6b98U, 0xac747b6365507e5eU, 0x95476a7591649b66U, 0x724badb74d5d7a5eU, 0xa08d8d537c70a190U, 0x86767f4668798f90U, 0x70946e6f7864686aU, 0xa0777141447e7087U, 0x79905e948d89736dU, 0xa79f41836c89b159U, 0x5a7d80a3834d8f8fU, 0x66607f5c879ca368U, 0x8960808e25b03a93U, 0x7e6e6e738463686cU, 0x49aca884845d5d8dU, 0x6e8f617a6560632fU, 0x3d606c84487a6ca8U, 0x7c8f7965c6a1889eU, 0x717ca994835da595U, 0x9b4f947176794d71U, 0x607a7f3d95708e78U, 0x8171932878208c4cU, 0x4067898e47286e76U, 0x7bad4e7593b880aaU, 0x7560bb7d5c5d637aU, 0x9e5d7b80456c3e53U, 0x87766960787d6c90U, 0x9c779dac657e8773U, 0x8d5e6883878aa496U, 0x848d79936eb370a2U, 0xa48da78d807f7172U, 0x7e7c509d776e5885U, 0x51708c48927c8a96U, 0x9d816745858c6251U, 0x845e646d8792805eU, 0x59817e7d498c7548U, 0x72856b4f7f6c9d66U, 0xa38d757d888a8681U, 0x9c56749386565383U, 0x956f4e4c5d6c8490U, 0x6f8d779187658f71U, 0x8983856378848f8cU, 0x759f7981a33d7477U, 0x717b706264878354U, 0x737d9b7f4d825078U, 0x7d6d965f8c5f8c90U, 0x68af9d7f918b7187U, 0x5f8e78974d619850U, 0x4f80769b7a77718eU, 0x79795c59b883a49bU, 0x5f778d8884528664U, 0x9b43867e8f7e5f50U, 0x805b6e846d716c67U, 0x4e679b7387559663U, 0x647a849b60637179U, 0x9a845359a2928897U, 0x92559e887e87716aU, 0xae687b66766f7255U, 0x6e9c9d8499897682U, 0x54904061698f5f79U, 0x5585586f7395668dU, 0x9d7b8a5d4c82679eU, 0x6d6461717e518ca0U, 0x766d2e7e9a867e86U, 0x815c588a79adae4fU, 0x74716a568d5e9c87U, 0x969f9d8970bb4976U, 0x99708e707f8e8268U, 0x5b7d6e5b8480886fU, 0x76668264994e7992U, 0x7787618d7452a98aU, 0x8b7d845a826e6179U, 0x9e9484ab6c975368U, 0x8367aa6b9a51958dU, 0x807578749454507aU, 0x9d7a89654d805b67U, 0x86885b51ac579870U, 0x92549c8964605858U, 0x565077a4759c7f7eU, 0x68927f39858b74b8U, 0x6b879e7a9e63a38dU, 0x566ab46f6e866378U, 0x64805282666c755fU, 0x648785736a8e7c85U, 0x9265948e68958b72U, 0x577b6e5d90577485U, 0xbf87869d75999f58U, 0x7f7460987f1f9859U, 0x96857388746baf75U, 0xa89a8f98a08c9995U, 0x817d866286999a8bU, 0xc19083a99d829165U, 0x705eb177a59a977fU, 0x6570828b727f8295U, 0xb47741684aa76c75U, 0xa77384b97e8a73a8U, 0xbb7e98453c4f849eU, 0x5da488aab670836bU, 0x6d8f9ebb5d977f59U, 0x6e9c867b834d5467U, 0x768d6ca093788968U, 0x7b3d9199a0716ec5U, 0x9b5b8cad698f9b8cU, 0x89ae6e65598a687dU, 0x745ca27d9c987c89U, 0x90689fbe29675b81U, 0x659a877f6e9fac8fU, 0x8c868169ba9c93b7U, 0x613fae85808866b3U, 0x97b98ea57d757e65U, 0x8e7daa7f55867994U, 0x7d71a1a38d4d9876U, 0x6eba6d64916d4d6fU, 0x7f2a5963974ba999U, 0x71b57a6287748269U, 0xb19f88917da29f6eU, 0x5e897c8cb1649092U, 0x4b73586fadb16972U, 0x93ac827c75529e93U, 0x728d7ab45fad85adU, 0x743b5c625fb8679aU, 0x79a437ba9b9aaf60U, 0x688c7b979b939e5fU, 0x89779d9c807983a2U, 0x86526b64596ca9a0U, 0x896781bbcb606a58U, 0x837890708c597666U, 0x5b64a081ad8d819dU, 0x2d9a75747591529fU, 0x8254646e857075a7U, 0x8a8174829b9d9475U, 0x6ea57689898a7c6cU, 0x89685f6e80644f80U, 0xa99996b4485aa67aU, 0x804fa38b75714268U, 0x828073607b8a918fU, 0xa5599e9291676b61U, 0x5cad3a7f5bb6a45eU, 0x86a0668f637b8f74U, 0xb3986a65936c8898U, 0x6a8294614a8b6a88U, 0x5c6587507e6192b3U, 0x6883b56d854f6286U, 0x6ab890856f76db74U, 0x45618b952b7f6c8fU, 0x66ac6aa1a794b16cU, 0x7c7a9a9f88527789U, 0xbd5395a58378815bU, 0x57526c7c43537c84U, 0x5a6d785742655f5fU, 0x6e83747b2d746986U, 0x6c6ea17e9485726dU, 0x766758796e9b695bU, 0xad7c24625b808667U, 0x6f648b6259466e82U, 0x749498734c7d6f8eU, 0x628f946369888692U, 0x6f8a6a8960919681U, 0x8c97ad9570646f6aU, 0x42a54c8483576497U, 0x7b67836e897f918cU, 0x6f76507864745c76U, 0xa36e8165a18e9d64U, 0x778d758c5c867469U, 0x7c8a7b7a7861707bU, 0x8f9c71697480888fU, 0x957e6d677a417280U, 0x7076a46362737c74U, 0x95988c8591835a8cU, 0x865e7d497876b28cU, 0x7c945d7796747c9fU, 0x6d7a595662a77a91U, 0x74546d8166736766U, 0x838a9d889c836f82U, 0x4e9a77979d627996U, 0x4e7484847e64a94fU, 0x459071707977848bU, 0x9292536e8d69826cU, 0xb17b6aa27d749675U, 0xaa77767c848f7179U, 0x926c8e5f82738385U, 0x5f6a54759061944bU, 0x756d827e6d757b74U, 0x6f88578daa665782U, 0x93477e55688f7687U, 0x93467670735c9c69U, 0x944f7e907e5d6360U, 0x854f70888081754eU, 0x6f505578837f9671U, 0x8c8771708d9d7881U, 0x77627e9289798769U, 0x4d486f6f6b864590U, 0x6b4b96788f867359U, 0xa266673a7d846f72U, 0x7f665a86968a516bU, 0x577b537c83879260U, 0x8982517caf746baeU, 0xa26d778e4080646eU, 0x788563726e897088U, 0x84544e815e4d6782U, 0x67a18c9e8f696e96U, 0x575e566c235b687aU, 0x656e818984707e8eU, 0x63829273678d634bU, 0x685e6c82997e6b66U, 0x9b618a6f6a739471U, 0x9366ac99745d9774U, 0x956752777b47ab69U, 0x8085aa6d5c865468U, 0x58706b80803c6095U, 0xa1973f6774724e3bU, 0x95777362897f4d7aU, 0x85697b767c9a3282U, 0x3a6a979c71616e69U, 0x714a6c8a6b867290U, 0x94688b61a2687873U, 0x604a676898785d7dU, 0x6e6855918299b0a4U, 0x777c948f84668c80U, 0x6d6181687798687dU, 0xa06c4f97867d8e86U, 0x8fa2959784997c5fU, 0x59807a9681669ea2U, 0xa79293637876a45dU, 0x9276548275735096U, 0x83799c71688b8fc3U, 0x9477939a8f679490U, 0x96924a979a7389b7U, 0x949e7f958a78699cU, 0x63aa834d3a836f6fU, 0x527ba07e788f787cU, 0x6f7280a6878e719fU, 0x95948a9c73559c60U, 0x7c8e3b549ac07056U, 0xa58f739b717c846eU, 0x73777d73866b826cU, 0x9ab26e8c61b0925dU, 0x925e9f7995ccb382U, 0xaf658a7562726179U, 0x8d65926f97a7768dU, 0x7070548b7e6c8fa4U, 0x7878c85d3277705fU, 0x88a86b7059ad5189U, 0x73ab7b8d62867ba2U, 0x958b686f60a2ab73U, 0x89a06f9aac877989U, 0x7a736ca15cb8737bU, 0x5e7a8f564d5b998cU, 0x52a57c7d576d6f64U, 0x838865526599839dU, 0x38616d953f74a0b8U, 0x7d82a6d3948d5da8U, 0xb992cbaac588539aU, 0x69a48fd278baa8acU, 0x6694ae407e8d773cU, 0x95ab95a9a2245598U, 0x38b77536bd3f3dc9U, 0x969f469157712c54U, 0xa04223cb9d7da98eU, 0x5699c4b35455aea3U, 0x98bab02c714f4977U, 0x3d73af32cd7dbb85U, 0xc564d65460503c5dU, 0x817474553b946499U, 0xac62774785a4c652U, 0xb1ab95819397b464U, 0xb8954bb293bb9da5U, 0x8a5a5c6ec688e289U, 0x626069704aa555caU, 0x3d939f50a5828e8dU, 0x43ae9343933758b5U, 0x7296ad8c43a58d3bU, 0x2d531e93785587a7U, 0xd07c7c5aa2c88465U, 0x6554beb66e3aa1eaU, 0xb63b98af46a93866U, 0x367a7e0c7e3bc73fU, 0x6f69687edd6c7c55U, 0x60ad909b5e70a7acU, 0x65c94c5ba5f2a0c4U, 0x9c93ce7c2aa6008eU, 0x8f473a623b3c2b55U, 0x5e938f59207837bdU, 0x8d8184668e97969eU, 0x82906ea476798e92U, 0x9f8e78a09381a086U, 0x829aa16684806b74U, 0x958e738294527671U, 0x68a1785a9a7e838aU, 0x6891719e926b887bU, 0x6d808a7fa6947d86U, 0x859db69c6172714fU, 0xa28e8a9763629d7aU, 0x914caa68a39f6badU, 0x9c8384a872797f7aU, 0x8d84796b70967f67U, 0x8e77928089978473U, 0x8eb0838b9facbf80U, 0x7e9389918d84828dU, 0x709f85648794aa61U, 0x8873af7d58a07e96U, 0x877e736c877b72a7U, 0x81a6806d8084776eU, 0x67a597878f9e5f70U, 0x5d8494a8496b8784U, 0x9d6d719b90688788U, 0x5b81b5ad8a7f7a79U, 0xa8738067546c4581U, 0x6687767f7e5c5f84U, 0x79a762737569847dU, 0x898bb5827a52a1a3U, 0x8cb36992559a9193U, 0x889382879b99838dU, 0x7e5b75816e738570U, 0x384970ac70706b81U, 0x8760b8bcb6644f7aU, 0xbd70d797ae7e6b79U, 0x7c9c8db59f948b72U, 0x668ea25b757e6654U, 0x898db65282903792U, 0x5ea4475e8b2e51caU, 0x71b13eb77fbf40a8U, 0x83a42eb0926d7fadU, 0x825c7f98b67d81e6U, 0x76a5918065a05b5eU, 0x5c9c7d4a81778f7aU, 0xbe5bb3a96a909778U, 0x53875490717a847aU, 0x5778657e7082bb71U, 0x8c8f668a66924482U, 0x838c896f8edd6746U, 0x4d665d99a89cb89eU, 0x65775c6351c2a19cU, 0x35a368a889cea27bU, 0x639d7c448d58784eU, 0x8b4b749083836e6dU, 0x7158569a8586579dU, 0xd0658f9a78ac7c74U, 0xbda78c7e53cc65beU, 0xa6948d7d5d738982U, 0x746e804387827b92U, 0xc2635390c4ad8b96U, 0x5daf977ea17676a6U, 0x7d886e5d9cc76598U, 0x72af9f6d47c26595U, 0x597a725e74585a59U, 0x73915ea9388e928eU, 0x976491848e768e83U, 0xa7998f74807f6678U, 0x81978cb0a5858599U, 0x579b87736a78766fU, 0x60b26da96d7a779fU, 0x53887767a25b60c7U, 0xa28a8c7c66684f75U, 0x665cac8989989b7bU, 0x75817d97659a9a7fU, 0x82a38255617c746fU, 0x728886489e839871U, 0x75777c617ba7498bU, 0x76657e9581995090U, 0x7f6f7d837d628a75U, 0x897d6d988192a151U, 0x867c67877864cbb4U, 0x68849d749e91c351U, 0x6f86b09f69b47599U, 0x6970a875b193a497U, 0x6f93b49071494cbeU, 0x6b7d9c9b61929368U, 0x6e70477e635d9579U, 0x998b97687da5b871U, 0x4f7cb59e926fe0a7U, 0x8c4e77de62866664U, 0x5a8c674c905bb08bU, 0x6c6f633c88587f44U, 0x525e76755e448987U, 0x4f85627f92aab68eU, 0x7c76a75a866a9676U, 0x9170578865665973U, 0x9260779f593b4c94U, 0x6869715982997b4fU, 0xac665277886998b2U, 0x8a7280859d7c5f7bU, 0x9c599b9eaa526d91U, 0xae7aa4598f9cad85U, 0x70537e66737d4b84U, 0xa28c705c5677737aU, 0x8463934b6cc97963U, 0x6165858e7879aa56U, 0x959b7165808fa092U, 0xa66491645790897dU, 0x95774b956d815b83U, 0x887ea087766b7d77U, 0x4d7297676b673086U, 0x848c6b6e9c7f7484U, 0x96a0875f7872767cU, 0x73a78f8f648a6c86U, 0x86887a7d8b658a95U, 0x7e62788a788e6871U, 0x8b6d7d927c828e56U, 0x90987685565d8eb9U, 0x97a1955b7884679bU, 0x566989477a616674U, 0x5a6e4a798b79895dU, 0x927c7556a586748eU, 0x7f6a92826f7d6882U, 0x8f737b848b777877U, 0x886f8b6759707461U, 0x82598f70657580a6U, 0x6f62459a9687616cU, 0x7ba4805d77905c84U, 0xa180806f7c6e8e73U, 0x4d8662659198a465U, 0xa793596da09ea381U, 0x7781816f80976c7aU, 0x547d849d956d6572U, 0x6b885d845c9d7488U, 0x917091886f849659U, 0x8c557053815d838fU, 0xb0836e4ea5705d93U, 0x628869ba69539f91U, 0x973c858189735d9eU, 0x744a9f61458caf7fU, 0x77826c5f65827656U, 0x9687808782805c7dU, 0x81937990827e9a97U, 0x89588656647c856eU, 0x7e5d5a92736273aaU, 0x7b77a34d5b635e53U, 0x7fa73f76685c743fU, 0x957e6f777e978899U, 0x6390787e657a62a0U, 0x5c7f698099865d78U, 0x8e6b657f4d66948eU, 0x7c899a5f50807083U, 0x6196708289876992U, 0x5b73996e8f894c7dU, 0x938685812a988e69U, 0x6169a37e84649264U, 0x61797d7e48958299U, 0x6c957c579a528e78U, 0x748569826458734dU, 0x71745c6f8888697eU, 0x7e8778516292848fU, 0x786d76968aa08891U, 0x7a6577788da8978bU, 0x81a08faf7e7ba382U, 0x6d76766c668d9e60U, 0x5da95c8670875a92U, 0x37849d529b749a9dU, 0x9973765979497481U, 0x98657286a1839649U, 0x748a9188498a7b66U, 0x737d654585736d99U, 0x9c5b80698d95ae7fU, 0x7f5274716184607cU, 0x9d86746e6077888eU, 0x6c959771a3896388U, 0x8f677b8c6961895dU, 0x8d8163929c45899dU, 0xb7675575648d6b6bU, 0x5a71a25c495c4790U, 0x88678952916b7b7bU, 0x6e9e8e92654759b7U, 0x436f9c84758a974bU, 0x4185a978735f7ca0U, 0xa09a7565c77f9f77U, 0x786a5a74856b9e9cU, 0x90219dbb4a995183U, 0x8a68985c9c6c8287U, 0x5b7c674a99416253U, 0x887390943b5e8e6aU, 0x599370648f9a887aU, 0x6e4aa47f67657f9dU, 0x967974b4666c9376U, 0x558c908e98935e64U, 0x956f856294695b86U, 0x767eb3887984697dU, 0x8eab7c895d946369U, 0x9a5bba4d6665a984U, 0x8669ae78777aa27bU, 0x968c4d6a70548794U, 0x66b677997887a485U, 0x746293815f9c7588U, 0x78746859a1c882b2U, 0x3e6c7b8a6299845eU, 0x6c87909acd96866aU, 0x8d927099928e6495U, 0x6b8973888b829968U, 0xa15972847479647bU, 0x7b86a151907f8481U, 0x94706d7899a6684eU, 0x574c5f686d8492b7U, 0x9d5d596ea080be62U, 0x71a86c6591bb9c5fU, 0x7e372095986e9159U, 0x8f848f7a83b3637dU, 0xaf8e6e9c98938f5cU, 0xa19896837e967176U, 0xb29d83906f958eafU, 0x857a72c14bad7083U, 0x607b5464ac64a08aU, 0x98745f938b8da58dU, 0x9d887da47f948f8eU, 0x636f92809ac263a0U, 0x6f866e6a6a786694U, 0x648d9d9cad5a618cU, 0x825aab837f65706dU, 0x967b76ab77a3886bU, 0xa8798a89b38b55a8U, 0x848a8f6c4ab07f7eU, 0x5c8a9b8b83a99c73U, 0x965679b767785cb8U, 0x7c81ba639e61889aU, 0x9a945c6564b95b91U, 0x697f5e866e769c61U, 0x746c9b9186a19ea2U, 0x7fab7d9c8c7b9f80U, 0x78857972bb7e976fU, 0xa667a9807294849fU, 0x9369719b54668a8eU, 0x545b7a7e8b808b9bU, 0x854b9b8780736b7bU, 0x9e95779092898d9bU, 0x646e7d80807b7887U, 0x89655bb47aac7f93U, 0x41a883a86882b567U, 0x6bbb8e6d8d9fb072U, 0xa982958b6252897fU, 0x8f7e5b7369b17785U, 0x8b80668f555854a7U, 0xa18bb494746e9ca3U, 0x6d7e958394915d9bU, 0x92869971c58e7c78U, 0x647c8b96c196b87eU, 0x7d9979a16f829681U, 0xb9718c6e9da796b0U, 0x796c829378b0437bU, 0x627a629eb2948385U, 0x8aae79b0796b6b77U, 0x9e4fb9956c828140U, 0x8d3c6f7a98969766U, 0x9a8f7da9ae8a7499U, 0x9d9e8c748d9b868cU, 0x6e7883776d8d6a9bU, 0x4d788a4a417f6092U, 0x9095b89b916c957dU, 0xa36e44a1847d8f60U, 0x90a8ab8b6b794c73U, 0x84a85f808b75707aU, 0x98ca7eb6ac667294U, 0x9a72859b88b5606bU, 0x72646177734c9f91U, 0x95678c989e747e73U, 0x6662a1a285888c7eU, 0x7e7f939164667e73U, 0x9f92508cb293b79bU, 0x548f8ea18aa47cbaU, 0x3a9398847e89b371U, 0x8d6e9b8b787c51a2U, 0x4693b2944b72a2b4U, 0x7c57666297697699U, 0x58716985ac9c8468U, 0x4a977994636c9a8dU, 0x9d6f8bae80988599U, 0x7d6aa9b28f528a96U, 0x46848990678c68a0U, 0x6aaf79884671799aU, 0xaeb3817c91a67970U, 0x605c419f73c58282U, 0xb7bc3e8d8aab7d84U, 0x936d90708e597477U, 0x7a6d6b7e7f958b84U, 0x838b746679987789U, 0x5b90809260958289U, 0x9c8f936d84637b8fU, 0x857d9b927a797586U, 0x789b846c63807458U, 0x7a847fa14c729e7dU, 0x7e5b9d667d9c8379U, 0x4d7f7f666a75a84cU, 0x8b798f76828b7aa6U, 0x91746962838b7f7eU, 0x807f8e7d65777d7bU, 0x8d82736e79978d87U, 0x76a7775197866085U, 0x9a71ab897584747bU, 0x6f94948a849c988fU, 0x816b93718197818cU, 0x8770658d8c5f788cU, 0x8a8d8b5c826b4c82U, 0x829e8373888f6471U, 0x97838b76786c6e7cU, 0x72848c5b8e868193U, 0xab62858e6a5a7c73U, 0x6d7f796c8c939f65U, 0x8d66726c84886c80U, 0x8b6a825184848a58U, 0x607b8d5d7d6b8577U, 0x916b7e7996538f6fU, 0x9c88618a818d93acU, 0x5951659d57645199U, 0x6b6b6f786d9a7e7fU, 0x678b985590ac937aU, 0x5a94537798656aa2U, 0x91959267585b525eU, 0x7b758f5a94a16eb6U, 0x799c895c72668f7bU, 0x68675952bb9d9683U, 0x665c86969c8b8e5aU, 0x5f71848ca0788b7dU, 0x527992935f8a53a0U, 0x9f67679a77926173U, 0x5d7a66828a899068U, 0x3a51805890727245U, 0x5dbb707b83bb8b92U, 0x799f956d4b777562U, 0x9f977877739066a9U, 0x67937288ab575b77U, 0x8a5d7b718c6489a6U, 0x70879b776c8a7d98U, 0x62788b86ac7e713bU, 0x7c686b947b70627aU, 0x653f6262808d7888U, 0x7f687953b3ba585eU, 0x7b8069877c73795aU, 0x84a1817873d56978U, 0x8881406f77825e42U, 0x8c8387a0627f817eU, 0x8c817c6e797a606dU, 0x9c79429e638b7b90U, 0x8697785d998a7d87U, 0x7b6c7578923b9266U, 0x89977783b18c978aU, 0x568e85588c6a5d8cU, 0x8b6982937d537994U, 0x97676ea4838ea589U, 0xa3a5738c9d896494U, 0x76848660968b63afU, 0x8487b4877a696e84U, 0x6f98b96e786e96bcU, 0x988c8592aa89a665U, 0x9c807e655f87847dU, 0x817372858089929dU, 0x8a8e6baa8478a5a6U, 0x7da09abe9da286a3U, 0x97957c8c7e6aa076U, 0x89a5867b85ad8b78U, 0x8f849a967557977bU, 0x9d747e777c9b609bU, 0x8e76806366596267U, 0x905b877b6296928fU, 0x8d839eac867348b0U, 0x8a735aae7b925d75U, 0x70797da0b989ac5cU, 0x74788ca072809981U, 0x8571a1659b72bc54U, 0xc9a0718a60b67365U, 0x5ebb605e7d636291U, 0xa06688949664afabU, 0x695e7d76a28d8568U, 0xac989f50aa71b48dU, 0x7f60b381acaa878dU, 0x924f73698e939d89U, 0x7ea6a78877847080U, 0x977a649a63854e82U, 0x7d969086a0649989U, 0x647e6f47aa80658bU, 0x9e76797782819d90U, 0x5d9686708b757fa4U, 0x939c82735a6072a0U, 0xa886865e4f5ba56aU, 0x66968c9d6f817e80U, 0xb56eae578f75828cU, 0x5c877d867c69865bU, 0x6aac9e9e4db3ad4fU, 0x5d9d98867d907561U, 0x9e82858272846e56U, 0xad5b6e86ac6144c5U, 0x846c6f72723d9d8cU, 0x81789f4250a0666aU, 0x628db56783a9728bU, 0x8b819cc659507774U, 0x82a476959b9d8894U, 0x805d654ea7857eaaU, 0x73778a4c6656588eU, 0xab91a16da9707578U, 0x5fad67947d704d81U, 0x597b708d7b437f4cU, 0x5d93a37885906e5aU, 0x665e448798734c91U, 0xa19891a78d5b9159U, 0xa76c6f9f679c6570U, 0x4f63817ab16c588cU, 0x5b7c4c48877e6a83U, 0xd68b87668f5ca53bU, 0x888c64b585867e8dU, 0x6c408778628e818cU, 0x746771ccb37cc650U, 0x8758716f9aad6f71U, 0x608e609d9f9188a4U, 0x598885b3929b8198U, 0x79ac9591709ea4b6U, 0x6dabb48c599ca93cU, 0x5fc84f9295486d59U, 0x6195a34db66f7891U, 0x9878747e8858503dU, 0x98697d8191639c67U, 0x6f66849c417b7666U, 0x75966d3c725e9a7fU, 0x8e5ba64092a28f82U, 0xb2806f375b817793U, 0xa1737a6d397b6e87U, 0x81727b987a8fac89U, 0xbb70a06f7d7ca08cU, 0x7d778aa2b7697fadU, 0x71697585768ba760U, 0x855057764c8e6e53U, 0x6b6d7c5d79846a7fU, 0x5a9a8869ae4e848bU, 0x64507bb6637f5621U, 0x5761818b6b6e8380U, 0xc5697f68c2558490U, 0x919ca38d855c7a8fU, 0x7176796e5a9d6a6fU, 0x545f874b757f905eU, 0x749a94649436ab64U, 0x596082ad7565ac86U, 0x88c7585cb4a7939dU, 0x8b76bb887e4b448cU, 0x67628c8161787f51U, 0x519f769ba1a16098U, 0x82759289886a6d86U, 0x986e7da195736876U, 0x6c5986949f897ca2U, 0x676b3e5f76949669U, 0x5db08f7475689fccU, 0x638f766e5c6c6e74U, 0x587a698b778e815fU, 0x5bb93d98ac8671afU, 0x8b6aa58e83836f95U, 0x737f5270a494445eU, 0x3d7b77903d6a948aU, 0x5a96619e7376807bU, 0x727c9c5a90797952U, 0x8a5aa67bbea15a70U, 0x966c3f8f707d806cU, 0x964e497f559e656fU, 0x9e698a9298949e7dU, 0x899a849c8c965e9dU, 0x6e9473a57487ab7eU, 0x7a9f83a3669f8f73U, 0x82875c788799bf5cU, 0x77a75f85516a7290U, 0x7d99695b87918d88U, 0x8f7172647498a5b4U, 0xad7d8b837869918fU, 0x6f466d44977b86b8U, 0xad743c4a9b7a5467U, 0x6b8c835e9c4a71a7U, 0x759f6f717a777d58U, 0x8d8b624d63c6527aU, 0x87855567733e4f75U, 0x61958482577963a0U, 0x5c92833f9273957fU, 0x738565b67282928eU, 0x7f69967b876eb28bU, 0x838b89828d2d7582U, 0x7da078907473c769U, 0xa852728b74b19b80U, 0x54606f7baa8a949bU, 0x93737a767f958295U, 0x58ae69926f739d55U, 0x89729192787d7c8dU, 0x809f9aa6649651a0U, 0x5a997e8f9d7e8869U, 0x70b0bc368f9d847cU, 0x7f88c660927b5285U, 0x978a5e9397696d66U, 0xa4736b805a5d7baaU, 0x9f7f69747b8c686bU, 0x7fb1c5586797b681U, 0x9589a77bad775fa6U, 0x7e7e89845f887d95U, 0x389b876fa79f8e65U, 0x8c5b82653a919381U, 0x51966e7278597161U, 0x56646e90925d576eU, 0xbc40a589987f8a73U, 0x788a857049703792U, 0x94a8596e5c625776U, 0x9b6b9a43729a8778U, 0x625d9f8d594f829dU, 0x719170869784b379U, 0x72706b895f6f9476U, 0x955a83725b58658cU, 0x89765d6f798e9571U, 0x6e5142506c807e96U, 0xa375967191987266U, 0x744b6fad956068a6U, 0x6e337275ae86557cU, 0x8d59ac8c819a8362U, 0x9c868545898d8196U, 0x977b7358669d5796U, 0x749066897e9b8d71U, 0x8a735783b589a2b6U, 0xa9456d945684855cU, 0x8e8363915d7b81acU, 0x846387797b586887U, 0x509382aa705b70b3U, 0x85675483475e7fa0U, 0x48689564776d5682U, 0x7ea6bd7e75856289U, 0x8a8e696eb744757eU, 0x9c7e859f7b5f878cU, 0x8e688b8a88628f74U, 0x8c8b8486a972a990U, 0x8a9e9c727385827cU, 0x67808f6e685d5b8aU, 0x91643c4d60956f3fU, 0x74987e50a98f9c7cU, 0xb28976875a873b56U, 0x8f7e93906581928fU, 0x88776c5874878579U, 0xc35e85709c755a7cU, 0x4d7a688aa0834f6bU, 0x6dab896daba89f95U, 0x7b65746987a99378U, 0xcc8567a3958a765bU, 0x8b608680ae5a9461U, 0x927a98896d8e8e62U, 0x8a8454744ea08889U, 0x8c64829469808b8fU, 0x9870869835885d65U, 0x4c7b95a68691958eU, 0x6e9f7895619d8557U, 0x7e5daa6677626f6fU, 0x89977586a96f767fU, 0x75636898884b6987U, 0x8d4796a5617d9878U, 0x8b86599762988377U, 0x7a6f8f70a779986eU, 0x7c8e78b5718a7272U, 0x5d817f8561b18693U, 0x8f5a7263c286a289U, 0x6179a47e658588b7U, 0x92a7959b61965f6fU, 0x8264a7a845536c8eU, 0x7d718599905f838fU, 0x618f435c76877f88U, 0x4c34457a64559095U, 0x76a85d7285838876U, 0x969a8a9169709585U, 0x688c8fa292818298U, 0x7f7c5b71b3a64d83U, 0xa7a9728fa0559870U, 0x638f84939d937d80U, 0x4f6e698963b3937eU, 0x9da653998885a777U, 0xce849d6b7c8a8792U, 0x849b5b368e848e7fU, 0x5d936e666d68784dU, 0x5b6a84538661468cU, 0x77974ba18c3f5d90U, 0xb2859c9c715ea559U, 0xa37186a7378e836eU, 0x5d5e96808f9d886cU, 0x9396b08576a99590U, 0x4b9459887049a077U, 0x8366638baab8617bU, 0x6e8a699b5d727190U, 0x39a94d8ab154645bU, 0x64c18e939d9d4990U, 0x667e75638e935b44U, 0x7c9d8b8177917c79U, 0x756e7b60587f9ba7U, 0x897f89667c5e807fU, 0x8a8f997b9149a675U, 0xa378938ea3777799U, 0xbc3b668e5fb17882U, 0x909b82549d9b88b4U, 0x869d787ba3a89870U, 0x4f6ec37c512b786dU, 0x65637f7c845f5044U, 0x6c66987ca2629972U, 0x7a8b85a7458e92a5U, 0x60907b7984805e77U, 0xba5684649ec78164U, 0x5c88babb4c469c58U, 0x7a8848aa766ea449U, 0x64876885956ea965U, 0x8e3f5ebf5f57977aU, 0x8089b1e7c488768dU, 0xaf85928fb78a89a9U, 0x7e9badb69bd1939eU, 0x61b8af6498ad8b32U, 0x74c09fac90583674U, 0x40cea26591593a9dU, 0xde9350995274676bU, 0xaa5044cbab759e6fU, 0x3e81bea65564ad81U, 0x869a87235d826a7cU, 0x618d863d9c7cad9cU, 0xb94d8846635d554bU, 0xcb7d787f3a8e7cabU, 0x784f5d508a76c653U, 0xbb997d6a958a8751U, 0x879775c5836897b1U, 0x5940737aaf7ecc63U, 0x8573489640ba3dabU, 0x587c9b5ca0a79981U, 0x2dbeba628f2234a2U, 0x946b6e993d6c7f4aU, 0x2b7d417145647eb6U, 0xba5f9147808c7886U, 0x7994b9b9594eb4c0U, 0x88579c8775883965U, 0x40767b5ca17ccb43U, 0x656da542da518577U, 0x438392b05254a7a2U, 0x7e9b456f85c593afU, 0x7d6d939327892a91U, 0x9c5e4d635f7c4126U, 0x60458d6665b262aeU, 0xad82879d875d6787U, 0x86758d9a87526287U, 0x74767482567f907aU, 0x8d82976188678555U, 0x8392c149906e417aU, 0x849178907d626270U, 0x9968779062826b85U, 0x889549a0685364a3U, 0x615c6178a57f82c0U, 0x6176807564bb8174U, 0x877e6f95887eaa80U, 0x9d8aa38696698f63U, 0x7c5e5cb4516e686bU, 0x639069875e7ecb70U, 0x82776e7555716f88U, 0x6da87f7ba6b4627dU, 0x42679696c85b6c9eU, 0x7d68437e65747369U, 0x7db24d865b92895cU, 0x597485517f806c55U, 0xbb67697ca85f806dU, 0x82625a6c8fa05d62U, 0xae7b77876b665080U, 0xa95e77656d905875U, 0x83b672737d789a86U, 0x6c6d6f6581898e58U, 0xb48a796fbcb6907fU, 0x559e9682a8888382U, 0xa58798588e7d757dU, 0xaca9975a4a98564fU, 0x6c5f795d8063776aU, 0x9a4483727fa9937dU, 0x866a8aa1a47c7b7bU, 0x8e968d9a948d9995U, 0x67706fa57c92879bU, 0x619c908281767c96U, 0x96b0867e66666b86U, 0x7a7c8898797d6371U, 0x93896b885b746984U, 0x7e7f5c9779a264b1U, 0x72865d819a35a3a7U, 0x888a8587795e8090U, 0x6c839b2d6064837eU, 0x8557ad4b7a43954fU, 0xae6854b274917482U, 0x5b99595b5d74b86aU, 0x89848890917d676bU, 0x9dab64797f9d89a2U, 0x5453616e9b7e7b7eU, 0x836464836488799eU, 0x77728d7b92717392U, 0x6f9290585e7d536fU, 0x9c65a48a95797093U, 0x84855169817b8f83U, 0x9e36ac5449695e45U, 0x4a607c974c50788cU, 0x8a7e614871756764U, 0x837e86668a828c3eU, 0x916871a4af965d99U, 0x83808b92929f9a97U, 0x81af6469696e7684U, 0x7c7c778c27526a7dU, 0x6e4ca0607f786466U, 0xbd6e7b777c9e6b92U, 0x759b82758f969a93U, 0x776c7d839396a484U, 0xa28675859f668c86U, 0x98888a9a70a49b88U, 0x82a3618c607e6687U, 0x6b68b88f8b8a9976U, 0xae72ae8d865c9b8fU, 0x90878a797e7ca168U, 0x518e907f71737131U, 0xac85717194778097U, 0x9e5e8e8f857e629dU, 0x804865856c518c75U, 0x998990857b9a5fa6U, 0x9288979272996c8fU, 0x9c999ba388545f93U, 0x769f907e7870888dU, 0xad8071888283734cU, 0x6c60866d746a639cU, 0x9c679d727e454d6fU, 0x80979093478d5e6fU, 0x58919986906b898aU, 0x967ba68f61778980U, 0x707b8078aa5a8068U, 0x5f707a8083735b58U, 0x90458c46848a616dU, 0x6e93997d9662696fU, 0x80a8aa6a87977a8aU, 0x8e9691a6856c888fU, 0x6e968f7f6d849d69U, 0x6e657e916aafa479U, 0xa77070b9678e985eU, 0x5e68784191bf6980U, 0x6eae60a082556a8bU, 0x5da377808b755aa7U, 0x5e90635a85c59f9aU, 0x887bbb4b797d7f62U, 0x78da67b45e8567a0U, 0x60c26a6b6d43959cU, 0x7198468981718b38U, 0x9f4883919a87bd5fU, 0x585adb835f94595fU, 0x7a5d7b554c359386U, 0x47607c3db6a3836eU, 0x7c8f6c70795a5775U, 0x7295753d8da47b77U, 0x748c5c6f9d76928aU, 0xc67f9e3d8ca4b472U, 0x8157487eb576724fU, 0x6268574a6d80bc7fU, 0xb0546a8b4ba53f6dU, 0x75747385a1a27a7dU, 0x53977373a04c7e90U, 0x6e90897c529e4e11U, 0x4d572d78783b8a81U, 0x9d8a829d7679688dU, 0x8d88b7ffa24dad8fU, 0xb7536e878282416bU, 0x5462724ba039ca62U, 0x5d7e49709744972fU, 0x70858d8847778989U, 0x585e63518db68f8cU, 0x694dda774478708eU, 0x9c40787c41582f62U, 0x6b9ca35cac5968a1U, 0x6e9d827c85629b8aU, 0x6197a5817791465fU, 0x6f687a706b885d86U, 0x646bb37c5b618b7fU, 0x7091849d42678d88U, 0xa2825073a87a9e79U, 0x6c926d988269816eU, 0x7e5d756b6a7f8270U, 0x85876a988b83a282U, 0x5b8298775c708586U, 0x6fa15a80a7818347U, 0x86999879817a8672U, 0x43ac796ba670ac72U, 0x7e8b704d63a7906dU, 0x7c81a270727a8758U, 0x9583916e8f937b7eU, 0x9d556c8687688a73U, 0x6f718d887b7b7266U, 0x65848f8eb98e6659U, 0x6a496861795d9775U, 0x7a63a98f95898384U, 0xb4696681aca6838bU, 0x89b48992608d7b40U, 0x5a5a57a16550835fU, 0x787293a66d6c6c68U, 0x7a859276894ea081U, 0xac717a6677705a90U, 0x8f7f8d6b7ab18b80U, 0x2f7a9b6272815b97U, 0x8c5e64766a7f867cU, 0x7e4f85967958657dU, 0x7b8798a88a496074U, 0x6d6c904b8d8b814eU, 0x764575896c676f7eU, 0x9c8883aeaa589463U, 0x71668088827ea884U, 0xc6636e9267bea686U, 0x866f857f8a827b79U, 0x5e83b96599a38e89U, 0x70879d756d9c846eU, 0xa7638667808b5866U, 0x9091b58d9a777c86U, 0x8c9c63ba6b763a92U, 0x5c9548ab8fa9518cU, 0x8388918a855ea483U, 0x877e93a195656c89U, 0x4a958d95848d819cU, 0x65697c84709e9966U, 0xae8d808f646e6682U, 0x70879b8baaac74b3U, 0x817076798bb8a276U, 0xc27c9294878ab577U, 0x6d88767d5e7382a1U, 0x988580725e977491U, 0x566896a6939d9e8bU, 0x708f717d88957461U, 0x99857787978376a3U, 0x7ca875a7867c6997U, 0xbe9fa38457725a7fU, 0x86836c816b62639fU, 0x836a82997a60896fU, 0x58847988a67db78eU, 0x7b9c99907b8f7bacU, 0x6e66637660538e66U, 0x836399876d89877eU, 0x8b7782819283a69fU, 0x6c9b87a77eb68a77U, 0x71a18c79658b7d5cU, 0x50b75f735c4b5293U, 0x748ba2778f5b3f96U, 0x9e5f406f92694955U, 0x9f5e6082a058837eU, 0x5f7a847c54629364U, 0x9c85764e7961608aU, 0x7b859f524679aa66U, 0x796e7e415d788880U, 0x8d7872716c7c8d6dU, 0x857f8d6e8c789058U, 0xb0906a856497905eU, 0x97714b977d4e84a0U, 0x778f646184869656U, 0x88717597307d5e67U, 0x876590568391798eU, 0x4da59e7d726a5d89U, 0x6a8c769e68748f4dU, 0x51714e6c4d557c87U, 0xa47686649b5d717cU, 0x9f7a94a85d89a088U, 0x8c4a878b945e5165U, 0x86667769857b857fU, 0x6656717f9b64a667U, 0x686593a1326a7790U, 0x8e9d3c4aaead769dU, 0x965baf615a565d89U, 0x8a5a75696a685c58U, 0x9a69915563826c79U, 0x8e86686f657d76a3U, 0x5f9c867d92718875U, 0x668a8c5fa3957e7fU, 0x8b7d788a6b5e8071U, 0x4d8f7a7d568a8887U, 0x863c648583805d6dU, 0x62718797827e9256U, 0x67757d8795a09395U, 0x718c9c764c906c5bU, 0x866c6ba68e418581U, 0x9a3f8a245e9d6a81U, 0x68715f6a4c569b7aU, 0x8079a6637b879d85U, 0x9c919a5c84915750U, 0x93967f937e8f8383U, 0x6b8d5d7f8c908b83U, 0x9e825a72629f6360U, 0xa265935d80897d7dU, 0xa67f6555719c5f9bU, 0x8f92797c5ca16763U, 0x80a679a488777873U, 0x9386878f67796870U, 0x72778b6d78697c97U, 0x748d4ea38b7b6b45U, 0x8e527e686c8b8167U, 0x7686776591485b82U, 0x7e9e5a709d815e75U, 0x7850a2786a5a8e84U, 0x6e9145866a666b91U, 0x84748a789677a394U, 0x6f69938b63767d55U, 0x6dae87939d73665bU, 0x6f6864627f7d706eU, 0x6a707e91639777aeU, 0x99706b87867e7e61U, 0x82795d96806b9280U, 0x92405d677dbaaa92U, 0x8871729786899963U, 0x68927b63856494a1U, 0x79877e6f69c0765aU, 0xad7b6b7aa2a47f71U, 0x5f6c748977856985U, 0x928579b37f9d7177U, 0x7791478c80985c93U, 0x699c84648f6baa76U, 0x7e6e98ae9578459eU, 0x6a668b8277767da0U, 0xa5658a877190936dU, 0xa2748f7e67636a84U, 0x87b28d86936f7b82U, 0x9664808b7365ad7bU, 0x8b676c9177838d8eU, 0x7077965081879d94U, 0xa4b1827078957148U, 0x59968b94838d868bU, 0x6daa7f7695808191U, 0x719b7ccd7b7980b6U, 0x807293908c926ba4U, 0x93747370667375acU, 0x96636059788c656eU, 0x7f399caa708b6a7aU, 0x63783aa28c8fad7dU, 0x73a27087af8594a4U, 0x78504b447a799b78U, 0x86715f96877c708dU, 0x8c72927f8e8c9e7dU, 0x7376a3a862837b81U, 0x8bb76980696b3754U, 0x858e8c6b91414b7cU, 0x937c9496a0885172U, 0x9e4c58af8d6d6c90U, 0xb2b45c92a35783a7U, 0x4a8b4e978d6d7cc2U, 0xb49d8b568aae518bU, 0x76b696578b429ea4U, 0x9268bb487657af65U, 0x967e60b6637837a2U, 0x7d96697c7c96d655U, 0x9e988e98438b8372U, 0x7e9e739d8998a392U, 0x27979483a084887cU, 0x4f85645e66668965U, 0x707e9c876c566f95U, 0x459d9b5370686091U, 0x964b7d9e875c5e99U, 0x5e877c938485967dU, 0xa0495e4866628967U, 0xa2649f5d4b796f89U, 0x7f8ab25b8357ac65U, 0x8899915e82a06f3eU, 0x637c70698eb5a671U, 0x698dab859c9a8183U, 0x72c4897082797c62U, 0x8198969a374b566dU, 0x75725956725a914dU, 0x70797b6a58919f90U, 0xa496738175679662U, 0x6f94ee73a1a67e54U, 0x63855064554d5f70U, 0xad597887249b4685U, 0xadaa608e53747c98U, 0x9b846f62995b7471U, 0x5bb55f9a8c615f55U, 0x76a168a75d5f856eU, 0x9065936e8d69a76bU, 0x7f819280a19b5d85U, 0x6842727e6b7b96a8U, 0xa76283c68a607c88U, 0x89a2817d8c87816dU, 0x7c857a4a81a78092U, 0xa288a98f453f799aU, 0xa57e517e819a7177U, 0x7c806772948cada2U, 0x7a498678706196aaU, 0x7cae729c93684c6aU, 0x7a8d6a9682997e73U, 0x9272878f8d7e8472U, 0x808c7ea18d8b7d32U, 0x7b9a5e7e7c638297U, 0xaa619b8f8e738bb8U, 0x98979e5d78856499U, 0x797b7d42d4736e8bU, 0x6c7e7ca7968b8464U, 0xaf659f6f6e6e875dU, 0x769d6a9f95b173a8U, 0x8960965f79af6d96U, 0x8f8aaec2a8576b8dU, 0x6f8e867e858e6e4cU, 0x4f607a4599897b7fU, 0x917947565085797bU, 0x9f566e6b6d535f82U, 0x7a6667979068a58dU, 0x7b7c5d5c83969884U, 0x5d61849e90ad7f78U, 0x7b6d954392a87d93U, 0x677e836d5e896156U, 0xa3626c7c81907453U, 0x7a7154666f9a8778U, 0x87615da05ba58274U, 0x649b63746c886590U, 0x8359815d74586d7cU, 0x7383809f585a5e8dU, 0x6f8d648d87405a7eU, 0x877e6a8455556788U, 0x7664728043605d72U, 0x6c7a6751ad6b5980U, 0x8c57938769348358U, 0x638356705d9f946aU, 0x317b8d628778965dU, 0x868db39176ab5e53U, 0x4da55e7780977d5bU, 0x90935f4c65636649U, 0x77687eba89766f6dU, 0x98837fa77c6f2d72U, 0x96878a6047526392U, 0x83915454a654646cU, 0x945a8c62573e7f78U, 0x6183678aa796a282U, 0x8f7d608a8a90a382U, 0x74426288a58b544eU, 0xad8094cfa97572a9U, 0xa66e836a9d788987U, 0x5d949faf92a5a67bU, 0x8aad805da7a67631U, 0x6995869c9e3844c4U, 0x16b6964c767b44a4U, 0xc08968717b5e656cU, 0x97373aa2b77ba188U, 0x28b0a0aa617d8141U, 0x92937c3f896a4f66U, 0xa07190719b91ad8bU, 0xbd5973724a7c5c67U, 0xa36b84555d996c9fU, 0x83647073a590b469U, 0x8b88706e71b59666U, 0x6ba76d99855aac88U, 0x79836d7b8ea49b99U, 0x675f8b7034ad5685U, 0x79778e5c946c7eb1U, 0x449ccb798c57488aU, 0x839e7fc1399ca744U, 0x436970ad4e598b99U, 0x97825776b38fb685U, 0x7f6baf7c815cb8afU, 0xad5aa09758794e39U, 0x3d6473558e4da05cU, 0x6172657381727168U, 0x479d7792484e8096U, 0x6aaf62419cb48a8fU, 0x8d759c8955963b79U, 0xb14b3b7a407b6e63U, 0x5d94829449736687U, 0x8d5b6550a693736bU, 0xa159728891736f89U, 0xa07f89838f979260U, 0x7d658a6c74af907fU, 0x4b705b5d74738787U, 0x5e84797b94748293U, 0x8176713f7c767d9eU, 0x9e877f9c67837e7bU, 0xb364818a7d9f677bU, 0x848e688b85715f7fU, 0x788f9d9686749692U, 0x768f4f8456ba748cU, 0x7a4f54747b748e59U, 0x6c5c8dbb9a3f8883U, 0x747e5a7290676872U, 0x9c7c6283927a7584U, 0x6e778385667f8275U, 0x718463879a898d76U, 0x7a68689a6c88a48aU, 0x6d9b609b6c6e7f62U, 0x6480746b62a37072U, 0x807e7c806f728598U, 0x8b5b607275bc7eb5U, 0xa098878a7a7b7e9fU, 0xb68f8190647f5f90U, 0x915b7c9c7b8f6288U, 0x936666966a6bad93U, 0x8185888e6e577d74U, 0x785a5a5ddc8b745eU, 0x9679687c8d6a6c83U, 0x64a36877a37073a5U, 0x9f0f5c6d6082837bU, 0x6e7c95acb1587e8fU, 0x7c5a718d98469996U, 0x4564af83877caeb4U, 0x8da88c5ca6847061U, 0x907a9b68ac773f63U, 0x95a7b051767c5f50U, 0xb84055945bb66069U, 0x856b4cab72889eadU, 0x37668692837f49b1U, 0xbc86745a3d847f70U, 0x76ae6a7a55a06770U, 0x9487a75b3c488d5fU, 0xa7617b9f6d8a7388U, 0x748c648d557ec451U, 0x84a1826f79806663U, 0x5ab45c96646d5570U, 0x548668ca827ba485U, 0x6d7c459554863276U, 0x60a952726780a589U, 0x53828e408f8a6f8aU, 0xad82599b71667d38U, 0x7b8a4471848a7ba5U, 0xbf68574894688972U, 0xae5884934d75536bU, 0x8e5f885e806e6e4fU, 0x57677055a08bca56U, 0xaa67b1948fa398a8U, 0x69c892a38b85687eU, 0xae96683c7b857f58U, 0x757c957e5f8b496eU, 0x856d7f587e4b793fU, 0xa06e638d6ec77993U, 0x9065888d76a29981U, 0x8d827f75a3858d74U, 0x8c708d9c60b09448U, 0x9d915ab5788e5c8eU, 0x69726e94875d577eU, 0x667aa27e84884561U, 0xa96d907184a87aabU, 0x88757d84735c9276U, 0x816c8c826d5fb17bU, 0x83a536619e8e5b74U, 0x87827f715b80939aU, 0x904178704d8e8183U, 0xa6866d9c566284a1U, 0x5d726f7d8e6e948eU, 0x80833680576c7054U, 0x8e887c9a5f6bb0b0U, 0x73917f657e858043U, 0x866d8a7e855c8b82U, 0x7561a09482457481U, 0x69a7c08755827281U, 0x6da97e90545b836cU, 0x7491635e8088857cU, 0x8d6260536b57988cU, 0x79868a7a86696986U, 0x9a639b7fa77c678dU, 0x9479759498937b6eU, 0x5672925a75827e7aU, 0x6c6a598c6b6b7585U, 0x7491886882ad858aU, 0x7165858f79746f98U, 0x7d813b7a8295987eU, 0x6f728f808b969379U, 0x92775074487b577cU, 0x666d994a85706563U, 0x88895f5975866c82U, 0x757d7284af8a7d91U, 0x79476e6399895e77U, 0xa16d8da3668d9186U, 0xae716c8778ac99a3U, 0x7ab48a8f7b795660U, 0x7880785c92a59188U, 0x80856fb395968974U, 0x7387678d8d7c8172U, 0x6f879a797b88a488U, 0x6c837fbb90767a91U, 0xa190608f66716b98U, 0x60617962816b8583U, 0x79926d8376877a94U, 0x8d8a629f8a7874a3U, 0x7d89557ab349986bU, 0x718c81857a668353U, 0x88439c8e7c58b56aU, 0x9f71964c907b969fU, 0xc08b839eb472905fU, 0x6379aa996f693579U, 0xa898415a79a64179U, 0x7fdc7e619b787ca5U, 0x98937a936da68683U, 0xae796e8cb1a19694U, 0xae8b7671a7a98450U, 0x8a688c898b6a868dU, 0x69925ca25997945dU, 0x5a929a81a89db7a5U, 0x73daa46b9089a8abU, 0x558146445a927772U, 0x639d909959854b63U, 0x649067706a4d829cU, 0x7d888b73538d5e9eU, 0x967a62b2677ca558U, 0xa57e388186949852U, 0x6c8e9f5f6c7a8f6cU, 0x8e60a05564848f6bU, 0x886e4a827b8b3d49U, 0x519877837c7a7f98U, 0x6a926089aa79a46aU, 0x82bc5d958aac93a7U, 0x46ada94ba7718679U, 0xa7816367849e3487U, 0x8065b7438e55a97eU, 0x6f647c6a7950748aU, 0x7c88927c58757e88U, 0x86596b72aa4d895fU, 0x764b926f902c493fU, 0x6b42788fad7771a1U, 0x8374814099956a89U, 0x6f848970bb74b584U, 0x6aad8b6183669875U, 0x537264a57f507c6eU, 0x66637a769b7d818fU, 0x719d6076787fa186U, 0x798c9660331f7769U, 0xb46b88806dc38e48U, 0x694d8fa56e628962U, 0x83917d69877bb161U, 0xb196b291a85e6d6dU, 0x5f57589a9f5a8a7cU, 0xb85cb6b3815a5d74U, 0x9f72c88469677b81U, 0x566d819e82706f56U, 0x8c6a966e8d905564U, 0x6e55a56e883d7a8aU, 0x90cd645e6d4c5ebeU, 0x6c7e649d9b793fa2U, 0x7c416c988069909fU, 0x4a735d939160979aU, 0x6ba3846d76837262U, 0x4aba928c6466b679U, 0x8f6c99869e944389U, 0x6774597183896f83U, 0x65765768927b746eU, 0x81846b484fa36b80U, 0x7c86597c81a69479U, 0x5882509b9e80a3acU, 0x879f615645a38d8aU, 0x657883709a968880U, 0x81945e48ad7d5e6fU, 0x8d6c819780716c80U, 0x486860776a7c567cU, 0x8d4fa49652748586U, 0x7a7cb790877c6b97U, 0x7a89899a777e8379U, 0x63696e6766648a81U, 0x835c5c9d9c7f8658U, 0x60868e479679628cU, 0x869b6a737fcc7098U, 0x7b8f85705f943699U, 0x8578545051637b7eU, 0xa5817a6863707e6eU, 0x76696e5f9a98966cU, 0x556566877680937cU, 0x844e7f4ca24d5695U, 0x8659427a8e9d969fU, 0x7b987e8b8baa5a9bU, 0x6c888397876f7183U, 0x7998545e88977b3cU, 0x7a765c728c817866U, 0x7d8c8f7d6378767dU, 0x5958785b689a7872U, 0x7f8b57bc78754387U, 0x89925d7d746f69a1U, 0x719183727565a95bU, 0x8963a58869a184a9U, 0x686f7e78683a8aa4U, 0x6d58838a87656b60U, 0x7f9e7c8651637173U, 0x657883c5726e3772U, 0x85798fae78787b85U, 0x78709b7e71849d70U, 0x50664e98817adb51U, 0x947b838d857c8281U, 0x81a95179a5848a65U, 0xae5a6e98598e855aU, 0x63626a61ac7d6589U, 0x7d896a9b5f6261a6U, 0x9e8976aa60759897U, 0x637593717274679eU, 0x90866d87527a697dU, 0x7a6164589a9e757cU, 0x938673906d707598U, 0xbe0d5e66aa875680U, 0xbd4b50ed3df84eebU, 0x3d98473fbe1ee4e7U, 0xbc22a32bbd0740e4U, 0x3dbd26c9bdfbc363U, 0x3e0140663b0ab532U, 0x3d1353a83b20f40dU, 0xbdb7db873d800220U, 0x3ce9a495bded70a1U, 0xbdc9d7053d4403b1U, 0xbdf94b52bd9cd390U, 0xbd100bcd3de547b2U, 0x3d8f6c75bd2f4198U, 0xbe35a287bd563178U, 0xbc1752663d97ddeaU, 0xbdf317a0bdd7e7a1U, 0xbd8cc6293dae3128U, 0x3ce3343fbd66759eU, 0x3e07625a3daa12cfU, 0xbdfcd5efbe048bc9U, 0x3de936f53db5e3a8U, 0xbe0e1634bdea0aabU, 0xbde8c0e83cd62ab4U, 0xbd217d6c3c7f52f1U, 0xbd66cbffbe04b76aU, 0xbe1b65c4bc18415aU, 0xbd9aca82be29ee01U, 0xbe1a80bb3c2cc615U, 0xbd8d11283db35cdeU, 0xbe0895343d3befbeU, 0xbde824013db133eeU, 0x3dfb9ed43daf67bfU, 0xbdcff090be130da8U, 0xbd363ce5bd1a4646U, 0x3de1cd243d9cd0f8U, 0xbe050a413da48607U, 0x3d34f46e3d9184aaU, 0x3de1d38abe0ce717U, 0x3d804c08bddd5c2cU, 0xbe0808553e01818dU, 0x3dde5c133dd742d7U, 0xbd333640bca4f409U, 0x3df00d8f3cdd808bU, 0xbd623ac73d50381fU, 0x3dd9ad27bd05b167U, 0xbbcf3ebbbe38f9d4U, 0x3c1bafeb3d7b29e0U, 0xbdefd0c53e0bd518U, 0xbd379484bd9ea569U, 0xbe15205d3dd3d810U, 0x3cd10b33bdac7be3U, 0xbdee8aaa3e086d39U, 0xbd2428a63d47cc56U, 0xbc9ac19fbdf25223U, 0xbe2b35653c24c927U, 0x3df38a583db0ab55U, 0x3da400ee3d87b9e1U, 0x3db768ebbdb2cfaaU, 0xbe0b79853deb4f1bU, 0x3c9866b33d297f5aU, 0x3d2b559c3d63a0baU, 0xbcfb3eb6be078e5aU, 0xbe0227853dca2ed5U, 0xbbb7dfb93d325956U, 0xbea793593d810d1aU, 0xbea504f2bea64c25U, 0xbea2768abea3bdbeU, 0xbe9fe823bea12f56U, 0xbe9d59bbbe9ec642U, 0xbe9acb54be9bfbe5U, 0xbe983cedbe998420U, 0xbe95ae09be96f5b9U, 0xbe93987abe946751U, 0xbe900d7dbe91d8eaU, 0xbe8e034fbe8f6288U, 0xbe8af62abe8cbc1bU, 0xbe88e680be8a2db4U, 0xbe865819be8796d5U, 0xbe842a7abe8510e5U, 0xbe81851fbe82d834U, 0xbe7d59c5be808e42U, 0xbe7754f3be7b4859U, 0xbe731538be75ae8fU, 0xbe6df026be71d66fU, 0xbe6a22d1be6b6f08U, 0xbe648ff1be67ba69U, 0xbe5f4a98be60554fU, 0xbe5a60c0be5ce1e7U, 0xbe5417abbe56866bU, 0xbe4efbdabe51bb0aU, 0xbe4a9a40be4c4a0cU, 0xbe44ff53be471e0eU, 0xbe401e01be434da9U, 0xbe3bac22be3e0e1cU, 0xbe35c745be3847e4U, 0xbe30bb40be332e18U, 0xbe2bb22abe2e63f2U, 0xbe265734be2931a5U, 0xbe21333ebe23a94fU, 0xbe1c4338be1ec190U, 0xbe1650f8be194f20U, 0xbe126ce3be146c32U, 0xbe0cd94cbe0fd71fU, 0xbe07e3ddbe0a836eU, 0xbe0298bfbe052a2bU, 0xbdfb1e0dbe006a45U, 0xbdf12012bdf55f7aU, 0xbde7307cbdec0f43U, 0xbddc80a0bde1e931U, 0xbdd23305bdd756c6U, 0xbdc68334bdcbcc3fU, 0xbdbcb066bdc1804fU, 0xbdb3d1a8bdb84b8dU, 0xbda93d18bdaeeec1U, 0xbd9ee37ebda402e2U, 0xbd94577abd998999U, 0xbd8b261dbd8fcdb3U, 0xbd814247bd86be7bU, 0xbd6d143dbd77ca3aU, 0xbd58149bbd62ad28U, 0xbd43aec1bd4d706cU, 0xbd2e4f0bbd390c82U, 0xbd19e701bd24dc97U, 0xbd064756bd106a05U, 0xbce5c012bcf6c4a7U, 0xbcbc7a8cbcd08f3aU, 0xbc922ebfbca6bf0fU, 0xbc510cc1bc79828dU, 0xbc011420bc297626U, 0xbb44d1bfbbb6068dU, 0x3b17236db9f09bdbU, 0x3bf62e3f3ba44682U, 0x3c47d97f3c1f9cf5U, 0x3c8b09093c6e3f73U, 0x3cb56ba43c9f30e6U, 0x3cdef4d03ccaa2ddU, 0x3d03995c3cf37b76U, 0x3d16ddc43d0ccb09U, 0x3d2dc3b23d229f7eU, 0x3d40123b3d36e963U, 0x3d54ab663d4a6582U, 0x3d6a40db3d5fb07cU, 0x3d7e9ecf3d743cb6U, 0x3d89a9283d84a335U, 0x3d93eb6e3d8f035bU, 0x3d9e89193d996148U, 0x3da83b303da3669eU, 0x3db183a73dacb54dU, 0x3dbb71113db63228U, 0x3dc5e9473dc09b4fU, 0x3dcfb1413dcb366fU, 0x3ddac8423dd57273U, 0x3de5e91c3de073d8U, 0x3df0a11c3deb3397U, 0x3dfb3ed63df569a1U, 0x3e028a903e003220U, 0x3e074df83e0474d8U, 0x3e0c65463e09b7cfU, 0x3e114ca93e0ee6e9U, 0x3e176a063e146947U, 0x3e1b2fd63e19b723U, 0x3e20ecfd3e1e4558U, 0x3e25fc883e233ba1U, 0x3e2bda423e284d6dU, 0x3e30b5053e2e0604U, 0x3e341cd13e32c354U, 0x3e3b3d003e37a95fU, 0x3e3f298b3e3cf120U, 0x3e44b1d03e419a59U, 0x3e49a8bc3e4753e0U, 0x3e4e69e63e4c0df9U, 0x3e53e0643e512e14U, 0x3e59008d3e560e0cU, 0x3e5ee59a3e5c4136U, 0x3e641f943e603617U, 0x3e6856fa3e65c892U, 0x3e6d73c83e6ae561U, 0x3e7290973e700230U, 0x3e774d5e3e751effU, 0x3e7cca353e7ac17fU, 0x3e8141973e7f589cU, 0x3e83298a3e823ab6U, 0x3e8610513e84d606U, 0x3e889eb83e875784U, 0x3e8b2d1f3e89e5ecU, 0x3e8dbb873e8bd754U, 0x3e9049ee3e8f02bbU, 0x3e92d8563e919122U, 0x3e9566bd3e941f89U, 0x3e97f5243e96adf1U, 0x3e9a838c3e993c58U, 0x3e9d11f33e9bcac0U, 0x8b92a55e3e9e5927U, 0xbb9471b03694a056U, 0x6b8f8f7b9e8c9c6cU, 0xa37181399389b55dU, 0x89ac585f703770c0U, 0x7796838280708067U, 0x51784d5a4987a492U, 0xc29c978f9d875f79U, 0xaa73bd927373817dU, 0xc1aacb6893449db2U, 0x88477980848c7da6U, 0xda6c81906d8a6186U, 0x616bb9b62a789b98U, 0x71727f84a64e989bU, 0xad569a9396cf9ccfU, 0x5b6e595d636a7280U, 0xd3ab7c7137736aa6U, 0x7d5d816b5a85978dU, 0x819cad8d897e7d4fU, 0x43ca8189925d6db0U, 0x444b45749f9ab122U, 0x74649d5a4f9b759bU, 0x97cb7c53798c789bU, 0x9fba8f7c7f7d95a5U, 0xad635fbba33c8984U, 0x6a75988177858b4dU, 0x52a18480769f7f7aU, 0x68a3ad6769af4676U, 0x5f536c97778f6f96U, 0x905b583d876f507bU, 0x5652aa7b6b8594a1U, 0x8287a18578887e98U, 0x826c806d5a69868aU, 0x61d39c5960cb8f6dU, 0x778a6a83b9ac7f7dU, 0xa78a536a79744294U, 0x5b455d505f7aab94U, 0x60a6ac87a5a539a1U, 0x8da2b84c67915b9dU, 0x68a570c4ad65657cU, 0x964fbd97976c8ba8U, 0x8eb684a28f6ab895U, 0x6a9ea6639065a276U, 0x695aba9493937a80U, 0x793c959e8c747c70U, 0xa88b8e8e90486e81U, 0x5d8092a88f669e79U, 0x637f60665c927979U, 0x8c6887835e9b9684U, 0x619f48af80807587U, 0x9355a935b05cad8aU, 0x75a69a4c475a9467U, 0x86499c59916a73a8U, 0x91876d5d97609b6fU, 0x776a917b4d8f7f99U, 0x8566677e9e8d489cU, 0xa39d519967805a74U, 0x5f8fb290a3a09297U, 0x6d946a6d345c3e73U, 0x978b358549926266U, 0x85a071a859545182U, 0x41b36f91b7b1518dU, 0x744a5aa785aa9666U, 0xa1786258aa829490U, 0x9067579e73706170U, 0x988e6d718a61634aU, 0x6da58da2626668aaU, 0x51a0725f54c5b6aaU, 0x5e22b37feac4cdbaU, 0x8c1f5a878f80006cU, 0x8ca3604d8d8e6dd6U, 0x8897a4af5ab477b7U, 0x8b611d668389656aU, 0x62488292849f7864U, 0xbabf4f718dc55daeU, 0x4f8b7f7c72889981U, 0xbc4f994a7c3aa29bU, 0x7a80aba2bbd25578U, 0xaa7a829b6f9049a3U, 0x5b7f5b97ae784481U, 0x774c8b93a562549aU, 0x9d8255996aaa5e8fU, 0x76a09450984ba591U, 0x88a3a67e6187b48bU, 0x7d8cb38e7b7b7492U, 0xad5393a58f8470b6U, 0x647657b26ca2be5dU, 0x5e99629bb1945e71U, 0x7c8f7f948c67487dU, 0x6b67799e7b99c083U, 0x60c19c624659643dU, 0x65a45690808d8c74U, 0x759b97875f6c6c7aU, 0x727d958d747548a5U, 0x5b3e718578aa5d77U, 0x8a78673da27d6bb1U, 0x8c918f8bab4c7898U, 0x8a7e887c6a7f8ab0U, 0x8b35858494876b94U, 0x5a8b96806d70ad76U, 0xb565717da370b484U, 0x8a7c6788983d4d7bU, 0x7f8da57e9969b7a0U, 0x7f4f73c16eae9dafU, 0x66a07e776c7c912fU, 0x6294508b8563c1bdU, 0xa5a787ac6f7e8784U, 0xbc484b89557bb89eU, 0x7e9958976e3c82a1U, 0x9b8179c6a27d8f70U, 0x867d3d7b399d7468U, 0x927081a0bd75715cU, 0xb15c5c8bc7776795U, 0x9c758f6ca19c9376U, 0x758484769c9a845fU, 0x696b9da97245ac6eU, 0x79a48f8b7e77a39cU, 0x7c94c75a4aada35aU, 0x9ead507eb7798d9fU, 0x5daa8553778aa69bU, 0xb0849fa34d697b72U, 0x9b63c37f81b46f98U, 0x5caf6b89578c7b8bU, 0x90787777434bb6a2U, 0x84767584c36373ebU, 0x85717a6b8d819574U, 0x82948a635f8a7291U, 0x86c3b85d4d868c88U, 0x988e9ba5545d2a8eU, 0x6e6d6c6f7167a8b4U, 0x957f738b49854b4bU, 0x627da58484898b70U, 0x7e71997e739874a9U, 0x719d7d4f6eb18b92U, 0x9555a982728f8897U, 0x767f9c8e616f8172U, 0xa45cb3b88d8d7089U, 0x5e61774f657e5350U, 0x9f69979e7aad5a92U, 0x7a9c8f90a398ad99U, 0x6e54627e6a4a749cU, 0x628b46987d8e968bU, 0x5eacad86a47c628bU, 0x5b8a939d6893839dU, 0x79b7819fc0a38564U, 0x9e9a5d6d9d8c7b84U, 0xa16a775c588eaf86U, 0x7d9d7d7c878f6960U, 0x6a859682b275a060U, 0x808c7e578b745346U, 0xadc75579988c8d75U, 0x828b9ba76187779aU, 0x7685816f8c8d5777U, 0x778a84a9ac68a587U, 0x9bb29a4c954b6171U, 0x7b7dab8b4f9c9645U, 0x4a987c8277804295U, 0x36a897a077685583U, 0x775d5b88428c668dU, 0x784a7d4e816f8f98U, 0xabac828dad833db4U, 0x7992718096a075abU, 0x739d7f6f52559a66U, 0x6cbd5bad4e4e85a0U, 0x9256917a8bb5a5a0U, 0x3b6193857d9d686aU, 0x8c88b279ad6a7fafU, 0x8b948e976b9a787eU, 0x60926f9da7937087U, 0x4e40a46081a9685aU, 0x6d74294794837b79U, 0xb477ac8e8ac2854fU, 0x9d736f6c78674977U, 0x8a836b59b1978637U, 0x629b5e8aa06ba16dU, 0xb37969a8467aac6cU, 0x34799e686f72858fU, 0xab595d9d39a0716bU, 0x8e808b95d782a1afU, 0xb48882c090915fa8U, 0x937787673c63616fU, 0xa89c9b809861cb9cU, 0x8961768f7f939775U, 0xa261957d9a93747dU, 0x6b9dbe9f6ab3a099U, 0x6f93a17e6e999b5cU, 0x626a8a7c5c5e88a7U, 0x57704e7675855f83U, 0xb8b095d28b5cb381U, 0x806777ac65707455U, 0xac8445775ba69e69U, 0xa1707f9e7e6f9181U, 0xa11392b6996e889bU, 0x88609a8bbf7d7561U, 0x8d8a826ec2b2729eU, 0x8c94586e828c6facU, 0x8160a66c586fa6aeU, 0x6ba1708a848fa774U, 0x9965a08190a2a3a9U, 0xb76e9da27eaa8759U, 0x636f107b65606eb1U, 0x9a4999a6399dacaeU, 0xb49d8a699d7a4ea3U, 0x6b5ebfa6823b599dU, 0x808e91b499736e4dU, 0x578dbc8d86d18ea3U, 0xb8ac7555908b439bU, 0x80688f98a0bc5f70U, 0x81b78fa3a87c806bU, 0x9974429cac925d81U, 0x6252a1509f527891U, 0x56728b888e7671a6U, 0x727b746b988d5861U, 0x70888981924f7e77U, 0x905963906a74526aU, 0x77866d69938d5b7bU, 0x94816b7781525f7eU, 0x777675a19a847a68U, 0x5473a06a59715168U, 0x865d2b5950846749U, 0xa374816a85975e83U, 0x57b08b778b936895U, 0x905c72618b81714eU, 0x8e7b98866a93667fU, 0x6bcf635f706c7f54U, 0x6c9566567aaf8d9aU, 0x59726e658e86547fU, 0x8480578f73777492U, 0x926bb554ad88737aU, 0x7c7f57969e659793U, 0x666f6b94b1977bacU, 0x846f3e8ea16f8f6aU, 0x777ea8c57473926dU, 0x9d7390635d719f93U, 0x8d508879949e6b8aU, 0x8bb1886767c5565eU, 0xab825ab06a88928dU, 0x5f79536456767f54U, 0x628f8ca1ad8f8bacU, 0x80717f9d80666360U, 0xa07791886793939aU, 0x867f6c92af5f5678U, 0x8da97e4b988d3a94U, 0x39746d7e8b9e969aU, 0x76725c995c94a180U, 0x7090b0854b76a8a2U, 0x9196789992a26892U, 0x82a392526c75905dU, 0x8b6b3c7b845e647dU, 0x8f527c6a86775766U, 0x8b3e8a5273686070U, 0x566e6c478d6a5075U, 0x9ea04e997fa53f61U, 0x89675b4976a6814aU, 0x6a4f56816c3d6e80U, 0x74929e66907b628eU, 0xa4737981ab52859eU, 0x65a1538fb5799a89U, 0x59ab3b8e96bd727bU, 0x986a6ab18b906a79U, 0x838f697e91a8454cU, 0x808c8f7883767f55U, 0x9070547079965e8bU, 0x64b57c8a878a7f6fU, 0x65987cc36e6b8e93U, 0x76b2655d6ea43565U, 0x7f536d655c446184U, 0x26769e7f6e47b3b5U, 0x87bc79869f769877U, 0x6e6d929aaf9c999cU, 0x8c9e46ab854b5679U, 0x62aa7992525a874cU, 0xa2997fb8534d5a98U, 0x56798029b04d9069U, 0xb089917492a96d71U, 0x7ba5a335647c8c5eU, 0x5a9b78a3a7abaa3aU, 0x63998f3f6dbb9460U, 0x8bb966439488cd7dU, 0x6ba1725b3c9568d2U, 0x8b77857197566ba1U, 0x92596f7a4ba55d86U, 0x8c8674736c768448U, 0x999e9a917696626cU, 0x60c73d8bc971636dU, 0x582b856790938c44U, 0x495abc7d4c517f7fU, 0x358ed4578c857ca6U, 0x5d828c5198754180U, 0x9a797f8bccab6559U, 0x78aeae8d728b7959U, 0x9d90876d8f88b982U, 0x59992f7f53a07d98U, 0x77a8858c77526d91U, 0x7a8d6c797467a953U, 0xaec07b3765a54b75U, 0x706c92834c7065b3U, 0x942ecda47ab9ab5dU, 0x60ba51977ba4726eU, 0x7c7293776b796073U, 0x7d606967ac46a478U, 0x6057b576ad93a37fU, 0x8e97697b9c9d6b94U, 0x9d8b676a7a9a5885U, 0x7769669881797e7eU, 0x66a87558559e4f69U, 0x75808b946a708c85U, 0x956c978a976aa170U, 0x97ae8dac9c9ea475U, 0x7860828aa2658ba0U, 0x6a597c9761a38b8aU, 0x8a50757e90635c78U, 0x8171894a75885f69U, 0x7e9c7399649a818cU, 0x827998848f78716fU, 0x90684a995e5e7e80U, 0x7c8e7b65565a756cU, 0x5a664c75ae887f89U, 0x959c4ba691948f6bU, 0x73858489625b805cU, 0x9abc7bd17c87877aU, 0x4698742dc1a26a54U, 0x8da376657b837637U, 0x7b839c9c8b87c187U, 0x7b8f996d6e665c85U, 0xabbb806d829a887fU, 0xa97980589a7a7b8aU, 0x8bae9c6772857865U, 0x8a7576a5c489897eU, 0x4aad6b83728f4b94U, 0x9b2c9a84a38c8d80U, 0x5e92ae727ba698b1U, 0x6aa6a16264688479U, 0x82746c82b572977dU, 0x99b07c9baea29a8dU, 0x54959d85505ac06bU, 0x63af78a1cd718774U, 0x4a9850a96ab25560U, 0x4e728f458e41807cU, 0x783e9764467b9e89U, 0x5f643b99a2844bb5U, 0xaeb1779081726aa8U, 0x8a6474b49ab45873U, 0x786767c38e644a68U, 0x5b449a88a2b1654cU, 0x837a8aa2b2808ba8U, 0x946fa764798b9633U, 0xb58343a04d648d9dU, 0xaaa1875d5c857174U, 0x6392a8ae85665f88U, 0xa07a87827cac687aU, 0x8635b03e87a2697eU, 0x6fb48ea16132b0a2U, 0x61577360d45d9596U, 0x78a7746e635a856dU, 0x616c9846a63a398aU, 0x73a571bc6b626162U, 0x90c79ea9638dd69bU, 0x645669b166ac6c7bU, 0x837f98aa869c8784U, 0x5b84828391837768U, 0xb04c6073906d8775U, 0x9e539f8c77746688U, 0x74609472af778171U, 0x2c7d6eb254af8e87U, 0x8199649299a57a7bU, 0x6a7e8192a15d7d6eU, 0x269e587a83905a7eU, 0x959a8a95a9939486U, 0xa39a836fb3757482U, 0x5fa0a96a918e5c52U, 0x824c7395a45d666cU, 0x51c958b17c615a65U, 0x8ab7b4807295ca69U, 0xa28972926679cb82U, 0x6a5b5f836c8da861U, 0x9d759b9ca3696e7dU, 0xcb6d9b9f528b81b0U, 0x8785778867809752U, 0x88898a70ad43516eU, 0x8c768c61a749573dU, 0xae83616388b796b0U, 0x9c9e939491af918dU, 0x74ad847a8ba5c5b1U, 0x77b251b8a06a9b7cU, 0x7bad7aa183b7625bU, 0x986fce8b75869a63U, 0x4d6c7d8e969d9f7cU, 0x756f858f827e7b7eU, 0x898477546b7eabb8U, 0x6c905b8fbc8bb0acU, 0x6975b06c8c3ba146U, 0xa27e96c28f76a27cU, 0x708e8079825086adU, 0xab44a9ac88b08688U, 0x8895855ab26fa270U, 0x80ab6aab6f7883d0U, 0xa46b3d9b6e7d965cU, 0x43a9869268425eb3U, 0x915995a09b63ae67U, 0x5f988a8c8e9ebf6aU, 0x5a8e8a8a6e9f5f9bU, 0x883a616c629aa171U, 0x6264a09b8a6a7e95U, 0x9297767a8c868360U, 0xa86b649a666f649dU, 0x9a6ca4845fa9a07dU, 0x9e77628477708479U, 0x93ae745a79849b96U, 0x658a5e869a987fa4U, 0x598774575b786d71U, 0x69664478847f9284U, 0x838e838466788fa9U, 0x628b867a727e866fU, 0x6b7c746f5fa79861U, 0xa6696368a7929584U, 0x726c8297abaf9a73U, 0x71967a7787878874U, 0x837c6c5348668f75U, 0x9274819a715a934eU, 0x7f957f878b656a59U, 0x6b6687a68a7f5998U, 0x9281976594787076U, 0x9172a37e75a46d79U, 0x99bd759186af7779U, 0x656398ab908d757cU, 0x61867e77467e5c88U, 0x815a8cc286a94a6cU, 0x92328368788b4879U, 0x6da98c4fac709f7aU, 0x8c6495825faabc6eU, 0x83a7616093c6a459U, 0x51adafa372836d8fU, 0x82857e6d67a66882U, 0x4b487d65b26f7978U, 0x83557a627a81ad8cU, 0x808a7d5986644b76U, 0xa09554967e998b90U, 0x644b4f616a8b8c4eU, 0xa7679b8b7a6e5c94U, 0xaa5e9d8880737997U, 0xa48265aa81999a94U, 0x64439f6c9e51549cU, 0x89a25aa0916eaf98U, 0x88ae8260635a8196U, 0x59b66c78926e84afU, 0xa9746c8a807e7c58U, 0x8b72935c9f85af65U, 0xc16866ae57afa65aU, 0x986cae6a6d907292U, 0x699cb16b9a6f7b5fU, 0x76956150b3a09c9eU, 0x964782777d8a9ab9U, 0xbda15e705fc25271U, 0xb7ac502ea08a7093U, 0x5dbf969870736965U, 0x9941c3a36fa97378U, 0x9186ad909b8ea949U, 0x7e8f7b7f78995e76U, 0x4c7caf64b897aca8U, 0x72ac6f89a28b6d96U, 0x6e855d76a1756992U, 0x6a6d8f8f717242a8U, 0x546c708759a7a17fU, 0xab9264b980999997U, 0x765f7d516ea55a73U, 0x8190613e7ab06c9fU, 0x92b27839805e5b9aU, 0x6e7f849076a48494U, 0x9e83aa946a979b79U, 0x9da5a49d79a94d85U, 0x4ab24fb93b9768a3U, 0x4b746d8b99484496U, 0x7e618e7882a19d6bU, 0x55538b3f29a13e27U, 0xac618f5b7464696eU, 0x7cc6468d9c9d6566U, 0x559e8b82897b1e70U, 0x60869492244b848aU, 0x6a819452b09d8acaU, 0x8d8c89929f9cab9bU, 0x82686c58b1787155U, 0x968d77a7b5aaa088U, 0xa0c394538f6f67a1U, 0x957a826369ad985cU, 0x2aacc5a18e747e4cU, 0x88c97e5a9a7c649cU, 0x6dc58a789eba7ca1U, 0x80b4427180769471U, 0x798c85a199b18568U, 0x7dc27f6a75757c99U, 0x738eb69078986157U, 0x9b9b937095626b83U, 0x8c3ec0a6708a8580U, 0x527378526e887f9fU, 0x6b8f808f7089a87eU, 0xa8945e794d9524c5U, 0xac5ca07f66607f4aU, 0x75746e6e80702a76U, 0x8f8a9d7e889e5879U, 0x957c7aad86635a78U, 0x5c7b896d9c7a997aU, 0x4d62898c769a9e82U, 0x93787a588a52954aU, 0x775a779790799fa2U, 0x7e90a28d62668689U, 0x6529a665849e6393U, 0x9c90854992b24875U, 0x7494779858857b98U, 0xa19d494943aa8e44U, 0x799465a98665869dU, 0x948c545256647f69U, 0x8b7aa264afa4875fU, 0xc79da2a75b81b27bU, 0x8f676e6cb370a08cU, 0x758d6d7d95ba579bU, 0x9d8d959bad8ea390U, 0x9481667a7e74567bU, 0x799976966684508cU, 0x77686f8dc78b958eU, 0x578b796168748d52U, 0x7ed56a69666aac72U, 0x6dba91a59e80776cU, 0x6a7e9c7684667780U, 0x78af8cc19c9eb075U, 0xc086a380b86aa3aaU, 0x5b5e6f9f70a66698U, 0xb49e5ca6c28a97a7U, 0x80448c9dab6d9fa5U, 0x8170888b7281b4aeU, 0x7d6c6c8570788cc0U, 0x9e807b99a68690afU, 0x81b6b98eb3969dbbU, 0x8da5617e8d7c69b0U, 0xa27789727a8aa5acU, 0x687b7d906c5c6a7fU, 0x807b8aaa5d799897U, 0x6d5f5f936e98978eU, 0x7f0e949cbd8a9087U, 0x7f9970809dbea6a0U, 0x8dae855f5b5c7fe4U, 0x6a853d9b9b389833U, 0x97947e9a7e6d977eU, 0x756c8a7d903c659aU, 0x687b668a5c738f9bU, 0xaa827fa55e638184U, 0x476c9f499a84746aU, 0x7b744b52898c7078U, 0xa04c93815571698eU, 0x7358487d7eae8a7dU, 0x966c87889c7a7a8eU, 0x897f6c6f6b70788dU, 0x5f70a370958f965bU, 0x9d837583735f5c84U, 0x717c788476a74875U, 0x79a2496b47a38e4eU, 0xa89c799c898e8a6fU, 0x4584715b999e7185U, 0x7c6194938e607d5dU, 0x615c6864757d2e73U, 0x95835c7db9767675U, 0xb1a293bf57958257U, 0x9880a4888d099c71U, 0x408f47307a9fa671U, 0x777792939f958a87U, 0x634a9897b24d7aaaU, 0x9b798f71909a9b83U, 0x587cbc76898f6b80U, 0x675869577e567d8bU, 0x59895682ac54a59cU, 0xab5885967a7d6c6fU, 0xae89717d746b86c5U, 0x9a4ca17e788e95b4U, 0x8d783c8f8997538dU, 0x919d7592907d5f7cU, 0x8a8a818f9f7368a0U, 0x4e7796777e7ea83eU, 0x686885b2599a9866U, 0x8898a5898e4fb3a8U, 0x629b9a7b8c919898U, 0x8a7abaaa64959fb7U, 0x5e4bb75e7d55bc93U, 0xa7ab7e88808db2b3U, 0x9273bd8e6a847ab3U, 0x8dbb3f62487ba8a6U, 0x665d6f604e9fcd60U, 0xa1276a98a97eb674U, 0x746c78676db493aeU, 0x9b8a6d6e3a4387d0U, 0x739512a8bca58a16U, 0x7aa36a5d83576958U, 0x9d9b6d839926a789U, 0xbc8c6fbe7e999e8fU, 0x8e88ae4a7d928589U, 0x618a7aa1788b8d4dU, 0x4e7dacb07d919b62U, 0x866c5e7883989d8fU, 0x9bb6658ba26b96aaU, 0xa79f9c8c8ea982a9U, 0x7fb3ca8a9c81857dU, 0x88a46fb0956367a6U, 0x4693729196666666U, 0x5dbe6f576e786692U, 0x739ab78ca2625aa7U, 0xab8b754b49b57ba2U, 0x8ea57a44b682b09fU, 0x667fa7ad817e6fb1U, 0x818885815c9da866U, 0x7d93a27c98a56c84U, 0x845398b1a35c5ec5U, 0x678883959e798eafU, 0xa1709e92804f737bU, 0x56719e7756ad6a88U, 0x7e7da360676a996eU, 0x7d9aa29d81636e79U, 0x898d54aea3758397U, 0x948b85b75d53968eU, 0x6e5e639092c66d78U, 0x7a68758b7a7aa183U, 0x8251535b4b81aa77U, 0x70a38c659a64a9b2U, 0x78846faaa57e6e72U, 0xa9ad724c969ab25dU, 0x71ab9577665c9d78U, 0x7fae988e98a551b0U, 0x774c897085645965U, 0x787777546780686fU, 0x826484b1988c786aU, 0x62869a6c8a7d5854U, 0x44608a4f7a7ead7bU, 0x898074a98b739459U, 0xa5873c8fa6b48b67U, 0xa2974e5c70a4617dU, 0x8054816c2fc69466U, 0x968c6e868f696a9eU, 0x8b71628b986f707dU, 0x5b7e968093448a54U, 0xa462bd8884cc6e83U, 0x61886a3268a4736dU, 0x89c3a4858f839c82U, 0x8c908d858e655d65U, 0x87637f51c8b79959U, 0x8c93d1a4bbadb05bU, 0x9d77565497a89c85U, 0x8574a6914d7e8562U, 0x77b1769d7f7d8776U, 0x99874d5e917a7958U, 0x6695aa4656bb7293U, 0x8c97769bb4566faeU, 0xc466cc6f82a6876eU, 0x6379465b9088786dU, 0x87768da6af785274U, 0xc8aa7ea8aeb04b91U, 0x74869f68a69d6a4bU, 0x907f847c825c69a3U, 0x755eb06c5294b281U, 0x84868d6f7990564fU, 0x527d65658761596cU, 0x5b4458726d55954dU, 0x6075a672836d7392U, 0x8ea046c482768884U, 0x80727b73a06f759aU, 0xb16a919f5b867559U, 0x7c69956b6197695eU, 0x807a576e82855170U, 0x75a773568f566fa0U, 0x8d7b6b63654e704dU, 0x8f34523f544e8c81U, 0x7b878e7a7e94456bU, 0x627e68ac69997f56U, 0x434d7f585f936561U, 0x78c49f4c86618c6bU, 0xb75663a69892a78bU, 0xaa7a846b8c59ad90U, 0x7d98aea040637271U, 0x62a58a8287ac709aU, 0x658b6a81a38cad98U, 0x6373a98f8b9b6b7bU, 0xa2a57f4c7c479d9eU, 0xa8ada392529b889fU, 0x8b7b7383b56a91b5U, 0x7068a934787d4975U, 0xa78d83909ca08aa3U, 0x9a7081aa98c76199U, 0x938e80789983735dU, 0x8646838e66988992U, 0x627e9f5aac83898eU, 0x4fb392808eb6a3a5U, 0x80848b9fab8538a3U, 0x688e9090727a6094U, 0x656c7f9b735b9180U, 0x718bc682b55082a9U, 0x58aaaa7f83939780U, 0x74ab7b70927da176U, 0x92b45678745aaaa2U, 0x8fb18a486ea458d1U, 0x6e8f4452778d70b9U, 0x9461874e838f668fU, 0x67408d5ba2964f5bU, 0x9182898f8db66f65U, 0x91c287528a5572a1U, 0x8d8969919a6d928cU, 0x8f7197419c7d92a5U, 0x97b58f6c941d78a1U, 0x9e55539c5c578c72U, 0x5a9847659e985271U, 0x457551477f946b66U, 0x6b8c649c54817b78U, 0x81917ba37f8e7886U, 0x6a7fb9988a8d6f6cU, 0xa27974a0b1999f8bU, 0x618ab68962a6636bU, 0x5a69705771505275U, 0x7b796c7a72647a74U, 0x5f9c784a5d826e55U, 0xa57091673f805a80U, 0xc0af58736792387fU, 0x42a27b89938133a7U, 0x5557819c436a9d82U, 0x67956d568a687a95U, 0x7b7c7d7786568ea2U, 0x9c828c517f60978eU, 0x99a2749f7f80a98cU, 0x97879d45ac7d9e90U, 0x7a878e798aa17c92U, 0x8e74556da979a94bU, 0xcb8c9d63a0948b79U, 0x92b77a927fa3a591U, 0x798a958c825aa6aaU, 0x8b84899d7da091a8U, 0xa1ac66907aa08897U, 0x8072849174b44e8bU, 0xaea86f8a79917e51U, 0x75577c5d94c06ea0U, 0x817e8d7c8b707f58U, 0x687898ad709c7961U, 0x5e9a7f61aa9b6385U, 0x9fa090ad788f5741U, 0x7a54a86c8f73808dU, 0x845a837d538ba986U, 0x727f8475696a8290U, 0x9eac5c9280617f89U, 0x97727fb083769990U, 0x5c747f7d70a37c6aU, 0x836e929692818275U, 0x7d7e8a6b9e5493a5U, 0xaa6a849b75a65a81U, 0xb790628957935682U, 0x818d5cd4739f6698U, 0x7da06e9881984058U, 0x8f5b8d6a6b7a6d75U, 0x846984509b7d8f84U, 0x7a5a9589957eac5aU, 0x678a687b697f3c79U, 0x6b468c2f686d6b79U, 0x748e9379638bc856U, 0x8457707970805eadU, 0x85834d88b892586eU, 0x784e88605eac928fU, 0x6f4da15c836d926eU, 0x42956a66a88b5d60U, 0x648a75777c6e8c7aU, 0xb08b8f9982893484U, 0x6d655b9248a2a65dU, 0x667c646780a69873U, 0x33aa7583908c6491U, 0x96815d8d88935f80U, 0x6e5a7e49a07c7c84U, 0x76b58a85a38ab687U, 0x4f7c848b668f778eU, 0x8f543b5170605e7bU, 0x69a9adb1936fa0a6U, 0x75464488627dba7aU, 0x5679ae6f5b5f5a72U, 0x7fa187748b7262baU, 0x7363918f85888299U, 0xa29491b6a79a848eU, 0x69409e9a8c9473a0U, 0x88a89288766f729aU, 0xba43507b6cc18e4fU, 0x89489f7bc2a74294U, 0x9fa0907968645738U, 0x7a825b698078ad56U, 0x8aab7888596b787aU, 0x5e8c9f9380c566a3U, 0x9ca2b3765791946bU, 0x2d56b99b664c9e9bU, 0x9d669653706d8489U, 0x9a735eb89a7c818aU, 0x9782928a995b7eb1U, 0x727457705ea2725cU, 0x8c607db18b5da36bU, 0x816d8283655e7a68U, 0x7197689dab659e8fU, 0x77a892956c659089U, 0xb278486b9388bca8U, 0x6f966d8c517e6a88U, 0x818f7aac9c6e9c72U, 0x9ea84eaa8184795cU, 0x77658d99829a5b52U, 0xa88c6cbb8d81876fU, 0x949f4eb682851c57U, 0x62695862a381626fU, 0x62a770b94daac365U, 0x743e8c6c8ac69da9U, 0x50707893917b2f78U, 0x6db16b80858e8da7U, 0x76a462789d6e8c63U, 0x78763a898382527fU, 0x639d978c9883727fU, 0x777272856e903268U, 0x8339715d2da1b198U, 0x897376718a7d6c9eU, 0x3bb88e8cb3a03e7dU, 0xa9435f775bb56a64U, 0xbc495653a678817aU, 0x866aa765795375a4U, 0xb3a8826d8177af87U, 0x72716a6f5dab478eU, 0x836ba594717e783aU, 0x8ebe826968195bb0U, 0x6775b77b9f6ab58aU, 0x9a3b96946d7e9785U, 0x865a6685885b5b5bU, 0xba8d9c7158ac9567U, 0x93a7808a676e6d7cU, 0x775591a5a86eb47bU, 0x9a8f6d878b5d906fU, 0xa57d9c776321a49dU, 0x837d41ad858e9d74U, 0x4e7a80a165819164U, 0x897d44a56a73ab88U, 0x61a96b9a5863b780U, 0x83a7916d76825a54U, 0x634ea19d816f6b94U, 0x567e78af6390b76bU, 0x9f86b287b9778582U, 0x607d94749c76795eU, 0xa07e4e96b485a37aU, 0x9170767da9a57d54U, 0x9671475b90907b65U, 0x536d92b285a7946dU, 0x928e928dab55b083U, 0x7c9b679547659a57U, 0xc09f85846c739a4fU, 0x71b0ae7d81bc9d85U, 0x4e84696245955292U, 0x9cbbaaac984da2a2U, 0x9e8e5a82995cb576U, 0x696e518aa1977189U, 0x76777c4b3a8a9172U, 0x2299ad7f577a6a95U, 0x84935fa381506660U, 0x589cb575576b7a84U, 0x99975b8d94ac5467U, 0x9eaca1797d926777U, 0x73a38a83446e4ea8U, 0x74ae7d8774736162U, 0x327ab370544d7c40U, 0x935d7b3b623d7f6bU, 0x6a8bb5514c823b7cU, 0x466068a64842808cU, 0x84625d6261727194U, 0x60895857a2ae6e74U, 0x7c71b36292829bb3U, 0x6bb95696479e4b78U, 0x4d6389479b359e6fU, 0x838c926d5b6cf166U, 0x7066806394ba7874U, 0xab4c42a5aa7f69b5U, 0x5c8a4e625b9a9b82U, 0xbb64839e8474354eU, 0x8d7a513d56b74466U, 0x87b08fa896538777U, 0xb363b7b28b825983U, 0x8e6638ad4b8471c9U, 0x9b5980856c4ebc91U, 0x2eb57254bc7b5fb4U, 0xa1624a70b0dc3b68U, 0x92368277af83407cU, 0x695c6e40a826aa72U, 0x64845e8094a16287U, 0x5146767d815145a1U, 0xa89e6388716db4abU, 0x977a579065b5a4acU, 0x915a609e6c99648cU, 0x4f5b8f8594618c57U, 0x895c788367963361U, 0x8a7dc648579b833fU, 0x5b67aa66a0768a89U, 0x68508a76647088bcU, 0x8b8e566b38636d9aU, 0x9c638a66b1677069U, 0x6f728d948387ab5cU, 0xba9366a7647a8d4cU, 0x6186906d9c8c3783U, 0xa2d691618d71736bU, 0x72a48b5c75b47674U, 0x745b709e6d3c9f57U, 0xa2b2a3a4614a6876U, 0x6c2da56ca287bf55U, 0x7678757f8b738870U, 0x6db08f8e988562aaU, 0xa5a0ba8f6e9b8999U, 0x4cb2d991bd7d8d72U, 0x66a6b269964a904cU, 0xa059427b5b719593U, 0x69aa6e9b67a7717aU, 0x6864965b8eba5f61U, 0x84886f5fa470726aU, 0x8c96728db2726a86U, 0x9c6a75aa875f8678U, 0x8d9499746b8b7370U, 0x897a87926b847896U, 0x4a51825597b4887bU, 0x955f8b928e7ca580U, 0x9a8e63b5a78d525bU, 0x8ba077977f9b9e5bU, 0x7b537bab88b49c5bU, 0x826fa7978d509f5aU, 0x7c9c7e7eb19ba858U, 0x688e8bb490709f6bU, 0x5575948d9161967dU, 0x7f79788064847f71U, 0x8293907e7370a682U, 0x7f668f8d818d7f7eU, 0x5269798047969f69U, 0x708caa5aa59c975cU, 0x9585a46c9d63ad87U, 0x97656174b57aa789U, 0xa7b457628ca546aaU, 0x6884617976797596U, 0xa9b26c6aac624d86U, 0x7a5c9b9c6867869bU, 0x84a08c99ab807556U, 0xa5a7707a6b986440U, 0x71676c576f9a8671U, 0x688b73a085c26775U, 0x789581987d747e5bU, 0x82815d6982289abfU, 0xcc4fab6dff4fa85bU, 0x739f78af8eea8dc1U, 0x9e784fa06d725f99U, 0x78d4495f659e7f72U, 0x5bb8a6cf8f796462U, 0x7dad7b61835d9569U, 0x7a76799380787165U, 0x695c9dbb957ab55eU, 0x577c449885a99086U, 0xcfb3437675e85db9U, 0x9673937a889c807dU, 0x6346989d8c65aa83U, 0x7e68d3ced4aa9094U, 0x699f5d81954985a7U, 0x8b6f9b8894b18f82U, 0x5ba16c8b8a9694a2U, 0x466e667a566bada6U, 0xa2af76693e57718eU, 0x61757c6da3b8876aU, 0x6966898f7ea99371U, 0x759b9c70ce96b6a7U, 0x747f5f8d7aa48790U, 0x51b15f9653826f74U, 0x808fb48c737e715dU, 0x859875b077677362U, 0x94af767eb49aa99bU, 0x6f8b6847988d9365U, 0x84a6a179566b7a9eU, 0x8182ca9187698e7fU, 0x52a67c61d1a04c86U, 0x5a63545f37928270U, 0x6f83a685aa838567U, 0x9ba3767a6a9b994eU, 0x9c848b837f896275U, 0x866489b59190d0a6U, 0x565584977ca973beU, 0x6f5d506db6488867U, 0x63868f8894586f68U, 0xaea0a05598617a88U, 0x63688d3e4f6b7c66U, 0x6391b97a9a5d9090U, 0xaba19275a361a659U, 0x649156a8adadac6cU, 0x7a8a5e6a486d7e93U, 0x6f62b3886e70525fU, 0x576a729473b39ca9U, 0x5bbaad454dae4f24U, 0xb65c8a937d89ab61U, 0x7e909baa884c9285U, 0x4b8b8eacb27d2585U, 0x6c3eb199319f9874U, 0x7e698b6eb5984aa2U, 0x7eb1e5799d92989fU, 0x2ea62768a68a28b4U, 0x435e7a764c6e75a5U, 0x908577d068309e6cU, 0x83796e69897c68bdU, 0xa7808fd0b66064b3U, 0x946ba7936fa9837eU, 0x7d847caa80a98472U, 0xb6b55a93659d5f7bU, 0x637f65c69c8d8f97U, 0x4152887d5a60ae86U, 0xa2506fb80771b081U, 0xb13e9e507d354fcaU, 0x50a73cb2aa86ac83U, 0x9b6b6fa664c8906bU, 0xccaa3a1c65a0817bU, 0x86c4b3b1b77cb394U, 0x6b69687b925b8575U, 0x65796f5b888e7c54U, 0x524fa64c7e60538fU, 0x9298576db27676bfU, 0x98db7b977f767991U, 0xb87a654ca069a565U, 0xaf75bc9d3d954fa1U, 0xabac658e919d9d7cU, 0xae94b1525360549fU, 0x8a5f82575fa8716fU, 0x8da081a69e9da063U, 0x619478a3ad8b7098U, 0x83415c86bb7f9d79U, 0x5a7dbb7b76af92acU, 0x644ea7665e848193U, 0xbd55a09d889ea497U, 0xbd2d24d6bdc1f409U, 0xbd8bfdb33dbbf1a5U, 0x3dda5581bdbac85aU, 0x3d7d23abbdd79e03U, 0xbdd7e845bdcba4dfU, 0xbd6da55b3d0162ffU, 0x3dd1c4cb3db12d04U, 0xbdf152b3be0e3524U, 0xbd8e1accbdbaf58aU, 0xbdeeb67e3dd0493cU, 0x3da3fb03bda901e2U, 0x3cdc4a653d190898U, 0xbd8c6d3c3df8a75cU, 0xbe00b87e3e004a6dU, 0xbde4b3f7be0d6945U, 0x3dc0d2933de12f60U, 0x3d8bbacbbd36d2ceU, 0x3d96769abd8b88d5U, 0x3dac1628bdeaf8f7U, 0xbdced66d3d5ed34bU, 0xbdd44cb03da1c490U, 0xbde96494bdef1183U, 0x3dce1515bdc105a4U, 0x3dc105b23dda2f67U, 0xbdebf4d13e0627baU, 0x3d959bc13d54bfdbU, 0xbd44f7debdb3f916U, 0xbddbac9d3deef93eU, 0xbb2cdccf3defbc46U, 0xbdb52ea83c8b1926U, 0xbd54495dbdafd922U, 0xbc3ad6c4bdba658cU, 0x3a323d35bddbfb34U, 0x3a9709f13d93f0edU, 0x3d261bd1bd31ce47U, 0x3d03593dbce15aa9U, 0xbc6f3377bdff285cU, 0xbbb9a2dcbd39daeaU, 0x3c8fa69c3dd4d46fU, 0x3c2b88c63ce2cd6bU, 0xbcaf32dbbe4af0efU, 0xbcc5cc183dbe82e0U, 0xbb1e78c9bdbe1446U, 0xbca4a7be3bea0762U, 0xbc7fda823d77ee0eU, 0x3c3386623dae4528U, 0xbdfff69bbd946d0fU, 0xbcdbcfa93d14742bU, 0x3cef612ebc90bbd4U, 0xb95f8ba5bb611f05U, 0xbc20cbb9bc8d16f0U, 0xbdf0bc153ccb129fU, 0xbd3b06503c90aebbU, 0xbd62233ebd40aefeU, 0x3b851be8be337535U, 0x3d05f22f3b07094eU, 0xbb2fe3df3d572225U, 0x3c6954dabdb0464aU, 0xbd315144bd5bbb8dU, 0xbceca0913d023ccbU, 0xbab38b5e3d68b5e0U, 0xbc88976ebd0a9714U, 0xbd5ee293bd9b5bb1U, 0xbca501c93cf132d5U, 0x3db14c06bc371b75U, 0xbd9a02fb3dd286a3U, 0xbc3f0a5abcc9bf12U, 0x3d956be93bc618efU, 0xbbc869313dd1ddf8U, 0x3c6278a63d61579bU, 0xbd9e8d05be7eaf5aU, 0x3dc030e4bd3fdf1dU, 0xbc8f5c1d3cb23172U, 0xb9c19628bcea8c5cU, 0xbde87dafbc4a769aU, 0xbe11a257bd4e2e67U, 0x3c8010d13cb82d48U, 0xbd672c1f3d7661dfU, 0x3dccb7153e397b57U, 0x3da2027dbe0dba5aU, 0x3e3395a0be044b3fU, 0x3a56f82dbc2a0ffeU, 0x3daa71303da1e3b2U, 0xbe3af62a3d727e22U, 0xbce27134bd7914d4U, 0x3c255e673d0bff2fU, 0x3c8e8cbf3c6f0f8cU, 0x3dc1f622bd90dac4U, 0x3dc4a996baca4e23U, 0x3c4ada163d1dcaa9U, 0x3ddb5e34be211ac3U, 0x3db4d677bda60281U, 0xbda0fc27be193b50U, 0x3d95dce4be62028eU, 0xbd0a93dd3d873db5U, 0xbe405f733dac4ed4U, 0xbdc784e6bd2df29dU, 0xbdae9bee3db95cbaU, 0xbda7cf85bce20857U, 0x3d8892503e3e55f7U, 0x3dfeb3c03c4f7488U, 0xbe20b31dbd775a00U, 0xbe2fa906bdfde390U, 0xbdd2fa15bd71f8a9U, 0x3ceb095fbe1fe4cfU, 0x3bdc05d8bdc6583bU, 0x3d9d2002bda2ed57U, 0x3b4abc4c3d9e7755U, 0x3b8ee64a3e0681deU, 0xbdad1e73bd0214edU, 0xbd43cf7d3daa01deU, 0x3d868bd6bdaf5211U, 0x3db36bcf3dd3fde0U, 0x3e128757bcbd4fa9U, 0xbd73df6d3d59d64fU, 0xbc07246dbd3b7df1U, 0x3d7ab0f33c897541U, 0xbb28620a3d5db0bbU, 0x3ab68b38bd92b7adU, 0xbd0939b83beb4278U, 0x3e3a11d6bdd7dd59U, 0x3e47d76dbe77db26U, 0x3dfbc3dd3d1d84a2U, 0xbd849ee4bde5d041U, 0x3d7d9425be11f3e7U, 0x3d411183bcbbb46fU, 0x3d07eb86bcadb398U, 0x3e20f6acbe1912ecU, 0xbda154aebea1f471U, 0xbdfaaa443b287581U, 0xbdcf49f53daac600U, 0x3da27a273ba275e7U, 0xbe1225313c084058U, 0xbd3cafd73e803a92U, 0x3d4a6d573d546b5cU, 0x3dac4e603ddc3126U, 0x3e0664d93d286779U, 0x3d8b23ab3e14fef8U, 0x3dae70e63d466dfaU, 0xbb62e9b3bdfe64faU, 0x3dd5497a3dbdc2c6U, 0xbd2f348a3d71cb3eU, 0x3d12aac7bd77587cU, 0xb924fcc63ca17470U, 0xbcd7fce1be09386eU, 0x3d6b9a1fbe035079U, 0xbda89e923e6b020dU, 0x3e5fff48bc580cbaU, 0x3df72d703e07cd27U, 0xbba70dc6bcfb04e3U, 0x3d87f2403db798beU, 0x3ca750a3bd15d355U, 0xbb2192783e0fd3feU, 0x3cf4ef8dbe03fb81U, 0xbe3e5eba3e590e67U, 0x3e48fb78bd776db0U, 0x3dcbb4163e555f7eU, 0xbd4208123e9f5da7U, 0x3d84a8fc3ca27fbcU, 0xbdd0839b3e33e8caU, 0x3d819c99bc468b56U, 0xbd1b3d65be2ecca5U, 0xbd596377bca9c148U, 0xbde6bf8a3cbac721U, 0x3d4ea94d3d5c1481U, 0x3d06060c3d09e5cdU, 0x3dcddceebd95d0dcU, 0x3d71a7013b5929e7U, 0x3dd3d11dbdba801bU, 0xbda2523e3e015ae7U, 0x3d50519abddcf1caU, 0x3b29ba34bdcf7c73U, 0x3b08aaaebc5d201eU, 0xbdea301e3dff02ecU, 0xbd8369083d22c64eU, 0x3e04ea273d80a3f4U, 0xbe5d6dac3d27cf77U, 0xbdba260a3dc7bcaeU, 0x3ddf5facbe513d7aU, 0x3d49ec66be3b775aU, 0x3da4dd9e3c07b69aU, 0xbe8e14af3df44c97U, 0xbc4720843dc8216cU, 0x3dcb10bc3dbde728U, 0x3c65eba53ce307afU, 0x3c94700dbbb8ecc4U, 0xbdac7d873d05c144U, 0x3d840fa8bc685eccU, 0x3dad00403d875352U, 0xbc32f8babbf96532U, 0xbdb38acc3d9cd15aU, 0x3deca222bbcac518U, 0x3bcdff89be061bebU, 0xbe283048bd93f8fbU, 0xbe035acd3d6993f1U, 0x3d8616a13d97d455U, 0x3bceb99fbd23d6c4U, 0x3dc7d0a63d264650U, 0xbd0ea2a13e04cbd9U, 0x3dbd6f89bd1d2568U, 0x3d36b7db3c889bc9U, 0xbda8c1aabda7513eU, 0x3dfb7e05bda8d353U, 0xbdce86783d428c59U, 0xbd0cd41e3dbb9076U, 0xbc302fbbbdd6bb1eU, 0x3e62b91e3e12bb9aU, 0xbe1dc99f3d383ef0U, 0x3d477491bd2d055aU, 0xbe0358cdbd291381U, 0xbdca88a43e360fa3U, 0x3dabec9f3e3a1b04U, 0xbdce2d723d9a4178U, 0xbcb9d673be18fa34U, 0xbd94ab523d402d23U, 0xbe022033bd7bab44U, 0x3d63e3593e2197ceU, 0xbd25f8af3b127df1U, 0xbdc2cd6d3dc5b4bdU, 0x3cc0369dbe2f8f82U, 0x3d25d446bd1b3705U, 0xbb4d88a9bd807887U, 0xbdad7af9bdcff7b4U, 0x3be1b08fbd1eea9aU, 0x3ca3d17a3c7b199aU, 0xbd00391cbdfdaaacU, 0x3d52fc243c98c23bU, 0xbd4a8c47bdeda0eaU, 0x3c84886b3ddeda18U, 0xbddac230bda91584U, 0xbd08932d3d22422aU, 0x3dcce9e83e090a5cU, 0x3cd2b0103c8a448eU, 0xbc47b348bd999d5fU, 0x3d91c8463da7d808U, 0x3dd66d0cbd25d994U, 0xbd3100893eac798dU, 0x3d856c44bdcb8703U, 0xbdb966ad3e66bbafU, 0x3e11f1c1be028293U, 0xbbf2b85ebd07f9b7U, 0x3d8012fb3dc0496aU, 0x3e463835be156130U, 0xbdd3598cbe9e4408U, 0xbd1f53b03dbbfd1dU, 0xbd4f725dbd3a00b8U, 0xbd00c9693d6666f9U, 0x3e7039093e107512U, 0x3ac0cbbabe261974U, 0xbd06ddf03e251f63U, 0x3cafb5d43da0984dU, 0xbe7b0f053cf599ceU, 0x3d9302263c953d23U, 0x3e539231bdd1061dU, 0xbdca3d38bc80af3cU, 0x3e297738bdfded51U, 0x3d2d0613badd93b3U, 0x3c030158bd1482a7U, 0x3da9a75fbd9e0125U, 0x3ccdec733dbac373U, 0x3ccc80593dae56e1U, 0x3d4d42d73d8b6b38U, 0x3bee5e1c3dc7f758U, 0x3db193ff3c21bc70U, 0xbc535158bda88547U, 0x3ce4eeed3da12517U, 0xbc89fa893c5c850fU, 0xbd56be793e1d8d5dU, 0x3d7dd6263d981bfdU, 0xbddd4d793c85e977U, 0xbe079ed0bd9c98a1U, 0x3e447a3dbc864b59U, 0xbc935f2fbdd4bbefU, 0xbcd97119bd227328U, 0x3b3050df3d553100U, 0xbda506153e309309U, 0x3dbbf02fbe0b501dU, 0x3b265f993d82e7aeU, 0x3dd94505bd85cdb2U, 0xbdd7f6c23cedd5a9U, 0x3d4f561d3e423db6U, 0xbdb08243bca451b4U, 0xbc9f263dbe2466e5U, 0x3dd8b1313dafe37dU, 0xbc83d3513e1ef6a1U, 0x3e169c613c0287eaU, 0x3c559d48bd93b96aU, 0xbb48d1dd3d14c045U, 0xbdbf1395bdfee254U, 0xbd93be9cbd91f04dU, 0x3dc7e6b8be5c21dcU, 0xbd32db2f3cf9b083U, 0xba220048bcd30ab0U, 0x3e164977bdb8750fU, 0xbdc1b3bbbdf4d1a6U, 0xbd57eef2bd944f61U, 0x3d1be8f13d8c4ce1U, 0x3d22387bbe3d0f9fU, 0xbd6b178a3cb86e7eU, 0xbbc11555bd4f860cU, 0x3e0dec133d864b1fU, 0xbcb6281bbd5a2463U, 0x3d912d87bcc028f9U, 0x3d74f130bc2b6561U, 0x3c0550583e07ed05U, 0xbe0f04bfbd40788fU, 0x3db086f8bda31e9fU, 0xbb277b2c3da4eb73U, 0x3ca2dcc6bde15b43U, 0xbde8ee38be17b34eU, 0x3de3d0273d72f074U, 0xbe0516c8bdc349bbU, 0x3d24b830bc91c031U, 0x3e1b6ac1be3107dcU, 0x3d3fb6343dad79bbU, 0xbdf92f02be317a04U, 0x3e296028bcef7844U, 0x3e055b323d395df8U, 0x3dd5abaa3dfaec28U, 0xbde171d93a7b1e1eU, 0xbce238aabe5277b4U, 0xbd8424243d76fadcU, 0xbd80ac283ebd0600U, 0xbdab3fd53e1a35baU, 0x3dd3cfc03d6c55bcU, 0xbe0021d03e26cd0bU, 0xbe3084f53e127193U, 0xbc0bdb053e49e952U, 0xbd064e3d3dbfeafdU, 0x3d049966be0fe8a6U, 0x3c291300bd526f1fU, 0xbe481407bc4d97f2U, 0xbd5ffe27bddeab43U, 0xbdbcc2bcbd99acb6U, 0xbd853e9c3a747be1U, 0xbe352d7d3ba027fcU, 0x3d4971903da89ab3U, 0x3dcd0f3d3dce6bc0U, 0x3d7d333abd23adf8U, 0xbcd82705bad2e43fU, 0xbdba3b17bd160332U, 0xbe0bf9e23e0f0dc2U, 0x3dda0af4bd93d925U, 0x3e0d29a4bd5bf7f2U, 0xbd840c03be03af94U, 0xbde3c09b3dd2732fU, 0xbe08be273c9fe457U, 0x3d1a01923e2e9023U, 0xbe12fb863e521705U, 0xbd068af83de407ffU, 0xbe2248f2be22f677U, 0xbcc319aabc8cd285U, 0xbc42f37dbdef7cd5U, 0xbde499743e584cf6U, 0x3d0857163d4a62b4U, 0xbe14b2ae3d042729U, 0xbcf12063bd9609b6U, 0xbd613333bd68265fU, 0x3d27e8393c90c703U, 0xbdc1aa6dbda44ce0U, 0x3dd0b0f2be2ce99eU, 0x3d044d4b3a773f7cU, 0x3dfa0ffbbd585506U, 0x3d9578d5bdd2ca0eU, 0x3dfd2cd7be0662e1U, 0x3d4b048e3dbb827dU, 0x3c41d0713dc08819U, 0xbe255f663c430af5U, 0x3ba9ee403c1644b1U, 0xbdefd260bd85587aU, 0x3da71eb7be0f95a8U, 0x3d72c29abd33a00cU, 0xbd8c9e61bd588572U, 0x3e049c6b3d34dda4U, 0xbd8b9c7f3d5ddbb8U, 0xbb85f1b9bdc6f27dU, 0xbd172b023e09a9e7U, 0xbded3e2fbd59f3dcU, 0xbe1a1f973c76f2baU, 0xbbabcc3bbd99eb86U, 0x3dedf000be02addcU, 0x3e1cd29abe71d6e2U, 0xbc023c1cbe16a064U, 0xbdbd7d1cbd7ca548U, 0x3cd1cfd8be1f755eU, 0xbe36c115bd8b4f6fU, 0x3dbe9b263db29a76U, 0x3d42dada3d0e3f63U, 0xbdb829b8be3b738fU, 0x3cced0a4bb12ca3eU, 0xbc9cd31a3cb228f6U, 0x3c60ac82be0b8d19U, 0xbd7938a83ca2cf64U, 0xbbc5db80399836adU, 0x3c8c023bbde312cdU, 0xba8b6ed33d9c26dfU, 0xbd1fc0863e115d05U, 0xbe164071bdf1f4ebU, 0x3e021d53bdc36d24U, 0xbdfd92c6bcedda4fU, 0xbd6cb2a63e332898U, 0x3e23c6d1bd868944U, 0x3dd6d0223d0d61efU, 0xbd948984ba68aa42U, 0x3d2d39713e40dcb0U, 0xbc6155c2be35585eU, 0xbd06aab13dba41b8U, 0xbe02b57fbdb7ab31U, 0x3da878eebd957e8aU, 0xbe784872bdf58371U, 0x3da43c6b3df13eafU, 0xbdb2ccd7bbc9198eU, 0xbd388f3e3df5a2caU, 0xbcaa3e8abdef33b8U, 0xbdb6f961bdea0fd7U, 0xbe15ea8abe49a047U, 0xbda2a0cebdef959cU, 0xbcd3978cbe3aa658U, 0x3d8a0683bd16771bU, 0x3e150786be19cd87U, 0xbc60fab53e408a01U, 0xbe05a7ca3db796bdU, 0x3df11d05bd4fdfe7U, 0xbd9b32d3be85bc49U, 0x3dc211e93deaf7ebU, 0x3d56b0dbbdfadd72U, 0x3c61d85d3e53540bU, 0x3e63ddd93e5c0b12U, 0x3cef46dbbcfff9f2U, 0x3d8f2d2f3dbd4e7fU, 0x3d76bdd93d6071ceU, 0xbe02793fbe03ded5U, 0xbde25897bdc877a9U, 0xbd0e738d3c8c9815U, 0x3d8ac2bbbe3adff4U, 0x3d7829403e22dc77U, 0x3dfdcac1bd8ac750U, 0xbd3a9f343dcb7b6dU, 0x3cf07c8fbddb8a49U, 0x3da813debd9c4416U, 0xbd646ceabd2affbcU, 0x3ba082b73ca5c584U, 0xbca11ac2bdb369ccU, 0xbde6f31bbd96d2b3U, 0xbd6738b9bdbb4397U, 0x3e19866c3d6cc685U, 0xbda70e1a3e5e1f29U, 0x3d8e956b3e1ca6d4U, 0x3d82e2a3bd93ca77U, 0x3ce8804a3d864a4bU, 0xbda0a704bd818b4aU, 0x3c8e70893daa00b7U, 0x3ce3bacdbc8fe4c1U, 0xbd879da83ccdf1dcU, 0x3f8000003f800000U, 0x3f8000003f800000U, 0x3f8000003f800000U, 0x3f8000003f800000U, 0x3f8000003f800000U, 0x3f8000003f800000U, 0xc00064dfc00e7d86U, 0xc00e5050bffdc125U, 0xbfede25fbfed838dU, 0xbffb408bc00e64b1U, 0xc0138a24bff4cfceU, 0xbffd1a44bffe0755U, }; ai_handle g_network_weights_table[1 + 2] = { AI_HANDLE_PTR(AI_MAGIC_MARKER), AI_HANDLE_PTR(s_network_weights_array_u64), AI_HANDLE_PTR(AI_MAGIC_MARKER), };
167,866
C
83.824154
85
0.880768
Tbarkin121/GuardDog/stm32/AnymalNet/X-CUBE-AI/App/network.c
/** ****************************************************************************** * @file network.c * @author AST Embedded Analytics Research Platform * @date Sat Jan 6 20:35:01 2024 * @brief AI Tool Automatic Code Generator for Embedded NN computing ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. ****************************************************************************** */ #include "network.h" #include "network_data.h" #include "ai_platform.h" #include "ai_platform_interface.h" #include "ai_math_helpers.h" #include "core_common.h" #include "core_convert.h" #include "layers.h" #undef AI_NET_OBJ_INSTANCE #define AI_NET_OBJ_INSTANCE g_network #undef AI_NETWORK_MODEL_SIGNATURE #define AI_NETWORK_MODEL_SIGNATURE "ea19e02ca028c0f0f356ef6bad3672ec" #ifndef AI_TOOLS_REVISION_ID #define AI_TOOLS_REVISION_ID "" #endif #undef AI_TOOLS_DATE_TIME #define AI_TOOLS_DATE_TIME "Sat Jan 6 20:35:01 2024" #undef AI_TOOLS_COMPILE_TIME #define AI_TOOLS_COMPILE_TIME __DATE__ " " __TIME__ #undef AI_NETWORK_N_BATCHES #define AI_NETWORK_N_BATCHES (1) static ai_ptr g_network_activations_map[1] = AI_C_ARRAY_INIT; static ai_ptr g_network_weights_map[1] = AI_C_ARRAY_INIT; /** Array declarations section **********************************************/ /* Array#0 */ AI_ARRAY_OBJ_DECLARE( obs_output_array, AI_ARRAY_FORMAT_FLOAT|AI_FMT_FLAG_IS_IO, NULL, NULL, 48, AI_STATIC) /* Array#1 */ AI_ARRAY_OBJ_DECLARE( _model_running_mean_std_Sub_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 48, AI_STATIC) /* Array#2 */ AI_ARRAY_OBJ_DECLARE( _model_running_mean_std_Div_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 48, AI_STATIC) /* Array#3 */ AI_ARRAY_OBJ_DECLARE( _model_running_mean_std_Clip_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 48, AI_STATIC) /* Array#4 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 256, AI_STATIC) /* Array#5 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_1_Elu_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 256, AI_STATIC) /* Array#6 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 128, AI_STATIC) /* Array#7 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_3_Elu_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 128, AI_STATIC) /* Array#8 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 64, AI_STATIC) /* Array#9 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_5_Elu_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 64, AI_STATIC) /* Array#10 */ AI_ARRAY_OBJ_DECLARE( value_output_array, AI_ARRAY_FORMAT_FLOAT|AI_FMT_FLAG_IS_IO, NULL, NULL, 1, AI_STATIC) /* Array#11 */ AI_ARRAY_OBJ_DECLARE( mu_output_array, AI_ARRAY_FORMAT_FLOAT|AI_FMT_FLAG_IS_IO, NULL, NULL, 12, AI_STATIC) /* Array#12 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_Mul_output_0_output_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 12, AI_STATIC) /* Array#13 */ AI_ARRAY_OBJ_DECLARE( log_std_output_array, AI_ARRAY_FORMAT_FLOAT|AI_FMT_FLAG_IS_IO, NULL, NULL, 12, AI_STATIC) /* Array#14 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_Constant_output_0_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 1, AI_STATIC) /* Array#15 */ AI_ARRAY_OBJ_DECLARE( onnxDiv_41_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 48, AI_STATIC) /* Array#16 */ AI_ARRAY_OBJ_DECLARE( onnxSub_38_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 48, AI_STATIC) /* Array#17 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_weights_array, AI_ARRAY_FORMAT_LUT8_FLOAT, NULL, NULL, 12288, AI_STATIC) /* Array#18 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_bias_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 256, AI_STATIC) /* Array#19 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_weights_array, AI_ARRAY_FORMAT_LUT8_FLOAT, NULL, NULL, 32768, AI_STATIC) /* Array#20 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_bias_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 128, AI_STATIC) /* Array#21 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_weights_array, AI_ARRAY_FORMAT_LUT8_FLOAT, NULL, NULL, 8192, AI_STATIC) /* Array#22 */ AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_bias_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 64, AI_STATIC) /* Array#23 */ AI_ARRAY_OBJ_DECLARE( value_weights_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 64, AI_STATIC) /* Array#24 */ AI_ARRAY_OBJ_DECLARE( value_bias_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 1, AI_STATIC) /* Array#25 */ AI_ARRAY_OBJ_DECLARE( mu_weights_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 768, AI_STATIC) /* Array#26 */ AI_ARRAY_OBJ_DECLARE( mu_bias_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 12, AI_STATIC) /* Array#27 */ AI_ARRAY_OBJ_DECLARE( log_std_scale_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 12, AI_STATIC) /* Array#28 */ AI_ARRAY_OBJ_DECLARE( log_std_bias_array, AI_ARRAY_FORMAT_FLOAT, NULL, NULL, 12, AI_STATIC) /** Tensor declarations section *********************************************/ /* Tensor #0 */ AI_TENSOR_OBJ_DECLARE( obs_output, AI_STATIC, 0, 0x0, AI_SHAPE_INIT(4, 1, 48, 1, 1), AI_STRIDE_INIT(4, 4, 4, 192, 192), 1, &obs_output_array, NULL) /* Tensor #1 */ AI_TENSOR_OBJ_DECLARE( _model_running_mean_std_Sub_output_0_output, AI_STATIC, 1, 0x0, AI_SHAPE_INIT(4, 1, 48, 1, 1), AI_STRIDE_INIT(4, 4, 4, 192, 192), 1, &_model_running_mean_std_Sub_output_0_output_array, NULL) /* Tensor #2 */ AI_TENSOR_OBJ_DECLARE( _model_running_mean_std_Div_output_0_output, AI_STATIC, 2, 0x0, AI_SHAPE_INIT(4, 1, 48, 1, 1), AI_STRIDE_INIT(4, 4, 4, 192, 192), 1, &_model_running_mean_std_Div_output_0_output_array, NULL) /* Tensor #3 */ AI_TENSOR_OBJ_DECLARE( _model_running_mean_std_Clip_output_0_output, AI_STATIC, 3, 0x0, AI_SHAPE_INIT(4, 1, 48, 1, 1), AI_STRIDE_INIT(4, 4, 4, 192, 192), 1, &_model_running_mean_std_Clip_output_0_output_array, NULL) /* Tensor #4 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_output, AI_STATIC, 4, 0x0, AI_SHAPE_INIT(4, 1, 256, 1, 1), AI_STRIDE_INIT(4, 4, 4, 1024, 1024), 1, &_model_a2c_network_actor_mlp_0_Gemm_output_0_output_array, NULL) /* Tensor #5 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_1_Elu_output_0_output, AI_STATIC, 5, 0x0, AI_SHAPE_INIT(4, 1, 256, 1, 1), AI_STRIDE_INIT(4, 4, 4, 1024, 1024), 1, &_model_a2c_network_actor_mlp_1_Elu_output_0_output_array, NULL) /* Tensor #6 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_output, AI_STATIC, 6, 0x0, AI_SHAPE_INIT(4, 1, 128, 1, 1), AI_STRIDE_INIT(4, 4, 4, 512, 512), 1, &_model_a2c_network_actor_mlp_2_Gemm_output_0_output_array, NULL) /* Tensor #7 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_3_Elu_output_0_output, AI_STATIC, 7, 0x0, AI_SHAPE_INIT(4, 1, 128, 1, 1), AI_STRIDE_INIT(4, 4, 4, 512, 512), 1, &_model_a2c_network_actor_mlp_3_Elu_output_0_output_array, NULL) /* Tensor #8 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_output, AI_STATIC, 8, 0x0, AI_SHAPE_INIT(4, 1, 64, 1, 1), AI_STRIDE_INIT(4, 4, 4, 256, 256), 1, &_model_a2c_network_actor_mlp_4_Gemm_output_0_output_array, NULL) /* Tensor #9 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_5_Elu_output_0_output, AI_STATIC, 9, 0x0, AI_SHAPE_INIT(4, 1, 64, 1, 1), AI_STRIDE_INIT(4, 4, 4, 256, 256), 1, &_model_a2c_network_actor_mlp_5_Elu_output_0_output_array, NULL) /* Tensor #10 */ AI_TENSOR_OBJ_DECLARE( value_output, AI_STATIC, 10, 0x0, AI_SHAPE_INIT(4, 1, 1, 1, 1), AI_STRIDE_INIT(4, 4, 4, 4, 4), 1, &value_output_array, NULL) /* Tensor #11 */ AI_TENSOR_OBJ_DECLARE( mu_output, AI_STATIC, 11, 0x0, AI_SHAPE_INIT(4, 1, 12, 1, 1), AI_STRIDE_INIT(4, 4, 4, 48, 48), 1, &mu_output_array, NULL) /* Tensor #12 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_Mul_output_0_output, AI_STATIC, 12, 0x0, AI_SHAPE_INIT(4, 1, 12, 1, 1), AI_STRIDE_INIT(4, 4, 4, 48, 48), 1, &_model_a2c_network_Mul_output_0_output_array, NULL) /* Tensor #13 */ AI_TENSOR_OBJ_DECLARE( log_std_output, AI_STATIC, 13, 0x0, AI_SHAPE_INIT(4, 1, 12, 1, 1), AI_STRIDE_INIT(4, 4, 4, 48, 48), 1, &log_std_output_array, NULL) /* Tensor #14 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_Constant_output_0, AI_STATIC, 14, 0x0, AI_SHAPE_INIT(4, 1, 1, 1, 1), AI_STRIDE_INIT(4, 4, 4, 4, 4), 1, &_model_a2c_network_Constant_output_0_array, NULL) /* Tensor #15 */ AI_TENSOR_OBJ_DECLARE( onnxDiv_41, AI_STATIC, 15, 0x0, AI_SHAPE_INIT(4, 1, 48, 1, 1), AI_STRIDE_INIT(4, 4, 4, 192, 192), 1, &onnxDiv_41_array, NULL) /* Tensor #16 */ AI_TENSOR_OBJ_DECLARE( onnxSub_38, AI_STATIC, 16, 0x0, AI_SHAPE_INIT(4, 1, 48, 1, 1), AI_STRIDE_INIT(4, 4, 4, 192, 192), 1, &onnxSub_38_array, NULL) /* Tensor #17 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_weights, AI_STATIC, 17, 0x0, AI_SHAPE_INIT(4, 48, 256, 1, 1), AI_STRIDE_INIT(4, 1, 48, 12288, 12288), 1, &_model_a2c_network_actor_mlp_0_Gemm_output_0_weights_array, NULL) /* Tensor #18 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_bias, AI_STATIC, 18, 0x0, AI_SHAPE_INIT(4, 1, 256, 1, 1), AI_STRIDE_INIT(4, 4, 4, 1024, 1024), 1, &_model_a2c_network_actor_mlp_0_Gemm_output_0_bias_array, NULL) /* Tensor #19 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_weights, AI_STATIC, 19, 0x0, AI_SHAPE_INIT(4, 256, 128, 1, 1), AI_STRIDE_INIT(4, 1, 256, 32768, 32768), 1, &_model_a2c_network_actor_mlp_2_Gemm_output_0_weights_array, NULL) /* Tensor #20 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_bias, AI_STATIC, 20, 0x0, AI_SHAPE_INIT(4, 1, 128, 1, 1), AI_STRIDE_INIT(4, 4, 4, 512, 512), 1, &_model_a2c_network_actor_mlp_2_Gemm_output_0_bias_array, NULL) /* Tensor #21 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_weights, AI_STATIC, 21, 0x0, AI_SHAPE_INIT(4, 128, 64, 1, 1), AI_STRIDE_INIT(4, 1, 128, 8192, 8192), 1, &_model_a2c_network_actor_mlp_4_Gemm_output_0_weights_array, NULL) /* Tensor #22 */ AI_TENSOR_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_bias, AI_STATIC, 22, 0x0, AI_SHAPE_INIT(4, 1, 64, 1, 1), AI_STRIDE_INIT(4, 4, 4, 256, 256), 1, &_model_a2c_network_actor_mlp_4_Gemm_output_0_bias_array, NULL) /* Tensor #23 */ AI_TENSOR_OBJ_DECLARE( value_weights, AI_STATIC, 23, 0x0, AI_SHAPE_INIT(4, 64, 1, 1, 1), AI_STRIDE_INIT(4, 4, 256, 256, 256), 1, &value_weights_array, NULL) /* Tensor #24 */ AI_TENSOR_OBJ_DECLARE( value_bias, AI_STATIC, 24, 0x0, AI_SHAPE_INIT(4, 1, 1, 1, 1), AI_STRIDE_INIT(4, 4, 4, 4, 4), 1, &value_bias_array, NULL) /* Tensor #25 */ AI_TENSOR_OBJ_DECLARE( mu_weights, AI_STATIC, 25, 0x0, AI_SHAPE_INIT(4, 64, 12, 1, 1), AI_STRIDE_INIT(4, 4, 256, 3072, 3072), 1, &mu_weights_array, NULL) /* Tensor #26 */ AI_TENSOR_OBJ_DECLARE( mu_bias, AI_STATIC, 26, 0x0, AI_SHAPE_INIT(4, 1, 12, 1, 1), AI_STRIDE_INIT(4, 4, 4, 48, 48), 1, &mu_bias_array, NULL) /* Tensor #27 */ AI_TENSOR_OBJ_DECLARE( log_std_scale, AI_STATIC, 27, 0x0, AI_SHAPE_INIT(4, 1, 12, 1, 1), AI_STRIDE_INIT(4, 4, 4, 48, 48), 1, &log_std_scale_array, NULL) /* Tensor #28 */ AI_TENSOR_OBJ_DECLARE( log_std_bias, AI_STATIC, 28, 0x0, AI_SHAPE_INIT(4, 1, 12, 1, 1), AI_STRIDE_INIT(4, 4, 4, 48, 48), 1, &log_std_bias_array, NULL) /** Layer declarations section **********************************************/ AI_TENSOR_CHAIN_OBJ_DECLARE( log_std_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_Mul_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &log_std_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &log_std_scale, &log_std_bias), AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( log_std_layer, 17, BN_TYPE, 0x0, NULL, bn, forward_bn, &log_std_chain, NULL, &log_std_layer, AI_STATIC, ) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_Mul_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &mu_output, &_model_a2c_network_Constant_output_0), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_Mul_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_Mul_output_0_layer, 16, ELTWISE_TYPE, 0x0, NULL, eltwise, forward_eltwise, &_model_a2c_network_Mul_output_0_chain, NULL, &log_std_layer, AI_STATIC, .operation = ai_mul_f32, .buffer_operation = ai_mul_buffer_f32, ) AI_TENSOR_CHAIN_OBJ_DECLARE( mu_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_5_Elu_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &mu_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &mu_weights, &mu_bias), AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( mu_layer, 14, DENSE_TYPE, 0x0, NULL, dense, forward_dense, &mu_chain, NULL, &_model_a2c_network_Mul_output_0_layer, AI_STATIC, ) AI_TENSOR_CHAIN_OBJ_DECLARE( value_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_5_Elu_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &value_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &value_weights, &value_bias), AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( value_layer, 13, DENSE_TYPE, 0x0, NULL, dense, forward_dense, &value_chain, NULL, &mu_layer, AI_STATIC, ) AI_STATIC_CONST ai_float _model_a2c_network_actor_mlp_5_Elu_output_0_nl_params_data[] = { 1.0 }; AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_5_Elu_output_0_nl_params, AI_ARRAY_FORMAT_FLOAT, _model_a2c_network_actor_mlp_5_Elu_output_0_nl_params_data, _model_a2c_network_actor_mlp_5_Elu_output_0_nl_params_data, 1, AI_STATIC_CONST) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_actor_mlp_5_Elu_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_4_Gemm_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_5_Elu_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_actor_mlp_5_Elu_output_0_layer, 12, NL_TYPE, 0x0, NULL, nl, forward_elu, &_model_a2c_network_actor_mlp_5_Elu_output_0_chain, NULL, &value_layer, AI_STATIC, .nl_params = &_model_a2c_network_actor_mlp_5_Elu_output_0_nl_params, ) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_3_Elu_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_4_Gemm_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &_model_a2c_network_actor_mlp_4_Gemm_output_0_weights, &_model_a2c_network_actor_mlp_4_Gemm_output_0_bias), AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_actor_mlp_4_Gemm_output_0_layer, 11, DENSE_TYPE, 0x0, NULL, dense, forward_dense, &_model_a2c_network_actor_mlp_4_Gemm_output_0_chain, NULL, &_model_a2c_network_actor_mlp_5_Elu_output_0_layer, AI_STATIC, ) AI_STATIC_CONST ai_float _model_a2c_network_actor_mlp_3_Elu_output_0_nl_params_data[] = { 1.0 }; AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_3_Elu_output_0_nl_params, AI_ARRAY_FORMAT_FLOAT, _model_a2c_network_actor_mlp_3_Elu_output_0_nl_params_data, _model_a2c_network_actor_mlp_3_Elu_output_0_nl_params_data, 1, AI_STATIC_CONST) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_actor_mlp_3_Elu_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_2_Gemm_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_3_Elu_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_actor_mlp_3_Elu_output_0_layer, 10, NL_TYPE, 0x0, NULL, nl, forward_elu, &_model_a2c_network_actor_mlp_3_Elu_output_0_chain, NULL, &_model_a2c_network_actor_mlp_4_Gemm_output_0_layer, AI_STATIC, .nl_params = &_model_a2c_network_actor_mlp_3_Elu_output_0_nl_params, ) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_1_Elu_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_2_Gemm_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &_model_a2c_network_actor_mlp_2_Gemm_output_0_weights, &_model_a2c_network_actor_mlp_2_Gemm_output_0_bias), AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_actor_mlp_2_Gemm_output_0_layer, 9, DENSE_TYPE, 0x0, NULL, dense, forward_dense, &_model_a2c_network_actor_mlp_2_Gemm_output_0_chain, NULL, &_model_a2c_network_actor_mlp_3_Elu_output_0_layer, AI_STATIC, ) AI_STATIC_CONST ai_float _model_a2c_network_actor_mlp_1_Elu_output_0_nl_params_data[] = { 1.0 }; AI_ARRAY_OBJ_DECLARE( _model_a2c_network_actor_mlp_1_Elu_output_0_nl_params, AI_ARRAY_FORMAT_FLOAT, _model_a2c_network_actor_mlp_1_Elu_output_0_nl_params_data, _model_a2c_network_actor_mlp_1_Elu_output_0_nl_params_data, 1, AI_STATIC_CONST) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_actor_mlp_1_Elu_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_0_Gemm_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_1_Elu_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_actor_mlp_1_Elu_output_0_layer, 8, NL_TYPE, 0x0, NULL, nl, forward_elu, &_model_a2c_network_actor_mlp_1_Elu_output_0_chain, NULL, &_model_a2c_network_actor_mlp_2_Gemm_output_0_layer, AI_STATIC, .nl_params = &_model_a2c_network_actor_mlp_1_Elu_output_0_nl_params, ) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_running_mean_std_Clip_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_a2c_network_actor_mlp_0_Gemm_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &_model_a2c_network_actor_mlp_0_Gemm_output_0_weights, &_model_a2c_network_actor_mlp_0_Gemm_output_0_bias), AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_a2c_network_actor_mlp_0_Gemm_output_0_layer, 7, DENSE_TYPE, 0x0, NULL, dense, forward_dense, &_model_a2c_network_actor_mlp_0_Gemm_output_0_chain, NULL, &_model_a2c_network_actor_mlp_1_Elu_output_0_layer, AI_STATIC, ) AI_STATIC_CONST ai_float _model_running_mean_std_Clip_output_0_nl_params_data[] = { -5.0, 5.0 }; AI_ARRAY_OBJ_DECLARE( _model_running_mean_std_Clip_output_0_nl_params, AI_ARRAY_FORMAT_FLOAT, _model_running_mean_std_Clip_output_0_nl_params_data, _model_running_mean_std_Clip_output_0_nl_params_data, 2, AI_STATIC_CONST) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_running_mean_std_Clip_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_running_mean_std_Div_output_0_output), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_running_mean_std_Clip_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_running_mean_std_Clip_output_0_layer, 5, NL_TYPE, 0x0, NULL, nl, forward_clip, &_model_running_mean_std_Clip_output_0_chain, NULL, &_model_a2c_network_actor_mlp_0_Gemm_output_0_layer, AI_STATIC, .nl_params = &_model_running_mean_std_Clip_output_0_nl_params, ) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_running_mean_std_Div_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &_model_running_mean_std_Sub_output_0_output, &onnxDiv_41), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_running_mean_std_Div_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_running_mean_std_Div_output_0_layer, 2, ELTWISE_TYPE, 0x0, NULL, eltwise, forward_eltwise, &_model_running_mean_std_Div_output_0_chain, NULL, &_model_running_mean_std_Clip_output_0_layer, AI_STATIC, .operation = ai_div_f32, .buffer_operation = ai_div_buffer_f32, ) AI_TENSOR_CHAIN_OBJ_DECLARE( _model_running_mean_std_Sub_output_0_chain, AI_STATIC_CONST, 4, AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 2, &obs_output, &onnxSub_38), AI_TENSOR_LIST_OBJ_INIT(AI_FLAG_NONE, 1, &_model_running_mean_std_Sub_output_0_output), AI_TENSOR_LIST_OBJ_EMPTY, AI_TENSOR_LIST_OBJ_EMPTY ) AI_LAYER_OBJ_DECLARE( _model_running_mean_std_Sub_output_0_layer, 1, ELTWISE_TYPE, 0x0, NULL, eltwise, forward_eltwise, &_model_running_mean_std_Sub_output_0_chain, NULL, &_model_running_mean_std_Div_output_0_layer, AI_STATIC, .operation = ai_sub_f32, .buffer_operation = ai_sub_buffer_f32, ) #if (AI_TOOLS_API_VERSION < AI_TOOLS_API_VERSION_1_5) AI_NETWORK_OBJ_DECLARE( AI_NET_OBJ_INSTANCE, AI_STATIC, AI_BUFFER_INIT(AI_FLAG_NONE, AI_BUFFER_FORMAT_U8, AI_BUFFER_SHAPE_INIT(AI_SHAPE_BCWH, 4, 1, 61976, 1, 1), 61976, NULL, NULL), AI_BUFFER_INIT(AI_FLAG_NONE, AI_BUFFER_FORMAT_U8, AI_BUFFER_SHAPE_INIT(AI_SHAPE_BCWH, 4, 1, 1536, 1, 1), 1536, NULL, NULL), AI_TENSOR_LIST_IO_OBJ_INIT(AI_FLAG_NONE, AI_NETWORK_IN_NUM, &obs_output), AI_TENSOR_LIST_IO_OBJ_INIT(AI_FLAG_NONE, AI_NETWORK_OUT_NUM, &mu_output, &log_std_output, &value_output), &_model_running_mean_std_Sub_output_0_layer, 0, NULL) #else AI_NETWORK_OBJ_DECLARE( AI_NET_OBJ_INSTANCE, AI_STATIC, AI_BUFFER_ARRAY_OBJ_INIT_STATIC( AI_FLAG_NONE, 1, AI_BUFFER_INIT(AI_FLAG_NONE, AI_BUFFER_FORMAT_U8, AI_BUFFER_SHAPE_INIT(AI_SHAPE_BCWH, 4, 1, 61976, 1, 1), 61976, NULL, NULL) ), AI_BUFFER_ARRAY_OBJ_INIT_STATIC( AI_FLAG_NONE, 1, AI_BUFFER_INIT(AI_FLAG_NONE, AI_BUFFER_FORMAT_U8, AI_BUFFER_SHAPE_INIT(AI_SHAPE_BCWH, 4, 1, 1536, 1, 1), 1536, NULL, NULL) ), AI_TENSOR_LIST_IO_OBJ_INIT(AI_FLAG_NONE, AI_NETWORK_IN_NUM, &obs_output), AI_TENSOR_LIST_IO_OBJ_INIT(AI_FLAG_NONE, AI_NETWORK_OUT_NUM, &mu_output, &log_std_output, &value_output), &_model_running_mean_std_Sub_output_0_layer, 0, NULL) #endif /*(AI_TOOLS_API_VERSION < AI_TOOLS_API_VERSION_1_5)*/ /******************************************************************************/ AI_DECLARE_STATIC ai_bool network_configure_activations( ai_network* net_ctx, const ai_network_params* params) { AI_ASSERT(net_ctx) if (ai_platform_get_activations_map(g_network_activations_map, 1, params)) { /* Updating activations (byte) offsets */ obs_output_array.data = AI_PTR(g_network_activations_map[0] + 320); obs_output_array.data_start = AI_PTR(g_network_activations_map[0] + 320); _model_running_mean_std_Sub_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 320); _model_running_mean_std_Sub_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 320); _model_running_mean_std_Div_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 320); _model_running_mean_std_Div_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 320); _model_running_mean_std_Clip_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 320); _model_running_mean_std_Clip_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 320); _model_a2c_network_actor_mlp_0_Gemm_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 512); _model_a2c_network_actor_mlp_0_Gemm_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 512); _model_a2c_network_actor_mlp_1_Elu_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 512); _model_a2c_network_actor_mlp_1_Elu_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 512); _model_a2c_network_actor_mlp_2_Gemm_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 0); _model_a2c_network_actor_mlp_2_Gemm_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 0); _model_a2c_network_actor_mlp_3_Elu_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 512); _model_a2c_network_actor_mlp_3_Elu_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 512); _model_a2c_network_actor_mlp_4_Gemm_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 0); _model_a2c_network_actor_mlp_4_Gemm_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 0); _model_a2c_network_actor_mlp_5_Elu_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 256); _model_a2c_network_actor_mlp_5_Elu_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 256); value_output_array.data = AI_PTR(g_network_activations_map[0] + 0); value_output_array.data_start = AI_PTR(g_network_activations_map[0] + 0); mu_output_array.data = AI_PTR(g_network_activations_map[0] + 4); mu_output_array.data_start = AI_PTR(g_network_activations_map[0] + 4); _model_a2c_network_Mul_output_0_output_array.data = AI_PTR(g_network_activations_map[0] + 52); _model_a2c_network_Mul_output_0_output_array.data_start = AI_PTR(g_network_activations_map[0] + 52); log_std_output_array.data = AI_PTR(g_network_activations_map[0] + 100); log_std_output_array.data_start = AI_PTR(g_network_activations_map[0] + 100); return true; } AI_ERROR_TRAP(net_ctx, INIT_FAILED, NETWORK_ACTIVATIONS); return false; } /******************************************************************************/ AI_DECLARE_STATIC ai_bool network_configure_weights( ai_network* net_ctx, const ai_network_params* params) { AI_ASSERT(net_ctx) if (ai_platform_get_weights_map(g_network_weights_map, 1, params)) { /* Updating weights (byte) offsets */ _model_a2c_network_Constant_output_0_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_Constant_output_0_array.data = AI_PTR(g_network_weights_map[0] + 0); _model_a2c_network_Constant_output_0_array.data_start = AI_PTR(g_network_weights_map[0] + 0); onnxDiv_41_array.format |= AI_FMT_FLAG_CONST; onnxDiv_41_array.data = AI_PTR(g_network_weights_map[0] + 4); onnxDiv_41_array.data_start = AI_PTR(g_network_weights_map[0] + 4); onnxSub_38_array.format |= AI_FMT_FLAG_CONST; onnxSub_38_array.data = AI_PTR(g_network_weights_map[0] + 196); onnxSub_38_array.data_start = AI_PTR(g_network_weights_map[0] + 196); _model_a2c_network_actor_mlp_0_Gemm_output_0_weights_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_actor_mlp_0_Gemm_output_0_weights_array.data = AI_PTR(g_network_weights_map[0] + 1412); _model_a2c_network_actor_mlp_0_Gemm_output_0_weights_array.data_start = AI_PTR(g_network_weights_map[0] + 388); _model_a2c_network_actor_mlp_0_Gemm_output_0_bias_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_actor_mlp_0_Gemm_output_0_bias_array.data = AI_PTR(g_network_weights_map[0] + 13700); _model_a2c_network_actor_mlp_0_Gemm_output_0_bias_array.data_start = AI_PTR(g_network_weights_map[0] + 13700); _model_a2c_network_actor_mlp_2_Gemm_output_0_weights_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_actor_mlp_2_Gemm_output_0_weights_array.data = AI_PTR(g_network_weights_map[0] + 15748); _model_a2c_network_actor_mlp_2_Gemm_output_0_weights_array.data_start = AI_PTR(g_network_weights_map[0] + 14724); _model_a2c_network_actor_mlp_2_Gemm_output_0_bias_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_actor_mlp_2_Gemm_output_0_bias_array.data = AI_PTR(g_network_weights_map[0] + 48516); _model_a2c_network_actor_mlp_2_Gemm_output_0_bias_array.data_start = AI_PTR(g_network_weights_map[0] + 48516); _model_a2c_network_actor_mlp_4_Gemm_output_0_weights_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_actor_mlp_4_Gemm_output_0_weights_array.data = AI_PTR(g_network_weights_map[0] + 50052); _model_a2c_network_actor_mlp_4_Gemm_output_0_weights_array.data_start = AI_PTR(g_network_weights_map[0] + 49028); _model_a2c_network_actor_mlp_4_Gemm_output_0_bias_array.format |= AI_FMT_FLAG_CONST; _model_a2c_network_actor_mlp_4_Gemm_output_0_bias_array.data = AI_PTR(g_network_weights_map[0] + 58244); _model_a2c_network_actor_mlp_4_Gemm_output_0_bias_array.data_start = AI_PTR(g_network_weights_map[0] + 58244); value_weights_array.format |= AI_FMT_FLAG_CONST; value_weights_array.data = AI_PTR(g_network_weights_map[0] + 58500); value_weights_array.data_start = AI_PTR(g_network_weights_map[0] + 58500); value_bias_array.format |= AI_FMT_FLAG_CONST; value_bias_array.data = AI_PTR(g_network_weights_map[0] + 58756); value_bias_array.data_start = AI_PTR(g_network_weights_map[0] + 58756); mu_weights_array.format |= AI_FMT_FLAG_CONST; mu_weights_array.data = AI_PTR(g_network_weights_map[0] + 58760); mu_weights_array.data_start = AI_PTR(g_network_weights_map[0] + 58760); mu_bias_array.format |= AI_FMT_FLAG_CONST; mu_bias_array.data = AI_PTR(g_network_weights_map[0] + 61832); mu_bias_array.data_start = AI_PTR(g_network_weights_map[0] + 61832); log_std_scale_array.format |= AI_FMT_FLAG_CONST; log_std_scale_array.data = AI_PTR(g_network_weights_map[0] + 61880); log_std_scale_array.data_start = AI_PTR(g_network_weights_map[0] + 61880); log_std_bias_array.format |= AI_FMT_FLAG_CONST; log_std_bias_array.data = AI_PTR(g_network_weights_map[0] + 61928); log_std_bias_array.data_start = AI_PTR(g_network_weights_map[0] + 61928); return true; } AI_ERROR_TRAP(net_ctx, INIT_FAILED, NETWORK_WEIGHTS); return false; } /** PUBLIC APIs SECTION *****************************************************/ AI_DEPRECATED AI_API_ENTRY ai_bool ai_network_get_info( ai_handle network, ai_network_report* report) { ai_network* net_ctx = AI_NETWORK_ACQUIRE_CTX(network); if (report && net_ctx) { ai_network_report r = { .model_name = AI_NETWORK_MODEL_NAME, .model_signature = AI_NETWORK_MODEL_SIGNATURE, .model_datetime = AI_TOOLS_DATE_TIME, .compile_datetime = AI_TOOLS_COMPILE_TIME, .runtime_revision = ai_platform_runtime_get_revision(), .runtime_version = ai_platform_runtime_get_version(), .tool_revision = AI_TOOLS_REVISION_ID, .tool_version = {AI_TOOLS_VERSION_MAJOR, AI_TOOLS_VERSION_MINOR, AI_TOOLS_VERSION_MICRO, 0x0}, .tool_api_version = AI_STRUCT_INIT, .api_version = ai_platform_api_get_version(), .interface_api_version = ai_platform_interface_api_get_version(), .n_macc = 59889, .n_inputs = 0, .inputs = NULL, .n_outputs = 0, .outputs = NULL, .params = AI_STRUCT_INIT, .activations = AI_STRUCT_INIT, .n_nodes = 0, .signature = 0x0, }; if (!ai_platform_api_get_network_report(network, &r)) return false; *report = r; return true; } return false; } AI_API_ENTRY ai_bool ai_network_get_report( ai_handle network, ai_network_report* report) { ai_network* net_ctx = AI_NETWORK_ACQUIRE_CTX(network); if (report && net_ctx) { ai_network_report r = { .model_name = AI_NETWORK_MODEL_NAME, .model_signature = AI_NETWORK_MODEL_SIGNATURE, .model_datetime = AI_TOOLS_DATE_TIME, .compile_datetime = AI_TOOLS_COMPILE_TIME, .runtime_revision = ai_platform_runtime_get_revision(), .runtime_version = ai_platform_runtime_get_version(), .tool_revision = AI_TOOLS_REVISION_ID, .tool_version = {AI_TOOLS_VERSION_MAJOR, AI_TOOLS_VERSION_MINOR, AI_TOOLS_VERSION_MICRO, 0x0}, .tool_api_version = AI_STRUCT_INIT, .api_version = ai_platform_api_get_version(), .interface_api_version = ai_platform_interface_api_get_version(), .n_macc = 59889, .n_inputs = 0, .inputs = NULL, .n_outputs = 0, .outputs = NULL, .map_signature = AI_MAGIC_SIGNATURE, .map_weights = AI_STRUCT_INIT, .map_activations = AI_STRUCT_INIT, .n_nodes = 0, .signature = 0x0, }; if (!ai_platform_api_get_network_report(network, &r)) return false; *report = r; return true; } return false; } AI_API_ENTRY ai_error ai_network_get_error(ai_handle network) { return ai_platform_network_get_error(network); } AI_API_ENTRY ai_error ai_network_create( ai_handle* network, const ai_buffer* network_config) { return ai_platform_network_create( network, network_config, &AI_NET_OBJ_INSTANCE, AI_TOOLS_API_VERSION_MAJOR, AI_TOOLS_API_VERSION_MINOR, AI_TOOLS_API_VERSION_MICRO); } AI_API_ENTRY ai_error ai_network_create_and_init( ai_handle* network, const ai_handle activations[], const ai_handle weights[]) { ai_error err; ai_network_params params; err = ai_network_create(network, AI_NETWORK_DATA_CONFIG); if (err.type != AI_ERROR_NONE) return err; if (ai_network_data_params_get(&params) != true) { err = ai_network_get_error(*network); return err; } #if defined(AI_NETWORK_DATA_ACTIVATIONS_COUNT) if (activations) { /* set the addresses of the activations buffers */ for (int idx=0;idx<params.map_activations.size;idx++) AI_BUFFER_ARRAY_ITEM_SET_ADDRESS(&params.map_activations, idx, activations[idx]); } #endif #if defined(AI_NETWORK_DATA_WEIGHTS_COUNT) if (weights) { /* set the addresses of the weight buffers */ for (int idx=0;idx<params.map_weights.size;idx++) AI_BUFFER_ARRAY_ITEM_SET_ADDRESS(&params.map_weights, idx, weights[idx]); } #endif if (ai_network_init(*network, &params) != true) { err = ai_network_get_error(*network); } return err; } AI_API_ENTRY ai_buffer* ai_network_inputs_get(ai_handle network, ai_u16 *n_buffer) { if (network == AI_HANDLE_NULL) { network = (ai_handle)&AI_NET_OBJ_INSTANCE; ((ai_network *)network)->magic = AI_MAGIC_CONTEXT_TOKEN; } return ai_platform_inputs_get(network, n_buffer); } AI_API_ENTRY ai_buffer* ai_network_outputs_get(ai_handle network, ai_u16 *n_buffer) { if (network == AI_HANDLE_NULL) { network = (ai_handle)&AI_NET_OBJ_INSTANCE; ((ai_network *)network)->magic = AI_MAGIC_CONTEXT_TOKEN; } return ai_platform_outputs_get(network, n_buffer); } AI_API_ENTRY ai_handle ai_network_destroy(ai_handle network) { return ai_platform_network_destroy(network); } AI_API_ENTRY ai_bool ai_network_init( ai_handle network, const ai_network_params* params) { ai_network* net_ctx = ai_platform_network_init(network, params); if (!net_ctx) return false; ai_bool ok = true; ok &= network_configure_weights(net_ctx, params); ok &= network_configure_activations(net_ctx, params); ok &= ai_platform_network_post_init(network); return ok; } AI_API_ENTRY ai_i32 ai_network_run( ai_handle network, const ai_buffer* input, ai_buffer* output) { return ai_platform_network_process(network, input, output); } AI_API_ENTRY ai_i32 ai_network_forward(ai_handle network, const ai_buffer* input) { return ai_platform_network_process(network, input, NULL); } #undef AI_NETWORK_MODEL_SIGNATURE #undef AI_NET_OBJ_INSTANCE #undef AI_TOOLS_DATE_TIME #undef AI_TOOLS_COMPILE_TIME
36,457
C
35.240557
150
0.663384
teerameth/omni.isaac.fiborobotlab/config/extension.toml
[core] reloadable = true order = 0 [package] version = "0.1.1" category = "Simulation" title = "Isaac Sim fiborobotlab" description = "fiborobotlab package for Isaac Sim" authors = ["NVIDIA"] repository = "" keywords = ["isaac", "urdf", "import"] changelog = "docs/CHANGELOG.md" readme = "docs/README.md" preview_image = "data/preview.png" icon = "data/icon.png" writeTarget.kit = true [dependencies] "omni.isaac.urdf" = {} [[python.module]] name = "omni.isaac.fiborobotlab" #[[python.module]] #name = "omni.isaac.fiborobotlab.mooncake" [[python.module]] name = "omni.isaac.fiborobotlab.mooncake.scripts.import_mooncake" [[python.module]] name = "omni.isaac.fiborobotlab.obike.scripts.import_obike" [[python.module]] name = "omni.isaac.fiborobotlab.taufinder.scripts.import_taufinder" [[python.module]] name = "omni.isaac.fiborobotlab.hello_world_extension" [[python.module]] name = "omni.isaac.fiborobotlab.hello_world" [[python.module]] name = "omni.isaac.fiborobotlab.hanuman.scripts.import_hanuman" [[native.plugin]] path = "bin/*.plugin" recursive = false [[test]] # this is to catch issues where our assimp is out of sync with the one that comes with # asset importer as this can cause segfaults due to binary incompatibility. dependencies = ["omni.kit.tool.asset_importer"]
1,297
TOML
22.6
87
0.730918
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/cartpole/cartpole_example.py
#!/usr/bin/env -S HOME=${HOME} ${HOME}/.local/share/ov/pkg/isaac_sim-2022.1.0/python.sh from omni.isaac.gym.vec_env import VecEnvBase env = VecEnvBase(headless=False) from cartpole_task import CartpoleTask task = CartpoleTask(name="Cartpole") env.set_task(task, backend="torch") from stable_baselines3 import PPO # create agent from stable baselines model = PPO( "MlpPolicy", env, n_steps=1000, batch_size=1000, n_epochs=20, learning_rate=0.001, gamma=0.99, device="cuda:0", ent_coef=0.0, vf_coef=0.5, max_grad_norm=1.0, verbose=1, tensorboard_log="./cartpole_tensorboard" ) model.learn(total_timesteps=100000) model.save("ppo_cartpole") env.close()
757
Python
24.266666
87
0.642008
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_ppo.py
from env import MoonCakeEnv import gym from stable_baselines3 import PPO from stable_baselines3.common.env_util import make_vec_env my_env = MoonCakeEnv(headless=False) # Parallel environments # env = make_vec_env("CartPole-v1", n_envs=4) model = PPO("MlpPolicy", my_env, verbose=1) model.learn(total_timesteps=25000) model.save("ppo_cartpole") # # del model # remove to demonstrate saving and loading # # model = PPO.load("ppo_cartpole") # # obs = env.reset() # while True: # action, _states = model.predict(obs) # obs, rewards, dones, info = env.step(action) # env.render()
589
Python
25.818181
58
0.716469
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_karn.py
from env_karn import MoonCakeEnv from stable_baselines3 import PPO from stable_baselines3.ppo import CnnPolicy, MlpPolicy from stable_baselines3.common.callbacks import CheckpointCallback import torch as th log_dir = "./mlp_policy" # set headles to false to visualize training my_env = MoonCakeEnv(headless=False) policy_kwargs = dict(activation_fn=th.nn.Tanh, net_arch=[16, dict(pi=[64, 32], vf=[64, 32])]) total_timesteps = 500000 checkpoint_callback = CheckpointCallback(save_freq=10000, save_path=log_dir, name_prefix="mooncake_policy_checkpoint") # model = PPO( # CnnPolicy, # my_env, # policy_kwargs=policy_kwargs, # verbose=1, # n_steps=10000, # batch_size=1000, # learning_rate=0.00025, # gamma=0.9995, # device="cuda", # ent_coef=0, # vf_coef=0.5, # max_grad_norm=10, # tensorboard_log=log_dir, # ) model = PPO(MlpPolicy, my_env, verbose=1, n_steps=10000, batch_size=100, learning_rate=0.00025, ) model.learn(total_timesteps=total_timesteps, callback=[checkpoint_callback]) model.save(log_dir + "/mooncake_policy") my_env.close()
1,169
Python
26.209302
118
0.66296
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/mooncake_task_2.py
from omniisaacgymenvs.tasks.base.rl_task import RLTask from mooncake import Mooncake import omni from pxr import UsdPhysics, Gf, UsdGeom from omni.isaac.core.articulations import ArticulationView from omni.isaac.core.prims import RigidPrimView from omni.isaac.core.utils.prims import get_prim_at_path import omni.isaac.core.utils.torch.rotations as torch_rot from omni.isaac.isaac_sensor import _isaac_sensor from omni.isaac.core.utils.torch.maths import torch_rand_float, tensor_clamp, unscale import numpy as np import torch import torch.nn.functional as f import math def q2falling(q): norm_vec = f.normalize(q[:, 1:], p=1, dim=1) return 2 * torch.acos(q[:, 0]) * torch.sqrt((norm_vec[:, 0] * norm_vec[:, 0] + norm_vec[:, 1] * norm_vec[:, 1])) class MooncakeTask(RLTask): def __init__( self, name, sim_config, env, offset=None ) -> None: self._sim_config = sim_config self._cfg = sim_config.config self._task_cfg = sim_config.task_config self._num_envs = self._task_cfg["env"]["numEnvs"] self._env_spacing = self._task_cfg["env"]["envSpacing"] self._ball_size = 0.12 self._ball_positions = torch.tensor([0.0, 0.0, 0.12]) # ball diameter is 12 cm. self._robot_offset = 0.1962 self._jump_offset = 0.01 self._reset_dist = self._task_cfg["env"]["resetDist"] self._max_push_effort = self._task_cfg["env"]["maxEffort"] self._max_wheel_velocity = self._task_cfg["env"]["maxWheelVelocity"] self.heading_weight = self._task_cfg["env"]["headingWeight"] self.up_weight = self._task_cfg["env"]["upWeight"] self.actions_cost_scale = self._task_cfg["env"]["actionsCost"] self.energy_cost_scale = self._task_cfg["env"]["energyCost"] self.joints_at_limit_cost_scale = self._task_cfg["env"]["jointsAtLimitCost"] self.death_cost = self._task_cfg["env"]["deathCost"] self.termination_height = self._task_cfg["env"]["terminationHeight"] self.alive_reward_scale = self._task_cfg["env"]["alive_reward_scale"] self._max_episode_length = 5000 self._num_observations = 22 self._num_actions = 3 self._imu_buf = [{"lin_acc_x": 0.0, "lin_acc_y": 0.0, "lin_acc_z": 0.0, "ang_vel_x": 0.0, "ang_vel_y": 0.0, "ang_vel_z": 0.0}] * 128 # default initial sensor buffer self._is = _isaac_sensor.acquire_imu_sensor_interface() # Sensor reader self.previous_fall_angle = None RLTask.__init__(self, name, env) return def set_up_scene(self, scene) -> None: self.get_mooncake() # mush be called before "super().set_up_scene(scene)" # self.get_ball() super().set_up_scene(scene) self._robots = ArticulationView(prim_paths_expr="/World/envs/*/Mooncake/mooncake", name="mooncake_view") # Add ball for each robot stage = omni.usd.get_context().get_stage() for robot_path in self._robots.prim_paths: ball_path = robot_path[:-18] + "/ball" # remove "/Mooncake/mooncake" and add "/ball" instead cubeGeom = UsdGeom.Sphere.Define(stage, ball_path) ballPrim = stage.GetPrimAtPath(ball_path) size = self._ball_size offset = Gf.Vec3f(0.0, 0.0, self._ball_size) cubeGeom.CreateRadiusAttr(size) cubeGeom.AddTranslateOp().Set(offset) # Attach Rigid Body and Collision Preset rigid_api = UsdPhysics.RigidBodyAPI.Apply(ballPrim) mass_api = UsdPhysics.MassAPI.Apply(ballPrim) mass_api.CreateMassAttr(4) rigid_api.CreateRigidBodyEnabledAttr(True) UsdPhysics.CollisionAPI.Apply(ballPrim) phys_api = UsdPhysics.MaterialAPI.Apply(ballPrim) phys_api.CreateStaticFrictionAttr().Set(1.0) phys_api.CreateDynamicFrictionAttr().Set(1.0) self._ball = RigidPrimView(prim_paths_expr="/World/envs/*/ball", name="ball_view") scene.add(self._robots) scene.add(self._ball) # self.meters_per_unit = UsdGeom.GetStageMetersPerUnit(omni.usd.get_context().get_stage()) return def get_mooncake(self): # must be called at very first line of set_up_scene() robot_position = self._ball_positions robot_position[2] += self._robot_offset mooncake = Mooncake(prim_path=self.default_zero_env_path + "/Mooncake", name="Mooncake", translation=robot_position) # applies articulation settings from the task configuration yaml file self._sim_config.apply_articulation_settings("Mooncake", get_prim_at_path(mooncake.prim_path), self._sim_config.parse_actor_config("Mooncake")) def get_ball(self): from omni.isaac.core.objects import DynamicSphere ball = self._my_world.scene.add( DynamicSphere( prim_path=self.default_zero_env_path + "/Ball", name="ball", position=self._ball_positions, radius=12, # mediciene ball diameter 24cm. color=np.array([1.0, 0, 0]), mass=4, ) ) # ball = Ball(prim_path=self.default_zero_env_path + "/Ball", name="Ball", translation=self._ball_positions) def get_robot(self): return self._robots def get_observations(self) -> dict: # dof_pos = self._robots.get_joint_positions(clone=False) dof_vel = self._robots.get_joint_velocities(clone=False) wheel_vel_0 = dof_vel[:, self._wheel_0_dof_idx] wheel_vel_1 = dof_vel[:, self._wheel_1_dof_idx] wheel_vel_2 = dof_vel[:, self._wheel_2_dof_idx] imu_accel_x = torch.tensor([imu["lin_acc_x"] for imu in self._imu_buf]) imu_accel_y = torch.tensor([imu["lin_acc_y"] for imu in self._imu_buf]) imu_accel_z = torch.tensor([imu["lin_acc_z"] for imu in self._imu_buf]) imu_gyro_x = torch.tensor([imu["ang_vel_x"] for imu in self._imu_buf]) imu_gyro_y = torch.tensor([imu["ang_vel_y"] for imu in self._imu_buf]) imu_gyro_z = torch.tensor([imu["ang_vel_z"] for imu in self._imu_buf]) self.obs_buf[:, 0] = wheel_vel_0 self.obs_buf[:, 1] = wheel_vel_1 self.obs_buf[:, 2] = wheel_vel_2 self.obs_buf[:, 3] = imu_accel_x self.obs_buf[:, 4] = imu_accel_y self.obs_buf[:, 5] = imu_accel_z self.obs_buf[:, 6] = imu_gyro_x self.obs_buf[:, 7] = imu_gyro_y self.obs_buf[:, 8] = imu_gyro_z robot_v = self._robots.get_linear_velocities() ball_v = self._robots.get_linear_velocities() robot_w = self._robots.get_angular_velocities() _, robot_orientation = self._robots.get_world_poses() self.obs_buf[:, 9] = robot_v[:, 0] self.obs_buf[:, 10] = robot_v[:, 1] self.obs_buf[:, 11] = robot_v[:, 2] self.obs_buf[:, 12] = ball_v[:, 0] self.obs_buf[:, 13] = ball_v[:, 1] self.obs_buf[:, 14] = ball_v[:, 2] self.obs_buf[:, 15] = robot_w[:, 0] self.obs_buf[:, 16] = robot_w[:, 1] self.obs_buf[:, 17] = robot_w[:, 2] self.obs_buf[:, 18] = robot_orientation[:, 0] self.obs_buf[:, 19] = robot_orientation[:, 1] self.obs_buf[:, 20] = robot_orientation[:, 2] self.obs_buf[:, 21] = robot_orientation[:, 3] observations = { self._robots.name: { "obs_buf": self.obs_buf } } # print("observations: %s"%(str(observations))) return observations def pre_physics_step(self, actions) -> None: # print("Action: %s"%(str(actions))) torch.nan_to_num(actions, nan=0.0) # replace NaN with zero reset_env_ids = self.reset_buf.nonzero(as_tuple=False).squeeze(-1) if len(reset_env_ids) > 0: self.reset_idx(reset_env_ids) self.actions = actions.clone().to(self._device) # save for later energy calculation # actions[:, 0] = actions[:, 0] * self._max_wheel_velocity # actions[:, 1] = actions[:, 1] * self._max_wheel_velocity # actions[:, 2] = actions[:, 2] * 0.5 # omega_bz ## calculate wheel_velocities from wheel's kinematics # actions = actions.to(self._device) * self._max_wheel_velocity # wheel_velocities = torch.zeros((self._robots.count, 3), dtype=torch.float32, device=self._device) # wheel_velocities[:, 0] = -12.8558 * actions[:, 1] - 11.0172 * actions[:, 2] # wheel_velocities[:, 1] = 11.1334 * actions[:, 0] + 6.4279 * actions[:, 1] + 8.2664 * actions[:, 2] # wheel_velocities[:, 2] = 6.4279 * actions[:, 1] - 11.1334 * actions[:, 0] + 8.2664 * actions[:, 2] wheel_velocities = torch.zeros((self._robots.count, self._robots.num_dof), dtype=torch.float32, device=self._device) wheel_velocities[:, self._wheel_0_dof_idx] = -12.8558 * actions[:, 1] - 11.0172 * actions[:, 2] wheel_velocities[:, self._wheel_1_dof_idx] = 11.1334 * actions[:, 0] + 6.4279 * actions[:, 1] + 8.2664 * actions[:, 2] wheel_velocities[:, self._wheel_2_dof_idx] = 6.4279 * actions[:, 1] - 11.1334 * actions[:, 0] + 8.2664 * actions[:, 2] # print("wheel_velocities: %s" % (str(wheel_velocities))) self.wheel_velocities = wheel_velocities.clone().to(self._device) # save for later energy calculation # wheel_effort = torch.zeros((self._robots.count, self._robots.num_dof), dtype=torch.float32, device=self._device) # wheel_effort[:, self._wheel_0_dof_idx] = actions[:, 0] * self._max_push_effort # wheel_effort[:, self._wheel_1_dof_idx] = actions[:, 1] * self._max_push_effort # wheel_effort[:, self._wheel_2_dof_idx] = actions[:, 2] * self._max_push_effort # print("wheel_effort: %s" % (str(wheel_effort))) ## Apply joint velocities from omni.isaac.core.utils.types import ArticulationActions # batched version of ArticulationAction stage = omni.usd.get_context().get_stage() for env in range(self._num_envs): axle_0 = UsdPhysics.DriveAPI.Get( stage.GetPrimAtPath("/World/envs/env_{}/Mooncake/mooncake/base_plate/wheel_0_joint".format(env)), "angular") axle_1 = UsdPhysics.DriveAPI.Get( stage.GetPrimAtPath("/World/envs/env_{}/Mooncake/mooncake/base_plate/wheel_1_joint".format(env)), "angular") axle_2 = UsdPhysics.DriveAPI.Get( stage.GetPrimAtPath("/World/envs/env_{}/Mooncake/mooncake/base_plate/wheel_2_joint".format(env)), "angular") # set_drive_parameters(axle_0, "velocity", math.degrees(wheel_velocities[env, 0]), 0.05, math.radians(1e7)) # set_drive_parameters(axle_1, "velocity", math.degrees(wheel_velocities[env, 1]), 0.05, math.radians(1e7)) # set_drive_parameters(axle_2, "velocity", math.degrees(wheel_velocities[env, 2]), 0.05, math.radians(1e7)) # self._robots.apply_action(ArticulationActions(joint_efforts=wheel_effort)) self._robots.apply_action(ArticulationActions(joint_velocities=wheel_velocities)) # self._robots[env].apply_wheel_actions(ArticulationAction(joint_efforts=wheel_effort[env])) # set_drive_parameters(axle_0, "effort", wheel_effort[env, 0], 0, math.radians(1e7)) # set_drive_parameters(axle_1, "effort", wheel_effort[env, 1], 0, math.radians(1e7)) # set_drive_parameters(axle_2, "effort", wheel_effort[env, 2], 0, math.radians(1e7)) ## Read IMU & store in buffer ## buffer = [] robots_prim_path = self._robots.prim_paths for robot_prim_path in robots_prim_path: reading = self._is.get_sensor_readings( robot_prim_path + "/base_plate/sensor") # read from select sensor (by prim_path) if reading.shape[0]: buffer.append(reading[-1]) # get only lastest reading else: buffer.append({"lin_acc_x": 0.0, "lin_acc_y": 0.0, "lin_acc_z": 0.0, "ang_vel_x": 0.0, "ang_vel_y": 0.0, "ang_vel_z": 0.0}) # default initial sensor buffer self._imu_buf = buffer def reset_idx(self, env_ids): num_resets = len(env_ids) ## randomize DOF velocities ## # dof_vel = torch_rand_float(-0.1, 0.1, (num_resets, 57), device=self._device) # self._robots.set_joint_velocities(dof_vel, indices=env_ids) # apply resets ## Reset Ball positions ## ball_pos, ball_rot = self.initial_root_pos[env_ids], self.initial_root_rot[env_ids] ball_pos[:, 2] = 0.12 # force ball to touch floor prefectly root_vel = torch.zeros((num_resets, 6), device=self._device) # Apply Ball position self._ball.set_world_poses(ball_pos, ball_rot, indices=env_ids) ## Random Ball velocities ## ball_vel = torch_rand_float(-0.01, 0.01, (num_resets, 6), device=self._device) self._ball.set_velocities(ball_vel, indices=env_ids) ## Random Robot positions & orientations ## fall_direction = torch_rand_float(-np.pi, np.pi, (num_resets, 1), device=self._device).reshape(-1) fall_direction_axis = torch.Tensor([0, 0, 1]).repeat(num_resets, 1).to(self._device).reshape(-1, 3) fall_angle = torch_rand_float(0, np.pi/8, (num_resets, 1), device=self._device).reshape(-1) fall_angle_axis = torch.Tensor([0, 1, 0]).repeat(num_resets, 1).to(self._device).reshape(-1, 3) fall_direction_quat = torch_rot.quat_from_angle_axis(fall_direction, fall_direction_axis) fall_angle_quat = torch_rot.quat_from_angle_axis(fall_angle, fall_angle_axis) ## Apply Robot position ## robot_pos = ball_pos.clone() # use ball position as reference robot_offset = torch.Tensor([0, 0, self._robot_offset]).repeat(num_resets).to(self._device).reshape(-1, 3) # Distance from ball center to robot center is 18 cm. robot_pos = robot_pos + robot_offset # robot_pos = robot_pos + torch_rot.quat_rotate(fall_angle_quat, torch_rot.quat_rotate(fall_direction_quat, robot_offset)) robot_rot = self.initial_root_rot[env_ids] # robot_rot = torch_rot.quat_apply(fall_direction_quat, robot_rot) # robot_rot = torch_rot.quat_apply(fall_angle_quat, robot_rot) # root_pos, root_rot = self.initial_root_pos[env_ids], self.initial_root_rot[env_ids] # root_vel = torch.zeros((num_resets, 6), device=self._device) # self._robots.set_world_poses(robot_pos, robot_rot, indices=env_ids) self._robots.set_velocities(root_vel, indices=env_ids) # bookkeeping self.reset_buf[env_ids] = 0 self.progress_buf[env_ids] = 0 def post_reset(self): # Run only once after simulation started # self._robots = self.get_robot() self.initial_root_pos, self.initial_root_rot = self._robots.get_world_poses() # save initial position for reset self.initial_dof_pos = self._robots.get_joint_positions() # initialize some data used later on # self.start_rotation = torch.tensor([1, 0, 0, 0], device=self._device, dtype=torch.float32) # self.up_vec = torch.tensor([0, 0, 1], dtype=torch.float32, device=self._device).repeat((self.num_envs, 1)) # self.heading_vec = torch.tensor([1, 0, 0], dtype=torch.float32, device=self._device).repeat((self.num_envs, 1)) # self.inv_start_rot = quat_conjugate(self.start_rotation).repeat((self.num_envs, 1)) # self.basis_vec0 = self.heading_vec.clone() # self.basis_vec1 = self.up_vec.clone() self._wheel_0_dof_idx = self._robots.get_dof_index("wheel_0_joint") self._wheel_1_dof_idx = self._robots.get_dof_index("wheel_1_joint") self._wheel_2_dof_idx = self._robots.get_dof_index("wheel_2_joint") # randomize all envs indices = torch.arange(self._robots.count, dtype=torch.int64, device=self._device) self.reset_idx(indices) def calculate_metrics(self) -> None: # calculate reward for each env wheel_vel = self.obs_buf[:, :3] # if 'self.previous_wheel_vel' in locals(): # wheel_accel = wheel_vel - self.previous_wheel_vel # else: wheel_accel = torch.zeros_like(wheel_vel) # wheel_accel_cost = torch.sum(wheel_accel**2, dim=-1) # self.previous_wheel_vel = wheel_vel.clone() balls_position, balls_orientation = self._ball.get_world_poses() robots_position, robots_orientation = self._robots.get_world_poses() robots_omega = self._robots.get_angular_velocities() fall_angles = q2falling(robots_orientation) # find fall angle of all robot (batched) if self.previous_fall_angle is None: falling_velocity = torch.zeros_like(robots_position[:, 0]) else: falling_velocity = fall_angles - self.previous_fall_angle ## aligning up axis of robot and environment # up_proj = torch.cos(fall_angles) # up_reward = torch.zeros_like(fall_angles) # up_reward = torch.where(up_proj > 0.93, up_reward + self.up_weight, up_reward) # falling_penalty = fall_angles q1 = self.initial_root_rot # world frame q2 = robots_orientation # robot orientation # find product of quaternions product_quaternion = torch.sum(q1*q2,dim=-1) # <q1, q2> quaternion_distance = 1 - (product_quaternion**2) # print(quaternion_distance) ## energy penalty for movement # actions_cost = torch.sum(self.wheel_velocities ** 2, dim=-1) # electricity_cost = torch.sum(torch.abs(self.actions * obs_buf[:, 12+num_dof:12+num_dof*2])* self.motor_effort_ratio.unsqueeze(0), dim=-1) ## rotation penality # rotation_cost = torch.sum(torch_rot.quat_diff_rad(robots_orientation, self.initial_root_rot)** 2, dim=-1) ## reward for duration of staying alive alive_reward = torch.ones_like(fall_angles) * self.alive_reward_scale # progress_reward = potentials - prev_potentials # print(robots_position - balls_position) # print(torch.sum((robots_position - balls_position)**2, dim=-1)) total_reward = ( - quaternion_distance # - wheel_accel_cost * 0.05 # - falling_velocity + alive_reward # + up_reward # - math.e**(-0.01*fall_angles) # - actions_cost * self.actions_cost_scale # - torch.sum(robots_omega**2, dim=-1) * 10 # - rotation_cost * 10 ) # adjust reward for fallen agents total_reward = torch.where( robots_position[:, 2] < self.termination_height, # fall by height torch.ones_like(total_reward) * self.death_cost, total_reward ) total_reward = torch.where( fall_angles > 50 / 180 * math.pi, # fall by angle torch.ones_like(total_reward) * self.death_cost, total_reward ) total_reward = torch.where( torch.sum((robots_position - balls_position)**2, dim=-1) > (self._robot_offset+self._jump_offset)**2, # jump beyond jump_offset torch.ones_like(total_reward) * self.death_cost, total_reward ) self.previous_fall_angle = fall_angles self.rew_buf[:] = total_reward def is_done(self) -> None: # check termination for each env balls_position, balls_orientation = self._ball.get_world_poses() robots_position, robots_orientation = self._robots.get_world_poses() fall_angles = q2falling(robots_orientation) # find fall angle of all robot (batched) robot_z_position = robots_position[:, 2] # print("Z position", robot_z_position) resets = torch.zeros(self._num_envs, dtype=torch.long, device=self._device) resets = torch.where(torch.sum((robots_position - balls_position)**2, dim=-1) > (self._robot_offset+self._jump_offset)**2, 1, resets) # jump beyond jump_offset resets = torch.where(robot_z_position < 0.25, 1, resets) # reset by falling (Z-position) resets = torch.where(fall_angles > 50*(np.pi / 180), 1, resets) # reset by falling (angle) resets = torch.where(self.progress_buf >= self._max_episode_length, 1, resets) # reset by time self.reset_buf[:] = resets
20,553
Python
50.129353
169
0.604583
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/eval.py
from env2 import MoonCakeEnv from stable_baselines3 import PPO from stable_baselines3.ppo import CnnPolicy, MlpPolicy from stable_baselines3.common.callbacks import CheckpointCallback policy_path = "./mlp_policy/mooncake_policy_checkpoint_200000_steps" my_env = MoonCakeEnv(headless=False, max_episode_length=99999999, display_every_iter=1) model = PPO.load(policy_path) for _ in range(20): obs = my_env.reset() done = False while not done: actions, _ = model.predict(observation=obs, deterministic=True) obs, reward, done, info = my_env.step(actions) my_env.render() my_env.close()
622
Python
31.789472
87
0.733119
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/mooncake_old.py
from typing import Optional, Tuple import numpy as np from omni.isaac.core.robots.robot import Robot from omni.isaac.core.utils.nucleus import find_nucleus_server from omni.isaac.core.utils.types import ArticulationAction from omni.isaac.core.utils.prims import get_prim_at_path, define_prim import carb class MoonCake(Robot): """[summary] Args: stage (Usd.Stage): [description] prim_path (str): [description] name (str): [description] usd_path (str, optional): [description] position (Optional[np.ndarray], optional): [description]. Defaults to None. orientation (Optional[np.ndarray], optional): [description]. Defaults to None. """ def __init__( self, prim_path: str, name: str = "mooncake", usd_path: Optional[str] = None, position: Optional[np.ndarray] = None, orientation: Optional[np.ndarray] = None, ) -> None: prim = get_prim_at_path(prim_path) if not prim.IsValid(): prim = define_prim(prim_path, "Xform") if usd_path: prim.GetReferences().AddReference(usd_path) else: result, nucleus_server = find_nucleus_server() if result is False: carb.log_error("Could not find nucleus server with /Isaac folder") return asset_path = nucleus_server + "/Library/mooncake.usd" # load from nucleus server prim.GetReferences().AddReference(asset_path) super().__init__( prim_path=prim_path, name=name, position=position, orientation=orientation, articulation_controller=None ) self._wheel_dof_names = ["wheel_0_joint", "wheel_1_joint", "wheel_2_joint"] self._wheel_dof_indices = None return @property def wheel_dof_indicies(self) -> Tuple[int, int, int]: """[summary] Returns: int: [description] """ return self._wheel_dof_indices def get_wheel_positions(self) -> Tuple[float, float, float]: """[summary] Returns: Tuple[float, float, float]: [description] """ joint_positions = self.get_joint_positions() return joint_positions[self._wheel_dof_indices[0]], joint_positions[self._wheel_dof_indices[1]], \ joint_positions[self._wheel_dof_indices[2]] def set_wheel_positions(self, positions: Tuple[float, float]) -> None: """[summary] Args: positions (Tuple[float, float, float]): [description] """ joint_positions = [None, None, None] joint_positions[self._wheel_dof_indices[0]] = positions[0] joint_positions[self._wheel_dof_indices[1]] = positions[1] joint_positions[self._wheel_dof_indices[2]] = positions[2] self.set_joint_positions(positions=np.array(joint_positions)) return def get_wheel_velocities(self) -> Tuple[float, float, float]: """[summary] Returns: Tuple[np.ndarray, np.ndarray, np.ndarray]: [description] """ joint_velocities = self.get_joint_velocities() return joint_velocities[self._wheel_dof_indices[0]], joint_velocities[self._wheel_dof_indices[1]], \ joint_velocities[self._wheel_dof_indices[2]] def set_wheel_velocities(self, velocities: Tuple[float, float, float]) -> None: """[summary] Args: velocities (Tuple[float, float, float]): [description] """ joint_velocities = [None, None, None] joint_velocities[self._wheel_dof_indices[0]] = velocities[0] joint_velocities[self._wheel_dof_indices[1]] = velocities[1] joint_velocities[self._wheel_dof_indices[2]] = velocities[2] self.set_joint_velocities(velocities=np.array(joint_velocities)) return def get_wheel_efforts(self) -> Tuple[float, float, float]: """[summary] Returns: Tuple[np.ndarray, np.ndarray, np.ndarray]: [description] """ joint_efforts = self.get_joint_efforts() return joint_efforts[self._wheel_dof_indices[0]], joint_efforts[self._wheel_dof_indices[1]], joint_efforts[ self._wheel_dof_indices[2]] def set_wheel_efforts(self, velocities: Tuple[float, float, float]) -> None: """[summary] Args: efforts (Tuple[float, float, float]): [description] """ joint_efforts = [None, None] joint_efforts[self._wheel_dof_indices[0]] = velocities[0] joint_efforts[self._wheel_dof_indices[1]] = velocities[1] joint_efforts[self._wheel_dof_indices[2]] = velocities[2] self.set_joint_efforts(efforts=np.array(joint_efforts)) return def apply_wheel_actions(self, actions: ArticulationAction) -> None: """[summary] Args: actions (ArticulationAction): [description] """ actions_length = actions.get_length() if actions_length is not None and actions_length != 3: raise Exception("ArticulationAction passed should be equal to 3") joint_actions = ArticulationAction() if actions.joint_positions is not None: joint_actions.joint_positions = np.zeros(self.num_dof) joint_actions.joint_positions[self._wheel_dof_indices[0]] = actions.joint_positions[0] joint_actions.joint_positions[self._wheel_dof_indices[1]] = actions.joint_positions[1] joint_actions.joint_positions[self._wheel_dof_indices[2]] = actions.joint_positions[2] if actions.joint_velocities is not None: joint_actions.joint_velocities = np.zeros(self.num_dof) joint_actions.joint_velocities[self._wheel_dof_indices[0]] = actions.joint_velocities[0] joint_actions.joint_velocities[self._wheel_dof_indices[1]] = actions.joint_velocities[1] joint_actions.joint_velocities[self._wheel_dof_indices[2]] = actions.joint_velocities[2] if actions.joint_efforts is not None: joint_actions.joint_efforts = np.zeros(self.num_dof) joint_actions.joint_efforts[self._wheel_dof_indices[0]] = actions.joint_efforts[0] joint_actions.joint_efforts[self._wheel_dof_indices[1]] = actions.joint_efforts[1] joint_actions.joint_efforts[self._wheel_dof_indices[2]] = actions.joint_efforts[2] self.apply_action(control_actions=joint_actions) return def initialize(self) -> None: """[summary] """ super().initialize() print(self._dofs_infos) # print Orderdict of all dof_name:dof_object self._wheel_dof_indices = ( self.get_dof_index(self._wheel_dof_names[0]), self.get_dof_index(self._wheel_dof_names[1]), self.get_dof_index(self._wheel_dof_names[2]), ) return def post_reset(self) -> None: """[summary] """ super().post_reset() # print(len(self._articulation_controller._dof_controllers)) # print(self._articulation_controller._dof_controllers) # Assign kd only for driven acticulation (3 wheels) and leave other as None kds = [None] * len(self._articulation_controller._dof_controllers) for i in self._wheel_dof_indices: kds[i] = 1e2 self._articulation_controller.set_gains(kds=kds) self._articulation_controller.switch_control_mode(mode="effort") # effort, velocity, position return
7,539
Python
43.352941
116
0.614803
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_ac2.py
from env import MoonCakeEnv import gym from stable_baselines3 import A2C from stable_baselines3.common.env_util import make_vec_env my_env = MoonCakeEnv(headless=False) # Parallel environments # env = make_vec_env("CartPole-v1", n_envs=4) model = A2C("MlpPolicy", my_env, verbose=1) model.learn(total_timesteps=5000000) model.save("a2c_cartpole") # del model # remove to demonstrate saving and loading # # model = A2C.load("a2c_cartpole") # # obs = env.reset() # while True: # action, _states = model.predict(obs) # obs, rewards, dones, info = env.step(action) # env.render()
591
Python
24.739129
58
0.717428
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_ppo_lstm.py
import numpy as np from env_mooncake import MoonCakeEnv import gym import numpy as np import wandb from wandb.integration.sb3 import WandbCallback from sb3_contrib import RecurrentPPO from stable_baselines3.common.evaluation import evaluate_policy config = { "policy_type": "MlpLstmPolicy", "total_timesteps": 3000000, "env_name": "MoonCake-v3", } run = wandb.init( project="mooncake_test", config=config, sync_tensorboard=True, # auto-upload sb3's tensorboard metrics # monitor_gym=True, # auto-upload the videos of agents playing the game # save_code=True, # optional ) env = MoonCakeEnv(skip_frame=1, physics_dt=1.0 / 100.0, rendering_dt=1.0 / 60.0, max_episode_length=10, display_every_iter=20, headless=False, observation_list=["lin_acc_x", "lin_acc_y", "lin_acc_z", "ang_vel_x", "ang_vel_y", "ang_vel_z", "robot_rotation_x", "robot_rotation_y", "robot_rotation_z"]) model = RecurrentPPO("MlpLstmPolicy", env, verbose=1, tensorboard_log=f"runs/{run.id}", device="cuda") model.learn( total_timesteps=config["total_timesteps"], callback=WandbCallback( gradient_save_freq=1000, model_save_path=f"models/{run.id}", verbose=2, ), ) run.finish() # mean_reward, std_reward = evaluate_policy(model, env, n_eval_episodes=20, warn=False) # print(mean_reward) model.save("ppo_recurrent") del model # remove to demonstrate saving and loading model = RecurrentPPO.load("ppo_recurrent") observations = env.reset() # cell and hidden state of the LSTM lstm_states = None num_envs = 1 # Episode start signals are used to reset the lstm states episode_starts = np.ones((num_envs,), dtype=bool) while True: # obs = [observations["lin_acc_y"], observations["lin_acc_z"], observations["ang_vel_x"]] # obs = np.array(obs, dtype=np.float32) action, lstm_states = model.predict(observations, state=lstm_states, episode_start=episode_starts, deterministic=True) observations, rewards, dones, info = env.step(action) episode_starts = dones env.render() if dones: lstm_states = None # Clear internal states observations = env.reset()
2,245
Python
32.029411
174
0.668597
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/env_mooncake.py
import random import gym from gym import spaces import numpy as np import math import time import carb from omni.isaac.imu_sensor import _imu_sensor state_low = [-100, -100, -10] state_high = [100, 100, 10] action_low = [-1] action_high = [1] def q2falling(q): q[0] = 1 if q[0] > 1 else q[0] try: if q[1] == 0 and q[2] == 0 and q[3] == 0: return 0 return 2*math.acos(q[0])*math.sqrt((q[1]**2 + q[2]**2)/(q[1]**2 + q[2]**2 + q[3]**2)) except: print(q) return 0 class MoonCakeEnv(gym.Env): metadata = {"render.modes": ["human"]} def __init__( self, skip_frame=1, physics_dt=1.0 / 100.0, rendering_dt=1.0 / 60.0, max_episode_length=60, display_every_iter=20, seed=0, headless=True, observation_list=["lin_acc_y", "lin_acc_z", "ang_vel_x"], ) -> None: from omni.isaac.kit import SimulationApp ## Specify simulation parameters ## self._physics_dt = physics_dt self._rendering_dt = rendering_dt self._max_episode_length = max_episode_length / self._physics_dt # 60 second after reset self._skip_frame = skip_frame self._iteration_count = 0 self._display_every_iter = display_every_iter self._update_every = 1 self._explore_every = 5 self._headless = headless self._observation_list = observation_list self.simulation_app = SimulationApp({"headless": self._headless, "anti_aliasing": 0}) self.previous_observations = {} ## Setup World ## from omni.isaac.core import World from mooncake_old import MoonCake from omni.isaac.core.objects import DynamicSphere self.world = World(physics_dt=self._physics_dt, rendering_dt=self._rendering_dt, stage_units_in_meters=0.01) self.world.scene.add_default_ground_plane() self.robot = self.world.scene.add( MoonCake( prim_path="/mooncake", name="mooncake_mk0", position=np.array([0, 0.0, 30.0]), orientation=np.array([1.0, 0.0, 0.0, 0.0]), ) ) self.ball = self.world.scene.add( DynamicSphere( prim_path="/ball", name="ball", position=np.array([0, 0, 12]), radius=12, # mediciene ball diameter 24cm. color=np.array([1.0, 0, 0]), mass=4, ) ) ## Setup IMU ## self.imu_interface = _imu_sensor.acquire_imu_sensor_interface() self.props = _imu_sensor.SensorProperties() self.props.position = carb.Float3(0, 0, 10) # translate from /obike/chassic to above motor (cm.) self.props.orientation = carb.Float4(1, 0, 0, 0) # (x, y, z, w) self.props.sensorPeriod = 1 / 500 # 2ms self._sensor_handle = self.imu_interface.add_sensor_on_body("/obike/chassic", self.props) self.action_space = spaces.Box(low=-1.0, high=1.0, shape=(3,), dtype=np.float32) self.observation_space = spaces.Box(low=-1.0, high=1.0, shape=(len(self._observation_list),), dtype=np.float32) def step(self, action): ## EXECUTE ACTION ## from omni.isaac.core.utils.types import ArticulationAction # print(action) # action = (action-0.5)+random.random()*0.01 joint_actions = ArticulationAction() joint_actions.joint_efforts = np.zeros(self.robot.num_dof) # joint_actions.joint_velocities = np.zeros(self.robot.num_dof) # joint_actions.joint_positions = np.zeros(self.robot.num_dof) # joint_actions.joint_efforts[self.robot._wheel_dof_indices[0]] = action[0] * 1000 * 2 # joint_actions.joint_efforts[self.robot._wheel_dof_indices[1]] = action[1] * 1000 * 2 # joint_actions.joint_efforts[self.robot._wheel_dof_indices[2]] = action[2] * 1000 * 2 # joint_actions.joint_velocities[self.robot._wheel_dof_indices[1]] = -0.2* 1000 # joint_actions.joint_positions[self.robot._wheel_dof_indices[2]] = 0 # self.robot.apply_action(control_actions=joint_actions) self.robot.apply_wheel_actions(ArticulationAction(joint_efforts=[action[i] * 3000 for i in range(3)])) self.world.step(render=(not self._headless) and (self._iteration_count%self._display_every_iter==0)) observations = self.get_observation() reward = self.previous_observations['fall_rotation'] - observations['fall_rotation'] reward *= 100 ## Check for stop event ## exceed_time_limit = self.world.current_time_step_index >= self._max_episode_length robot_fall = True if observations['fall_rotation'] > 50 / 180 * math.pi else False done = exceed_time_limit or robot_fall info = {} obs = [observations[name] for name in self._observation_list] scaled_observation = [] for name in self._observation_list: if "lin_acc" in name: scaled_observation.append(observations[name]/1000) # (-1000,1000)cm/s^2 -> (-1,1) if "ang_vel" in name: scaled_observation.append(observations[name]/10) # (-10,10)rad/s -> (-1,1) if "rotation" in name: scaled_observation.append(observations[name]) # quaternion already inrange(0,1) self.previous_observations = observations.copy() return obs, reward, done, info def reset(self): self._iteration_count += 1 self.world.reset() self.robot.initialize() # self.world.scene.remove("/obike") # from obike import Obike # self.robot = self.world.scene.add( # Obike( # prim_path="/obike", # name="obike_mk0", # position=np.array([10 * random.random(), 10 * random.random(), 1.435]), # orientation=np.array([1.0, 0.0, 0.0, 0.0]), # ) # ) observations = self.get_observation() obs = [observations[name] for name in self._observation_list] self.previous_observations['fall_rotation'] = 0 return obs def get_observation(self): observations = {"robot_position_x":None, "robot_position_y":None, "robot_position_z":None, "robot_rotation_x":None, "robot_rotation_y":None, "robot_rotation_z":None, "robot_rotation_w":None, "lin_acc_x":None, "lin_acc_y":None, "lin_acc_z":None, "ang_vel_x":None, "ang_vel_y":None, "ang_vel_z":None} [observations["robot_position_x"], observations["robot_position_y"], observations["robot_position_z"]], [observations["robot_rotation_x"], observations["robot_rotation_y"], observations["robot_rotation_z"], observations["robot_rotation_w"]] = self.robot.get_world_pose() reading = self.imu_interface.get_sensor_readings(self._sensor_handle) if reading.shape[0] == 0: # no valid data in buffer -> init observation wih zeros observations["lin_acc_x"], observations["lin_acc_y"], observations["lin_acc_z"], observations["ang_vel_x"], observations["ang_vel_y"], observations["ang_vel_z"] = 0, 0, 0, 0, 0, 0 else: observations["lin_acc_x"], observations["lin_acc_y"], observations["lin_acc_z"], observations["ang_vel_x"], observations["ang_vel_y"], observations["ang_vel_z"] = reading[-1]["lin_acc_x"], reading[-1]["lin_acc_y"], reading[-1]["lin_acc_z"], reading[-1]["ang_vel_x"], reading[-1]["ang_vel_y"], reading[-1]["ang_vel_z"] observations["fall_rotation"] = q2falling([observations["robot_rotation_x"], observations["robot_rotation_y"], observations["robot_rotation_z"], observations["robot_rotation_w"]]) return observations def close(self): pass def seed(self, seed=None): self.np_random, seed = gym.utils.seeding.np_random(seed) np.random.seed(seed) return [seed]
7,919
Python
48.81132
331
0.59856
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_ddpg.py
from env import MoonCakeEnv import gym import numpy as np from stable_baselines3 import DDPG from stable_baselines3.common.noise import NormalActionNoise, OrnsteinUhlenbeckActionNoise my_env = MoonCakeEnv(headless=False) # env = gym.make("Pendulum-v1") # The noise objects for DDPG n_actions = my_env.action_space.shape[-1] # action_noise = NormalActionNoise(mean=np.zeros(n_actions), sigma=0.01 * np.ones(n_actions)) model = DDPG("MlpPolicy", my_env, verbose=1) # model = DDPG("MlpPolicy", my_env, action_noise=action_noise, verbose=1) model.learn(total_timesteps=10000, log_interval=10) model.save("ddpg_pendulum") # env = model.get_env() # # del model # remove to demonstrate saving and loading # # model = DDPG.load("ddpg_pendulum") # # obs = env.reset() # while True: # action, _states = model.predict(obs) # obs, rewards, dones, info = env.step(action) # env.render()
889
Python
29.689654
93
0.727784
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_dqn.py
from env import MoonCakeEnv import gym from stable_baselines3 import DQN my_env = MoonCakeEnv(headless=False) # env = gym.make("CartPole-v0") model = DQN("MlpPolicy", my_env, verbose=1) model.learn(total_timesteps=10000, log_interval=4) model.save("dqn_cartpole") # del model # remove to demonstrate saving and loading # # model = DQN.load("dqn_cartpole") # # obs = env.reset() # while True: # action, _states = model.predict(obs, deterministic=True) # obs, reward, done, info = env.step(action) # env.render() # if done: # obs = env.reset()
566
Python
24.772726
62
0.685512
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/mooncake.py
from typing import Optional import numpy as np import torch from omni.isaac.core.robots.robot import Robot from omni.isaac.core.utils.nucleus import get_server_path from omni.isaac.core.utils.stage import add_reference_to_stage from omni.isaac.core.utils.types import ArticulationAction import carb class Mooncake(Robot): def __init__( self, prim_path: str, name: Optional[str] = "Mooncake", usd_path: Optional[str] = None, translation: Optional[np.ndarray] = None, orientation: Optional[np.ndarray] = None, ) -> None: self._usd_path = usd_path self._name = name if self._usd_path is None: server_path = get_server_path() if server_path is None: carb.log_error("Could not find Isaac Sim assets folder") self._usd_path = server_path + "/Library/mooncake.usd" add_reference_to_stage(self._usd_path, prim_path) super().__init__( prim_path=prim_path, name=name, translation=translation, orientation=orientation, articulation_controller=None, ) self._wheel_dof_indices = [self.get_dof_index("wheel_0_joint"), self.get_dof_index("wheel_1_joint"), self.get_dof_index("wheel_2_joint")] def apply_wheel_actions(self, actions: ArticulationAction) -> None: """[summary] Args: actions (ArticulationAction): [description] """ actions_length = actions.get_length() if actions_length is not None and actions_length != 3: raise Exception("ArticulationAction passed should be equal to 3") joint_actions = ArticulationAction() if actions.joint_positions is not None: joint_actions.joint_positions = np.zeros(self.num_dof) joint_actions.joint_positions[self._wheel_dof_indices[0]] = actions.joint_positions[0] joint_actions.joint_positions[self._wheel_dof_indices[1]] = actions.joint_positions[1] joint_actions.joint_positions[self._wheel_dof_indices[2]] = actions.joint_positions[2] if actions.joint_velocities is not None: joint_actions.joint_velocities = np.zeros(self.num_dof) joint_actions.joint_velocities[self._wheel_dof_indices[0]] = actions.joint_velocities[0] joint_actions.joint_velocities[self._wheel_dof_indices[1]] = actions.joint_velocities[1] joint_actions.joint_velocities[self._wheel_dof_indices[2]] = actions.joint_velocities[2] if actions.joint_efforts is not None: joint_actions.joint_efforts = np.zeros(self.num_dof) joint_actions.joint_efforts[self._wheel_dof_indices[0]] = actions.joint_efforts[0] joint_actions.joint_efforts[self._wheel_dof_indices[1]] = actions.joint_efforts[1] joint_actions.joint_efforts[self._wheel_dof_indices[2]] = actions.joint_efforts[2] self.apply_action(control_actions=joint_actions) return # class Ball(Robot): # def __init__( # self, # prim_path: str, # name: Optional[str] = "Ball", # usd_path: Optional[str] = None, # translation: Optional[np.ndarray] = None, # orientation: Optional[np.ndarray] = None, # ) -> None: # self._usd_path = usd_path # self._name = name # # if self._usd_path is None: # server_path = get_server_path() # if server_path is None: # carb.log_error("Could not find Isaac Sim assets folder") # self._usd_path = server_path + "/Library/ball.usd" # # add_reference_to_stage(self._usd_path, prim_path) # # super().__init__( # prim_path=prim_path, # name=name, # translation=translation, # orientation=orientation, # articulation_controller=None, # )
4,034
Python
40.597938
100
0.594695
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/train_select_observe.py
from stable_baselines3 import PPO from stable_baselines3.ppo import CnnPolicy, MlpPolicy from stable_baselines3.common.callbacks import CheckpointCallback import torch as th from env_select_observe import MoonCakeEnv import os log_dir = "./mlp_policy" # set headles to false to visualize training b = [1, 1, 1, 1, 1] save_dir = log_dir + "/mooncake_policy_" + str(b[0])+str(b[1])+str(b[2])+str(b[3])+str(b[4]) os.mkdir(save_dir) with open(save_dir + '/log.txt', 'w') as f: f.write(str(b) + '\n') [print("####################################################################################################") for i in range(3)] print(b) [print("####################################################################################################") for i in range(3)] my_env = MoonCakeEnv(headless=True, observ_selection = [b[0], b[1], b[2], b[3], b[4]]) # # checkpoint_callback = CheckpointCallback(save_freq=10000, save_path=log_dir, name_prefix="mooncake_policy_checkpoint") model = PPO(MlpPolicy, my_env, verbose=1, n_steps=10000, batch_size=100, learning_rate=0.00025, ) # model.learn(total_timesteps=500000, callback=[checkpoint_callback]) model.learn(total_timesteps=500000) model.save(save_dir) my_env.close()
1,297
Python
37.176469
129
0.560524
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/mooncake_task_3.py
from omniisaacgymenvs.tasks.base.rl_task import RLTask from mooncake import Mooncake import omni from pxr import UsdPhysics, Gf, UsdGeom from omni.isaac.core.articulations import ArticulationView from omni.isaac.core.prims import RigidPrimView from omni.isaac.core.utils.prims import get_prim_at_path import omni.isaac.core.utils.torch.rotations as torch_rot from omni.isaac.isaac_sensor import _isaac_sensor from omni.isaac.core.utils.torch.maths import torch_rand_float, tensor_clamp, unscale import numpy as np import torch import torch.nn.functional as f import math class MooncakeTask(RLTask):
601
Python
32.444443
85
0.828619
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/continuous_control.py
# -*- coding: utf-8 -*- """ A Continuous Control Implementation for TensorFlow 2.0 Author: W.J.A. van Heeswijk Date: 11-8-2020 This code is supplemental to the following note: 'Implementing Gaussian Actor Networks for Continuous Control in TensorFlow 2.0' https://www.researchgate.net/publication/343714359_Implementing_Gaussian_Actor_Networks_for_Continuous_Control_in_TensorFlow_20 Corresponding blog post: https://towardsdatascience.com/a-minimal-working-example-for-continuous-policy-gradients-in-tensorflow-2-0-d3413ec38c6b Python 3.8 and TensorFlow 2.3 were used to write the algorithm This code has been published under the GNU GPLv3 license """ # Needed for training the network import numpy as np import tensorflow as tf import tensorflow.keras as keras import tensorflow.keras.layers as layers import tensorflow.keras.initializers as initializers # Needed for animation import matplotlib.pyplot as plt import time """Plot output""" plt.ion() # here we are creating sub plots figure, ax = plt.subplots(figsize=(10, 8)) # Add labels and legend plt.xlabel('Episode') plt.ylabel('Parameter value') plt.grid() plt.legend(loc='best') def plot(): # fig = plt.figure() # ax = fig.add_subplot(1, 1, 1) # Append arrays epoch_ar.append(int(i)) mu_ar.append(float(mu)) sigma_ar.append(float(sigma)) reward_ar.append(float(reward)) target_ar.append(float(mu_target)) # Plot outcomes ax.plot(epoch_ar, mu_ar, label='mu') ax.plot(epoch_ar, sigma_ar, label='sigma') ax.plot(epoch_ar, reward_ar, label='reward') ax.plot(epoch_ar, target_ar, label='target') # plt.show() figure.canvas.draw() figure.canvas.flush_events() time.sleep(0.01) """Construct the actor network with mu and sigma as output""" def ConstructActorNetwork(bias_mu, bias_sigma): inputs = layers.Input(shape=(1,)) # input dimension hidden1 = layers.Dense(5, activation="relu", kernel_initializer=initializers.he_normal())(inputs) hidden2 = layers.Dense(5, activation="relu", kernel_initializer=initializers.he_normal())(hidden1) mu = layers.Dense(1, activation="linear", kernel_initializer=initializers.Zeros(), \ bias_initializer=initializers.Constant(bias_mu))(hidden2) sigma = layers.Dense(1, activation="softplus", kernel_initializer=initializers.Zeros(), \ bias_initializer=initializers.Constant(bias_sigma))(hidden2) actor_network = keras.Model(inputs=inputs, outputs=[mu, sigma]) return actor_network """Weighted Gaussian log likelihood loss function""" def CustomLossGaussian(state, action, reward): # Obtain mu and sigma from actor network nn_mu, nn_sigma = actor_network(state) # Obtain pdf of Gaussian distribution pdf_value = tf.exp(-0.5 * ((action - nn_mu) / (nn_sigma)) ** 2) * \ 1 / (nn_sigma * tf.sqrt(2 * np.pi)) # Compute log probability log_probability = tf.math.log(pdf_value + 1e-5) # Compute weighted loss loss_actor = - reward * log_probability return loss_actor """Main code""" # Initialize fixed state state = tf.constant([[1.0]]) # Define properties reward function mu_target = 4.0 target_range = 0.25 max_reward = 1.0 # Create actor network bias_mu = 0.0 # bias 0.0 yields mu=0.0 with linear activation function bias_sigma = 0.55 # bias 0.55 yields sigma=1.0 with softplus activation function actor_network = ConstructActorNetwork(bias_mu, bias_sigma) opt = keras.optimizers.Adam(learning_rate=0.001) # Initialize arrays for plot epoch_ar = [] mu_ar = [] sigma_ar = [] reward_ar = [] target_ar = [] for i in range(10000 + 1): # Obtain mu and sigma from network mu, sigma = actor_network(state) # Draw action from normal distribution action = tf.random.normal \ ([1], mean=mu, stddev=sigma) # Compute reward reward = max_reward / max(target_range, abs(mu_target - action)) * target_range # Update network weights with tf.GradientTape() as tape: # Compute Gaussian loss loss_value = CustomLossGaussian(state, action, reward) # Compute gradients grads = tape.gradient(loss_value, actor_network.trainable_variables) # Apply gradients to update network weights opt.apply_gradients(zip(grads, actor_network.trainable_variables)) # Update console output and plot if np.mod(i, 100) == 0: print('\n======episode', i, '======') print('mu', float(mu)) print('sigma', float(sigma)) print('action', float(action)) print('reward', float(reward)) print('loss', float(loss_value)) plot()
4,644
Python
29.966666
127
0.68497
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/ppo_lstm.py
import numpy as np import gym from sb3_contrib import RecurrentPPO from stable_baselines3.common.evaluation import evaluate_policy env = gym.make('CartPole-v1') model = RecurrentPPO("MlpLstmPolicy", env, verbose=1) model.learn(50000) mean_reward, std_reward = evaluate_policy(model, env, n_eval_episodes=20, warn=False) print(mean_reward) model.save("ppo_recurrent") del model # remove to demonstrate saving and loading model = RecurrentPPO.load("ppo_recurrent") obs = env.reset() # cell and hidden state of the LSTM lstm_states = None num_envs = 1 # Episode start signals are used to reset the lstm states episode_starts = np.ones((num_envs,), dtype=bool) while True: action, lstm_states = model.predict(obs, state=lstm_states, episode_start=episode_starts, deterministic=True) obs, rewards, dones, info = env.step(action) episode_starts = dones env.render() if dones: lstm_states = None env.reset()
942
Python
28.468749
113
0.733546
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/ppo_recurrent.py
# pysac -m pip install sb3-contrib import numpy as np from sb3_contrib import RecurrentPPO from stable_baselines3.common.evaluation import evaluate_policy model = RecurrentPPO("MlpLstmPolicy", "CartPole-v1", verbose=1) model.learn(50000) env = model.get_env() mean_reward, std_reward = evaluate_policy(model, env, n_eval_episodes=20, warn=False) print(mean_reward) model.save("ppo_recurrent") del model # remove to demonstrate saving and loading model = RecurrentPPO.load("ppo_recurrent") obs = env.reset() # cell and hidden state of the LSTM lstm_states = None num_envs = 1 # Episode start signals are used to reset the lstm states episode_starts = np.ones((num_envs,), dtype=bool) while True: action, lstm_states = model.predict(obs, state=lstm_states, episode_start=episode_starts, deterministic=True) obs, rewards, dones, info = env.step(action) episode_starts = dones env.render()
907
Python
30.310344
113
0.749724
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/simple_CartPole.py
import time import keras import tensorflow as tf import tensorflow.keras as keras import tensorflow.keras.layers as layers import tensorflow.keras.initializers as initializers import numpy as np import gym import matplotlib.pyplot as plt env = gym.make('CartPole-v1') gamma = 0.99 def discount_rewards(r): """ take 1D float array of rewards and compute discounted reward """ discounted_r = np.zeros_like(r) running_add = 0 for t in reversed(range(0, r.size)): running_add = running_add * gamma + r[t] discounted_r[t] = running_add return discounted_r """Weighted Gaussian log likelihood loss function""" def CustomLossGaussian(state, action, reward): # Obtain mu and sigma from actor network nn_mu, nn_sigma = actor_network(state.reshape(-1, 4)) # Obtain pdf of Gaussian distribution pdf_value = tf.exp(-0.5 * ((action - nn_mu) / (nn_sigma)) ** 2) * 1 / (nn_sigma * tf.sqrt(2 * np.pi)) # Compute log probability log_probability = tf.math.log(pdf_value + 1e-5) # Compute weighted loss loss_actor = - reward * log_probability return loss_actor class SimpleAgent(keras.Model): def __init__(self, s_size, a_size, h_size): super(SimpleAgent, self).__init__() # Input() can create a placeholder from an arbitrary tf.TypeSpec # self.state_in = keras.Input(type_spec=tf.RaggedTensorSpec(shape=[None, s_size], dtype=tf.float32)) self.state_in = keras.Input(shape=[None, s_size], dtype=tf.float32) self.hidden1 = layers.Dense(h_size, activation="relu") self.hidden2 = layers.Dense(h_size, activation="relu") self.mu = layers.Dense(a_size, activation="linear", kernel_initializer=initializers.Zeros())# , bias_initializer=initializers.Constant(bias_mu) self.sigma = layers.Dense(a_size, activation="softplus", kernel_initializer=initializers.Zeros())# , bias_initializer=initializers.Constant(bias_sigma) def call(self, inputs, training=False, mask=None): x = self.state_in = inputs x = self.hidden1(x, training=training) x = self.hidden2(x, training=training) return [self.mu(x, training=training), self.sigma(x, training=training)] actor_network = SimpleAgent(s_size=4, a_size=1, h_size=8) print(actor_network.trainable_variables) max_angle = 0.418 opt = keras.optimizers.Adam(learning_rate=0.001) update_frequency = 5 i = 0 total_reward = [] total_length = [] total_episodes = 10000 max_episode = 9999 gradBuffer = None # gradBuffer = actor_network.trainable_variables # for ix,grad in enumerate(gradBuffer): gradBuffer[ix] = grad * 0 while i < total_episodes: state = env.reset() running_reward = 0 ep_history = [] for j in range(max_episode): mu, sigma = actor_network(state.reshape(-1, 4)) # Obtain mu and sigma from network action = tf.random.normal([1], mean=mu, stddev=sigma) # Draw action from normal distribution # | Num | Action | # |-----|------------------------| # | 0 | Push cart to the left | # | 1 | Push cart to the right | cart_action = 1 if action.numpy().reshape(-1) > 0 else 0 # threshold action since cart_action is discrete next_state, reward, d, _ = env.step(cart_action) # if i % 100 == 0 and i!=0: env.render() delta_angle = abs(state[2]) # manually calculate reward from falling angle reward = 1 - (delta_angle / max_angle) # env.render() # print(reward, d) # time.sleep(0.1) ep_history.append([state, action, reward, next_state]) running_reward += reward if d==True: # Update the network ep_history = np.array(ep_history) ep_history[:, 2] = discount_rewards(ep_history[:, 2]) if gradBuffer is None: # init gradBuffer gradBuffer = actor_network.trainable_variables for ix, grad in enumerate(gradBuffer): gradBuffer[ix] = grad * 0 with tf.GradientTape() as tape: # Compute Gaussian loss loss_value = CustomLossGaussian(state, action, reward) # Compute gradients grads = tape.gradient(loss_value, actor_network.trainable_variables) # Apply gradients to update network weights # opt.apply_gradients(zip(grads, actor_network.trainable_variables)) for idx, grad in enumerate(grads): gradBuffer[idx] += grad if i % update_frequency == 0 and i != 0: # Apply gradients to update network weights opt.apply_gradients(zip(gradBuffer, actor_network.trainable_variables)) for ix, grad in enumerate(gradBuffer): gradBuffer[ix] = grad * 0 # reset buffer total_reward.append(running_reward) total_length.append(j) break state = next_state if i % 100 == 0: print(np.mean(total_reward[-100:])) i += 1
4,989
Python
42.771929
159
0.629786
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/test_RNN.py
import tensorflow as tf from tensorflow.keras import layers import numpy as np paragraph1 = np.random.random((20, 10, 50)).astype(np.float32) paragraph2 = np.random.random((20, 10, 50)).astype(np.float32) paragraph3 = np.random.random((20, 10, 50)).astype(np.float32) lstm_layer = layers.LSTM(64, stateful=True) output = lstm_layer(paragraph1) output = lstm_layer(paragraph2) existing_state = lstm_layer.states e = list(existing_state) for item in e: print(item.numpy().shape) new_lstm_layer = layers.LSTM(64) new_output = new_lstm_layer(paragraph3, initial_state=existing_state)
587
Python
29.947367
69
0.747871
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/test.py
import numpy as np import tensorflow as tf np.random.seed(42) tf.random.set_seed(42) input_dim = 3 output_dim = 3 num_timesteps = 2 batch_size = 10 nodes = 10 input_layer = tf.keras.Input(shape=(num_timesteps, input_dim), batch_size=batch_size) cell = tf.keras.layers.LSTMCell( nodes, kernel_initializer='glorot_uniform', recurrent_initializer='glorot_uniform', bias_initializer='zeros', ) lstm = tf.keras.layers.RNN( cell, return_state=True, return_sequences=True, stateful=True, ) lstm_out, hidden_state, cell_state = lstm(input_layer) output = tf.keras.layers.Dense(output_dim)(lstm_out) mdl = tf.keras.Model( inputs=input_layer, outputs=[hidden_state, cell_state, output] ) # We can now test what’s going on by passing a batch through the network (look Ma, no tf.Session!): x = np.random.rand(batch_size, num_timesteps, input_dim).astype(np.float32) h_state, c_state, out = mdl(x) print(np.mean(out)) # If we pass this same batch again, we get different result as the hidden state has been changed: h_state, c_state, out = mdl(x) print(np.mean(out)) # If we reset the hidden state, we can recover our initial output: lstm.reset_states(states=[np.zeros((batch_size, nodes)), np.zeros((batch_size, nodes))]) h_state, c_state, out = mdl(x) print(np.mean(out)) # This method also allows us to use other values than all zeros for the hidden state: lstm.reset_states(states=[np.ones((batch_size, nodes)), np.ones((batch_size, nodes))]) h_state, c_state, out = mdl(x) print(np.mean(out))
1,532
Python
29.058823
99
0.710836
teerameth/omni.isaac.fiborobotlab/omni/isaac/fiborobotlab/mooncake/examples/td3.py
import tensorflow as tf import numpy as np import gym from tensorflow.keras.models import load_model # !pip3 install box2d-py print(tf.config.list_physical_devices('GPU')) env = gym.make("LunarLanderContinuous-v2") state_low = env.observation_space.low state_high = env.observation_space.high action_low = env.action_space.low action_high = env.action_space.high print(state_low) print(state_high) print(action_low) print(action_high) class RBuffer(): def __init__(self, maxsize, statedim, naction): self.cnt = 0 self.maxsize = maxsize self.state_memory = np.zeros((maxsize, *statedim), dtype=np.float32) self.action_memory = np.zeros((maxsize, naction), dtype=np.float32) self.reward_memory = np.zeros((maxsize,), dtype=np.float32) self.next_state_memory = np.zeros((maxsize, *statedim), dtype=np.float32) self.done_memory = np.zeros((maxsize,), dtype=np.bool) def storexp(self, state, next_state, action, done, reward): index = self.cnt % self.maxsize self.state_memory[index] = state self.action_memory[index] = action self.reward_memory[index] = reward self.next_state_memory[index] = next_state self.done_memory[index] = 1 - int(done) self.cnt += 1 def sample(self, batch_size): max_mem = min(self.cnt, self.maxsize) batch = np.random.choice(max_mem, batch_size, replace=False) states = self.state_memory[batch] next_states = self.next_state_memory[batch] rewards = self.reward_memory[batch] actions = self.action_memory[batch] dones = self.done_memory[batch] return states, next_states, rewards, actions, dones class Critic(tf.keras.Model): def __init__(self): super(Critic, self).__init__() self.f1 = tf.keras.layers.Dense(512, activation='relu') self.f2 = tf.keras.layers.Dense(512, activation='relu') self.v = tf.keras.layers.Dense(1, activation=None) def call(self, inputstate, action): x = self.f1(tf.concat([inputstate, action], axis=1)) x = self.f2(x) x = self.v(x) return x class Actor(tf.keras.Model): def __init__(self, no_action): super(Actor, self).__init__() self.f1 = tf.keras.layers.Dense(512, activation='relu') self.f2 = tf.keras.layers.Dense(512, activation='relu') self.mu = tf.keras.layers.Dense(no_action, activation='tanh') def call(self, state): x = self.f1(state) x = self.f2(x) x = self.mu(x) return x class Agent(): def __init__(self, n_action=len(env.action_space.high)): self.actor_main = Actor(n_action) self.actor_target = Actor(n_action) self.critic_main = Critic() self.critic_main2 = Critic() self.critic_target = Critic() self.critic_target2 = Critic() self.batch_size = 64 self.n_actions = len(env.action_space.high) self.a_opt = tf.keras.optimizers.Adam(0.001) # self.actor_target = tf.keras.optimizers.Adam(.001) self.c_opt1 = tf.keras.optimizers.Adam(0.002) self.c_opt2 = tf.keras.optimizers.Adam(0.002) # self.critic_target = tf.keras.optimizers.Adam(.002) self.memory = RBuffer(1_00_000, env.observation_space.shape, len(env.action_space.high)) self.trainstep = 0 # self.replace = 5 self.gamma = 0.99 self.min_action = env.action_space.low[0] self.max_action = env.action_space.high[0] self.actor_update_steps = 2 self.warmup = 200 def act(self, state, evaluate=False): if self.trainstep > self.warmup: evaluate = True state = tf.convert_to_tensor([state], dtype=tf.float32) actions = self.actor_main(state) if not evaluate: actions += tf.random.normal(shape=[self.n_actions], mean=0.0, stddev=0.1) actions = self.max_action * (tf.clip_by_value(actions, self.min_action, self.max_action)) # print(actions) return actions[0] def savexp(self, state, next_state, action, done, reward): self.memory.storexp(state, next_state, action, done, reward) def update_target(self): self.actor_target.set_weights(self.actor_main.get_weights()) self.critic_target.set_weights(self.critic_main.get_weights()) self.critic_target2.set_weights(self.critic_main2.get_weights()) def train(self): if self.memory.cnt < self.batch_size: return states, next_states, rewards, actions, dones = self.memory.sample(self.batch_size) states = tf.convert_to_tensor(states, dtype=tf.float32) next_states = tf.convert_to_tensor(next_states, dtype=tf.float32) rewards = tf.convert_to_tensor(rewards, dtype=tf.float32) actions = tf.convert_to_tensor(actions, dtype=tf.float32) # dones = tf.convert_to_tensor(dones, dtype= tf.bool) with tf.GradientTape() as tape1, tf.GradientTape() as tape2: target_actions = self.actor_target(next_states) target_actions += tf.clip_by_value( tf.random.normal(shape=[*np.shape(target_actions)], mean=0.0, stddev=0.2), -0.5, 0.5) target_actions = self.max_action * (tf.clip_by_value(target_actions, self.min_action, self.max_action)) target_next_state_values = tf.squeeze(self.critic_target(next_states, target_actions), 1) target_next_state_values2 = tf.squeeze(self.critic_target2(next_states, target_actions), 1) critic_value = tf.squeeze(self.critic_main(states, actions), 1) critic_value2 = tf.squeeze(self.critic_main2(states, actions), 1) next_state_target_value = tf.math.minimum(target_next_state_values, target_next_state_values2) target_values = rewards + self.gamma * next_state_target_value * dones critic_loss1 = tf.keras.losses.MSE(target_values, critic_value) critic_loss2 = tf.keras.losses.MSE(target_values, critic_value2) grads1 = tape1.gradient(critic_loss1, self.critic_main.trainable_variables) grads2 = tape2.gradient(critic_loss2, self.critic_main2.trainable_variables) self.c_opt1.apply_gradients(zip(grads1, self.critic_main.trainable_variables)) self.c_opt2.apply_gradients(zip(grads2, self.critic_main2.trainable_variables)) self.trainstep += 1 if self.trainstep % self.actor_update_steps == 0: with tf.GradientTape() as tape3: new_policy_actions = self.actor_main(states) actor_loss = -self.critic_main(states, new_policy_actions) actor_loss = tf.math.reduce_mean(actor_loss) grads3 = tape3.gradient(actor_loss, self.actor_main.trainable_variables) self.a_opt.apply_gradients(zip(grads3, self.actor_main.trainable_variables)) # if self.trainstep % self.replace == 0: self.update_target() with tf.device('GPU:0'): tf.random.set_seed(336699) agent = Agent(2) episods = 20000 ep_reward = [] total_avgr = [] target = False for s in range(episods): if target == True: break total_reward = 0 state = env.reset() done = False while not done: if s%10==0: env.render() action = agent.act(state) next_state, reward, done, _ = env.step(action) agent.savexp(state, next_state, action, done, reward) agent.train() state = next_state total_reward += reward if done: ep_reward.append(total_reward) avg_reward = np.mean(ep_reward[-100:]) total_avgr.append(avg_reward) print("total reward after {} steps is {} and avg reward is {}".format(s, total_reward, avg_reward)) if avg_reward == 200: target = True
7,977
Python
37.917073
115
0.620409