forked from ARM-software/CMSIS_5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMSIS-DSP: Added scalar version of clipping functions.
- Loading branch information
1 parent
b966796
commit 3ecf087
Showing
43 changed files
with
1,606 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ | |
#include "arm_offset_f16.c" | ||
#include "arm_scale_f16.c" | ||
#include "arm_sub_f16.c" | ||
#include "arm_clip_f16.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* ---------------------------------------------------------------------- | ||
* Project: CMSIS DSP Library | ||
* Title: arm_clip_f16.c | ||
* Description: Floating-point vector addition | ||
* | ||
* | ||
* Target Processor: Cortex-M cores | ||
* -------------------------------------------------------------------- */ | ||
/* | ||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the License); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "dsp/basic_math_functions_f16.h" | ||
|
||
/** | ||
@ingroup groupMath | ||
*/ | ||
|
||
|
||
/** | ||
@addtogroup BasicClip | ||
@{ | ||
*/ | ||
|
||
/** | ||
@brief Elementwise floating-point clipping | ||
@param[in] pSrc points to input values | ||
@param[out] pDst points to output clipped values | ||
@param[in] low lower bound | ||
@param[in] high higher bound | ||
@param[in] numSamples number of samples to clip | ||
@return none | ||
*/ | ||
|
||
#if defined(ARM_FLOAT16_SUPPORTED) | ||
|
||
void arm_clip_f16(const float16_t * pSrc, | ||
float16_t * pDst, | ||
float16_t low, | ||
float16_t high, | ||
uint32_t numSamples) | ||
{ | ||
for (uint32_t i = 0; i < numSamples; i++) | ||
{ | ||
if (pSrc[i] > high) | ||
pDst[i] = high; | ||
else if (pSrc[i] < low) | ||
pDst[i] = low; | ||
else | ||
pDst[i] = pSrc[i]; | ||
} | ||
} | ||
#endif /* defined(ARM_FLOAT16_SUPPORTED */ | ||
|
||
/** | ||
@} end of BasicClip group | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* ---------------------------------------------------------------------- | ||
* Project: CMSIS DSP Library | ||
* Title: arm_clip_f32.c | ||
* Description: Floating-point vector addition | ||
* | ||
* | ||
* Target Processor: Cortex-M cores | ||
* -------------------------------------------------------------------- */ | ||
/* | ||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the License); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "dsp/basic_math_functions.h" | ||
|
||
/** | ||
@ingroup groupMath | ||
*/ | ||
|
||
/** | ||
@defgroup BasicClip Elementwise clipping | ||
Element-by-element clipping of a value. | ||
The value is constrained between 2 bounds. | ||
There are separate functions for floating-point, Q7, Q15, and Q31 data types. | ||
*/ | ||
|
||
/** | ||
@addtogroup BasicClip | ||
@{ | ||
*/ | ||
|
||
/** | ||
@brief Elementwise floating-point clipping | ||
@param[in] pSrc points to input values | ||
@param[out] pDst points to output clipped values | ||
@param[in] low lower bound | ||
@param[in] high higher bound | ||
@param[in] numSamples number of samples to clip | ||
@return none | ||
*/ | ||
|
||
void arm_clip_f32(const float32_t * pSrc, | ||
float32_t * pDst, | ||
float32_t low, | ||
float32_t high, | ||
uint32_t numSamples) | ||
{ | ||
for (uint32_t i = 0; i < numSamples; i++) | ||
{ | ||
if (pSrc[i] > high) | ||
pDst[i] = high; | ||
else if (pSrc[i] < low) | ||
pDst[i] = low; | ||
else | ||
pDst[i] = pSrc[i]; | ||
} | ||
} | ||
|
||
/** | ||
@} end of BasicClip group | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* ---------------------------------------------------------------------- | ||
* Project: CMSIS DSP Library | ||
* Title: arm_clip_q15.c | ||
* Description: Floating-point vector addition | ||
* | ||
* | ||
* Target Processor: Cortex-M cores | ||
* -------------------------------------------------------------------- */ | ||
/* | ||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the License); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "dsp/basic_math_functions.h" | ||
|
||
/** | ||
@ingroup groupMath | ||
*/ | ||
|
||
|
||
/** | ||
@addtogroup BasicClip | ||
@{ | ||
*/ | ||
|
||
/** | ||
@brief Elementwise fixed-point clipping | ||
@param[in] pSrc points to input values | ||
@param[out] pDst points to output clipped values | ||
@param[in] low lower bound | ||
@param[in] high higher bound | ||
@param[in] numSamples number of samples to clip | ||
@return none | ||
*/ | ||
|
||
void arm_clip_q15(const q15_t * pSrc, | ||
q15_t * pDst, | ||
q15_t low, | ||
q15_t high, | ||
uint32_t numSamples) | ||
{ | ||
for (uint32_t i = 0; i < numSamples; i++) | ||
{ | ||
if (pSrc[i] > high) | ||
pDst[i] = high; | ||
else if (pSrc[i] < low) | ||
pDst[i] = low; | ||
else | ||
pDst[i] = pSrc[i]; | ||
} | ||
} | ||
|
||
/** | ||
@} end of BasicClip group | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* ---------------------------------------------------------------------- | ||
* Project: CMSIS DSP Library | ||
* Title: arm_clip_q31.c | ||
* Description: Floating-point vector addition | ||
* | ||
* | ||
* Target Processor: Cortex-M cores | ||
* -------------------------------------------------------------------- */ | ||
/* | ||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the License); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "dsp/basic_math_functions.h" | ||
|
||
/** | ||
@ingroup groupMath | ||
*/ | ||
|
||
|
||
/** | ||
@addtogroup BasicClip | ||
@{ | ||
*/ | ||
|
||
/** | ||
@brief Elementwise fixed-point clipping | ||
@param[in] pSrc points to input values | ||
@param[out] pDst points to output clipped values | ||
@param[in] low lower bound | ||
@param[in] high higher bound | ||
@param[in] numSamples number of samples to clip | ||
@return none | ||
*/ | ||
|
||
void arm_clip_q31(const q31_t * pSrc, | ||
q31_t * pDst, | ||
q31_t low, | ||
q31_t high, | ||
uint32_t numSamples) | ||
{ | ||
for (uint32_t i = 0; i < numSamples; i++) | ||
{ | ||
if (pSrc[i] > high) | ||
pDst[i] = high; | ||
else if (pSrc[i] < low) | ||
pDst[i] = low; | ||
else | ||
pDst[i] = pSrc[i]; | ||
} | ||
} | ||
|
||
/** | ||
@} end of BasicClip group | ||
*/ |
Oops, something went wrong.