matrix_functions_f16.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /******************************************************************************
  2. * @file matrix_functions_f16.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: Cortex-M and Cortex-A cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. *
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the License); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. #ifndef _MATRIX_FUNCTIONS_F16_H_
  26. #define _MATRIX_FUNCTIONS_F16_H_
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. #include "arm_math_types_f16.h"
  32. #include "arm_math_memory.h"
  33. #include "dsp/none.h"
  34. #include "dsp/utils.h"
  35. #if defined(ARM_FLOAT16_SUPPORTED)
  36. /**
  37. * @brief Instance structure for the floating-point matrix structure.
  38. */
  39. typedef struct
  40. {
  41. uint16_t numRows; /**< number of rows of the matrix. */
  42. uint16_t numCols; /**< number of columns of the matrix. */
  43. float16_t *pData; /**< points to the data of the matrix. */
  44. } arm_matrix_instance_f16;
  45. /**
  46. * @brief Floating-point matrix addition.
  47. * @param[in] pSrcA points to the first input matrix structure
  48. * @param[in] pSrcB points to the second input matrix structure
  49. * @param[out] pDst points to output matrix structure
  50. * @return The function returns either
  51. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  52. */
  53. arm_status arm_mat_add_f16(
  54. const arm_matrix_instance_f16 * pSrcA,
  55. const arm_matrix_instance_f16 * pSrcB,
  56. arm_matrix_instance_f16 * pDst);
  57. /**
  58. * @brief Floating-point, complex, matrix multiplication.
  59. * @param[in] pSrcA points to the first input matrix structure
  60. * @param[in] pSrcB points to the second input matrix structure
  61. * @param[out] pDst points to output matrix structure
  62. * @return The function returns either
  63. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  64. */
  65. arm_status arm_mat_cmplx_mult_f16(
  66. const arm_matrix_instance_f16 * pSrcA,
  67. const arm_matrix_instance_f16 * pSrcB,
  68. arm_matrix_instance_f16 * pDst);
  69. /**
  70. * @brief Floating-point matrix transpose.
  71. * @param[in] pSrc points to the input matrix
  72. * @param[out] pDst points to the output matrix
  73. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  74. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  75. */
  76. arm_status arm_mat_trans_f16(
  77. const arm_matrix_instance_f16 * pSrc,
  78. arm_matrix_instance_f16 * pDst);
  79. /**
  80. * @brief Floating-point complex matrix transpose.
  81. * @param[in] pSrc points to the input matrix
  82. * @param[out] pDst points to the output matrix
  83. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  84. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  85. */
  86. arm_status arm_mat_cmplx_trans_f16(
  87. const arm_matrix_instance_f16 * pSrc,
  88. arm_matrix_instance_f16 * pDst);
  89. /**
  90. * @brief Floating-point matrix multiplication
  91. * @param[in] pSrcA points to the first input matrix structure
  92. * @param[in] pSrcB points to the second input matrix structure
  93. * @param[out] pDst points to output matrix structure
  94. * @return The function returns either
  95. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  96. */
  97. arm_status arm_mat_mult_f16(
  98. const arm_matrix_instance_f16 * pSrcA,
  99. const arm_matrix_instance_f16 * pSrcB,
  100. arm_matrix_instance_f16 * pDst);
  101. /**
  102. * @brief Floating-point matrix and vector multiplication
  103. * @param[in] pSrcMat points to the input matrix structure
  104. * @param[in] pVec points to vector
  105. * @param[out] pDst points to output vector
  106. */
  107. void arm_mat_vec_mult_f16(
  108. const arm_matrix_instance_f16 *pSrcMat,
  109. const float16_t *pVec,
  110. float16_t *pDst);
  111. /**
  112. * @brief Floating-point matrix subtraction
  113. * @param[in] pSrcA points to the first input matrix structure
  114. * @param[in] pSrcB points to the second input matrix structure
  115. * @param[out] pDst points to output matrix structure
  116. * @return The function returns either
  117. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  118. */
  119. arm_status arm_mat_sub_f16(
  120. const arm_matrix_instance_f16 * pSrcA,
  121. const arm_matrix_instance_f16 * pSrcB,
  122. arm_matrix_instance_f16 * pDst);
  123. /**
  124. * @brief Floating-point matrix scaling.
  125. * @param[in] pSrc points to the input matrix
  126. * @param[in] scale scale factor
  127. * @param[out] pDst points to the output matrix
  128. * @return The function returns either
  129. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  130. */
  131. arm_status arm_mat_scale_f16(
  132. const arm_matrix_instance_f16 * pSrc,
  133. float16_t scale,
  134. arm_matrix_instance_f16 * pDst);
  135. /**
  136. * @brief Floating-point matrix initialization.
  137. * @param[in,out] S points to an instance of the floating-point matrix structure.
  138. * @param[in] nRows number of rows in the matrix.
  139. * @param[in] nColumns number of columns in the matrix.
  140. * @param[in] pData points to the matrix data array.
  141. */
  142. void arm_mat_init_f16(
  143. arm_matrix_instance_f16 * S,
  144. uint16_t nRows,
  145. uint16_t nColumns,
  146. float16_t * pData);
  147. /**
  148. * @brief Floating-point matrix inverse.
  149. * @param[in] src points to the instance of the input floating-point matrix structure.
  150. * @param[out] dst points to the instance of the output floating-point matrix structure.
  151. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  152. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  153. */
  154. arm_status arm_mat_inverse_f16(
  155. const arm_matrix_instance_f16 * src,
  156. arm_matrix_instance_f16 * dst);
  157. /**
  158. * @brief Floating-point Cholesky decomposition of Symmetric Positive Definite Matrix.
  159. * @param[in] src points to the instance of the input floating-point matrix structure.
  160. * @param[out] dst points to the instance of the output floating-point matrix structure.
  161. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  162. * If the input matrix does not have a decomposition, then the algorithm terminates and returns error status ARM_MATH_DECOMPOSITION_FAILURE.
  163. * If the matrix is ill conditioned or only semi-definite, then it is better using the LDL^t decomposition.
  164. * The decomposition is returning a lower triangular matrix.
  165. */
  166. arm_status arm_mat_cholesky_f16(
  167. const arm_matrix_instance_f16 * src,
  168. arm_matrix_instance_f16 * dst);
  169. /**
  170. * @brief Solve UT . X = A where UT is an upper triangular matrix
  171. * @param[in] ut The upper triangular matrix
  172. * @param[in] a The matrix a
  173. * @param[out] dst The solution X of UT . X = A
  174. * @return The function returns ARM_MATH_SINGULAR, if the system can't be solved.
  175. */
  176. arm_status arm_mat_solve_upper_triangular_f16(
  177. const arm_matrix_instance_f16 * ut,
  178. const arm_matrix_instance_f16 * a,
  179. arm_matrix_instance_f16 * dst);
  180. /**
  181. * @brief Solve LT . X = A where LT is a lower triangular matrix
  182. * @param[in] lt The lower triangular matrix
  183. * @param[in] a The matrix a
  184. * @param[out] dst The solution X of LT . X = A
  185. * @return The function returns ARM_MATH_SINGULAR, if the system can't be solved.
  186. */
  187. arm_status arm_mat_solve_lower_triangular_f16(
  188. const arm_matrix_instance_f16 * lt,
  189. const arm_matrix_instance_f16 * a,
  190. arm_matrix_instance_f16 * dst);
  191. #endif /*defined(ARM_FLOAT16_SUPPORTED)*/
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. #endif /* ifndef _MATRIX_FUNCTIONS_F16_H_ */