训练营PLSR题目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

164 line
4.0 KiB

  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_min_q31.c
  4. * Description: Minimum value of a Q31 vector
  5. *
  6. * $Date: 27. January 2017
  7. * $Revision: V.1.5.1
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "arm_math.h"
  29. /**
  30. * @ingroup groupStats
  31. */
  32. /**
  33. * @addtogroup Min
  34. * @{
  35. */
  36. /**
  37. * @brief Minimum value of a Q31 vector.
  38. * @param[in] *pSrc points to the input vector
  39. * @param[in] blockSize length of the input vector
  40. * @param[out] *pResult minimum value returned here
  41. * @param[out] *pIndex index of minimum value returned here
  42. * @return none.
  43. */
  44. void arm_min_q31(
  45. q31_t * pSrc,
  46. uint32_t blockSize,
  47. q31_t * pResult,
  48. uint32_t * pIndex)
  49. {
  50. #if defined (ARM_MATH_DSP)
  51. /* Run the below code for Cortex-M4 and Cortex-M3 */
  52. q31_t minVal1, minVal2, out; /* Temporary variables to store the output value. */
  53. uint32_t blkCnt, outIndex, count; /* loop counter */
  54. /* Initialise the count value. */
  55. count = 0U;
  56. /* Initialise the index value to zero. */
  57. outIndex = 0U;
  58. /* Load first input value that act as reference value for comparision */
  59. out = *pSrc++;
  60. /* Loop unrolling */
  61. blkCnt = (blockSize - 1U) >> 2U;
  62. while (blkCnt > 0U)
  63. {
  64. /* Initialize minVal to the next consecutive values one by one */
  65. minVal1 = *pSrc++;
  66. minVal2 = *pSrc++;
  67. /* compare for the minimum value */
  68. if (out > minVal1)
  69. {
  70. /* Update the minimum value and its index */
  71. out = minVal1;
  72. outIndex = count + 1U;
  73. }
  74. /* compare for the minimum value */
  75. if (out > minVal2)
  76. {
  77. /* Update the minimum value and its index */
  78. out = minVal2;
  79. outIndex = count + 2U;
  80. }
  81. /* Initialize minVal to the next consecutive values one by one */
  82. minVal1 = *pSrc++;
  83. minVal2 = *pSrc++;
  84. /* compare for the minimum value */
  85. if (out > minVal1)
  86. {
  87. /* Update the minimum value and its index */
  88. out = minVal1;
  89. outIndex = count + 3U;
  90. }
  91. /* compare for the minimum value */
  92. if (out > minVal2)
  93. {
  94. /* Update the minimum value and its index */
  95. out = minVal2;
  96. outIndex = count + 4U;
  97. }
  98. count += 4U;
  99. /* Decrement the loop counter */
  100. blkCnt--;
  101. }
  102. /* if (blockSize - 1U) is not multiple of 4 */
  103. blkCnt = (blockSize - 1U) % 4U;
  104. #else
  105. /* Run the below code for Cortex-M0 */
  106. q31_t minVal1, out; /* Temporary variables to store the output value. */
  107. uint32_t blkCnt, outIndex; /* loop counter */
  108. /* Initialise the index value to zero. */
  109. outIndex = 0U;
  110. /* Load first input value that act as reference value for comparision */
  111. out = *pSrc++;
  112. blkCnt = (blockSize - 1U);
  113. #endif /* #if defined (ARM_MATH_DSP) */
  114. while (blkCnt > 0U)
  115. {
  116. /* Initialize minVal to the next consecutive values one by one */
  117. minVal1 = *pSrc++;
  118. /* compare for the minimum value */
  119. if (out > minVal1)
  120. {
  121. /* Update the minimum value and it's index */
  122. out = minVal1;
  123. outIndex = blockSize - blkCnt;
  124. }
  125. /* Decrement the loop counter */
  126. blkCnt--;
  127. }
  128. /* Store the minimum value and it's index into destination pointers */
  129. *pResult = out;
  130. *pIndex = outIndex;
  131. }
  132. /**
  133. * @} end of Min group
  134. */