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