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