arm_copy_f32.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_copy_f32.c
  4. * Description: Copies the elements of a floating-point vector
  5. *
  6. * $Date: 18. March 2019
  7. * $Revision: V1.6.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 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 "arm_math.h"
  29. /**
  30. @ingroup groupSupport
  31. */
  32. /**
  33. @defgroup copy Vector Copy
  34. Copies sample by sample from source vector to destination vector.
  35. <pre>
  36. pDst[n] = pSrc[n]; 0 <= n < blockSize.
  37. </pre>
  38. There are separate functions for floating point, Q31, Q15, and Q7 data types.
  39. */
  40. /**
  41. @addtogroup copy
  42. @{
  43. */
  44. /**
  45. @brief Copies the elements of a floating-point vector.
  46. @param[in] pSrc points to input vector
  47. @param[out] pDst points to output vector
  48. @param[in] blockSize number of samples in each vector
  49. @return none
  50. */
  51. #if defined(ARM_MATH_NEON_EXPERIMENTAL)
  52. void arm_copy_f32(
  53. const float32_t * pSrc,
  54. float32_t * pDst,
  55. uint32_t blockSize)
  56. {
  57. uint32_t blkCnt; /* loop counter */
  58. float32x4_t inV;
  59. blkCnt = blockSize >> 2U;
  60. /* Compute 4 outputs at a time.
  61. ** a second loop below computes the remaining 1 to 3 samples. */
  62. while (blkCnt > 0U)
  63. {
  64. /* C = A */
  65. /* Copy and then store the results in the destination buffer */
  66. inV = vld1q_f32(pSrc);
  67. vst1q_f32(pDst, inV);
  68. pSrc += 4;
  69. pDst += 4;
  70. /* Decrement the loop counter */
  71. blkCnt--;
  72. }
  73. /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
  74. ** No loop unrolling is used. */
  75. blkCnt = blockSize & 3;
  76. while (blkCnt > 0U)
  77. {
  78. /* C = A */
  79. /* Copy and then store the results in the destination buffer */
  80. *pDst++ = *pSrc++;
  81. /* Decrement the loop counter */
  82. blkCnt--;
  83. }
  84. }
  85. #else
  86. void arm_copy_f32(
  87. const float32_t * pSrc,
  88. float32_t * pDst,
  89. uint32_t blockSize)
  90. {
  91. uint32_t blkCnt; /* Loop counter */
  92. #if defined (ARM_MATH_LOOPUNROLL)
  93. /* Loop unrolling: Compute 4 outputs at a time */
  94. blkCnt = blockSize >> 2U;
  95. while (blkCnt > 0U)
  96. {
  97. /* C = A */
  98. /* Copy and store result in destination buffer */
  99. *pDst++ = *pSrc++;
  100. *pDst++ = *pSrc++;
  101. *pDst++ = *pSrc++;
  102. *pDst++ = *pSrc++;
  103. /* Decrement loop counter */
  104. blkCnt--;
  105. }
  106. /* Loop unrolling: Compute remaining outputs */
  107. blkCnt = blockSize % 0x4U;
  108. #else
  109. /* Initialize blkCnt with number of samples */
  110. blkCnt = blockSize;
  111. #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
  112. while (blkCnt > 0U)
  113. {
  114. /* C = A */
  115. /* Copy and store result in destination buffer */
  116. *pDst++ = *pSrc++;
  117. /* Decrement loop counter */
  118. blkCnt--;
  119. }
  120. }
  121. #endif /* #if defined(ARM_MATH_NEON) */
  122. /**
  123. @} end of BasicCopy group
  124. */