arm_max_no_idx_f64.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_max_no_idx_f64.c
  4. * Description: Maximum value of a floating-point vector without returning the index
  5. *
  6. * $Date: 10 August 2022
  7. * $Revision: V1.10.1
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2021 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 "dsp/statistics_functions.h"
  29. /**
  30. @ingroup groupStats
  31. */
  32. /**
  33. @addtogroup Max
  34. @{
  35. */
  36. /**
  37. @brief Maximum value of a floating-point vector.
  38. @param[in] pSrc points to the input vector
  39. @param[in] blockSize number of samples in input vector
  40. @param[out] pResult maximum value returned here
  41. */
  42. #if defined(ARM_MATH_NEON) && defined(__aarch64__)
  43. void arm_max_no_idx_f64(
  44. const float64_t * pSrc,
  45. uint32_t blockSize,
  46. float64_t * pResult)
  47. {
  48. float64_t maxVal , in; /* Temporary variables to store the output value. */
  49. uint32_t blkCnt; /* Loop counter */
  50. float64x2_t maxV;
  51. float64x2_t pSrcV ;
  52. pSrcV = vld1q_f64(pSrc);
  53. pSrc += 2 ;
  54. maxV = pSrcV;
  55. /* Load first input value that act as reference value for comparision */
  56. /* Initialize blkCnt with number of samples */
  57. blkCnt = (blockSize - 2U) >> 1U;
  58. while (blkCnt > 0U)
  59. {
  60. /* Initialize maxVal to the next consecutive values one by one */
  61. pSrcV = vld1q_f64(pSrc);
  62. maxV = vmaxq_f64(maxV, pSrcV);
  63. pSrc += 2 ;
  64. /* Decrement loop counter */
  65. blkCnt--;
  66. }
  67. maxVal =vgetq_lane_f64(maxV, 0);
  68. if(maxVal < vgetq_lane_f64(maxV, 1))
  69. {
  70. maxVal = vgetq_lane_f64(maxV, 1);
  71. }
  72. blkCnt = (blockSize - 2U) & 1;
  73. while (blkCnt > 0U)
  74. {
  75. /* Initialize maxVal to the next consecutive values one by one */
  76. in = *pSrc++;
  77. /* compare for the maximum value */
  78. if (maxVal < in)
  79. {
  80. /* Update the maximum value and it's index */
  81. maxVal = in;
  82. }
  83. /* Decrement loop counter */
  84. blkCnt--;
  85. }
  86. *pResult = maxVal;
  87. /* Store the maximum value and it's index into destination pointers */
  88. }
  89. #else
  90. void arm_max_no_idx_f64(
  91. const float64_t *pSrc,
  92. uint32_t blockSize,
  93. float64_t *pResult)
  94. {
  95. float64_t maxValue = F64_MIN;
  96. float64_t newVal;
  97. while (blockSize > 0U)
  98. {
  99. newVal = *pSrc++;
  100. /* compare for the maximum value */
  101. if (maxValue < newVal)
  102. {
  103. /* Update the maximum value and it's index */
  104. maxValue = newVal;
  105. }
  106. blockSize --;
  107. }
  108. *pResult = maxValue;
  109. }
  110. #endif
  111. /**
  112. @} end of Max group
  113. */