1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
8 * Title: arm_negate_q31.c
10 * Description: Negates Q31 vectors.
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Version 1.0.10 2011/7/15
15 * Big Endian support added and Merged M0 and M3/M4 Source code.
17 * Version 1.0.3 2010/11/29
18 * Re-organized the CMSIS folders and updated documentation.
20 * Version 1.0.2 2010/11/11
21 * Documentation updated.
23 * Version 1.0.1 2010/10/05
24 * Production release and review comments incorporated.
26 * Version 1.0.0 2010/09/20
27 * Production release and review comments incorporated.
29 * Version 0.0.7 2010/06/10
30 * Misra-C changes done
31 * -------------------------------------------------------------------- */
45 * @brief Negates the elements of a Q31 vector.
46 * @param[in] *pSrc points to the input vector
47 * @param[out] *pDst points to the output vector
48 * @param[in] blockSize number of samples in the vector
51 * <b>Scaling and Overflow Behavior:</b>
53 * The function uses saturating arithmetic.
54 * The Q31 value -1 (0x80000000) will be saturated to the maximum allowable positive value 0x7FFFFFFF.
62 q31_t in; /* Temporary variable */
63 uint32_t blkCnt; /* loop counter */
67 /* Run the below code for Cortex-M4 and Cortex-M3 */
70 blkCnt = blockSize >> 2u;
72 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
73 ** a second loop below computes the remaining 1 to 3 samples. */
77 /* Negate and then store the results in the destination buffer. */
79 *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
81 *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
83 *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
85 *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
87 /* Decrement the loop counter */
91 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
92 ** No loop unrolling is used. */
93 blkCnt = blockSize % 0x4u;
97 /* Run the below code for Cortex-M0 */
99 /* Initialize blkCnt with number of samples */
102 #endif /* #ifndef ARM_MATH_CM0 */
108 /* Negate and then store the result in the destination buffer. */
110 *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
112 /* Decrement the loop counter */
118 * @} end of negate group