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 
29 #include "dsp/statistics_functions.h"
30 
31 /**
32   @ingroup groupStats
33  */
34 
35 
36 /**
37   @addtogroup Max
38   @{
39  */
40 
41 /**
42   @brief         Maximum value of a floating-point vector.
43   @param[in]     pSrc       points to the input vector
44   @param[in]     blockSize  number of samples in input vector
45   @param[out]    pResult    maximum value returned here
46  */
47 #if defined(ARM_MATH_NEON) && defined(__aarch64__)
arm_max_no_idx_f64(const float64_t * pSrc,uint32_t blockSize,float64_t * pResult)48 ARM_DSP_ATTRIBUTE void arm_max_no_idx_f64(
49     const float64_t * pSrc,
50     uint32_t blockSize,
51     float64_t * pResult)
52 {
53     float64_t maxVal , in;                         /* Temporary variables to store the output value. */
54     uint32_t blkCnt;                     /* Loop counter */
55 
56     float64x2_t maxV;
57     float64x2_t pSrcV ;
58     pSrcV = vld1q_f64(pSrc);
59     pSrc += 2 ;
60     maxV = pSrcV;
61 
62 
63 
64 
65     /* Load first input value that act as reference value for comparision */
66 
67 
68     /* Initialize blkCnt with number of samples */
69     blkCnt = (blockSize - 2U) >> 1U;
70 
71     while (blkCnt > 0U)
72     {
73         /* Initialize maxVal to the next consecutive values one by one */
74         pSrcV = vld1q_f64(pSrc);
75         maxV = vmaxq_f64(maxV, pSrcV);
76 
77         pSrc += 2 ;
78 
79         /* Decrement loop counter */
80         blkCnt--;
81     }
82     maxVal =vgetq_lane_f64(maxV, 0);
83     if(maxVal < vgetq_lane_f64(maxV, 1))
84     {
85         maxVal = vgetq_lane_f64(maxV, 1);
86     }
87     blkCnt = (blockSize - 2U) & 1;
88 
89     while (blkCnt > 0U)
90     {
91         /* Initialize maxVal to the next consecutive values one by one */
92         in = *pSrc++;
93 
94         /* compare for the maximum value */
95         if (maxVal < in)
96         {
97             /* Update the maximum value and it's index */
98             maxVal = in;
99         }
100 
101         /* Decrement loop counter */
102         blkCnt--;
103     }
104     *pResult = maxVal;
105 
106 
107     /* Store the maximum value and it's index into destination pointers */
108 
109 }
110 #else
arm_max_no_idx_f64(const float64_t * pSrc,uint32_t blockSize,float64_t * pResult)111 ARM_DSP_ATTRIBUTE void arm_max_no_idx_f64(
112     const float64_t *pSrc,
113     uint32_t   blockSize,
114     float64_t *pResult)
115 {
116     float64_t   maxValue = F64_MIN;
117     float64_t   newVal;
118 
119     while (blockSize > 0U)
120     {
121         newVal = *pSrc++;
122 
123         /* compare for the maximum value */
124         if (maxValue < newVal)
125         {
126             /* Update the maximum value and it's index */
127             maxValue = newVal;
128         }
129 
130         blockSize --;
131     }
132 
133     *pResult = maxValue;
134 }
135 #endif
136 
137 /**
138   @} end of Max group
139  */
140