arm_f64_to_f16.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_f64_to_f16.c
  4. * Description: Converts the elements of the 64 bit floating-point vector to 16 bit floating-point vector
  5. *
  6. * $Date: 18 August 2022
  7. * $Revision: V1.0.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2022 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/support_functions_f16.h"
  29. #if defined(ARM_FLOAT16_SUPPORTED)
  30. /**
  31. @ingroup groupSupport
  32. */
  33. /**
  34. * @defgroup f64_to_x Convert 64-bit floating point value
  35. */
  36. /**
  37. @addtogroup f64_to_x
  38. @{
  39. */
  40. /**
  41. @brief Converts the elements of the f64 vector to f16 vector.
  42. @param[in] pSrc points to the f64 input vector
  43. @param[out] pDst points to the f16 output vector
  44. @param[in] blockSize number of samples in each vector
  45. */
  46. void arm_f64_to_f16(
  47. const float64_t * pSrc,
  48. float16_t * pDst,
  49. uint32_t blockSize)
  50. {
  51. const float64_t *pIn = pSrc; /* Src pointer */
  52. uint32_t blkCnt; /* loop counter */
  53. /*
  54. * Loop over blockSize number of values
  55. */
  56. blkCnt = blockSize;
  57. while (blkCnt > 0U)
  58. {
  59. *pDst++ = (float16_t) * pIn++;
  60. /*
  61. * Decrement the loop counter
  62. */
  63. blkCnt--;
  64. }
  65. }
  66. /**
  67. @} end of f64_to_x group
  68. */
  69. #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */