1 /******************************************************************************
2  * @file     matrix_functions_f16.h
3  * @brief    Public header file for CMSIS DSP Library
4  * @version  V1.9.0
5  * @date     23 April 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 
26 
27 #ifndef _MATRIX_FUNCTIONS_F16_H_
28 #define _MATRIX_FUNCTIONS_F16_H_
29 
30 #ifdef   __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 
36 #include "arm_math_types_f16.h"
37 #include "arm_math_memory.h"
38 
39 #include "dsp/none.h"
40 #include "dsp/utils.h"
41 
42 #if defined(ARM_FLOAT16_SUPPORTED)
43 
44  /**
45    * @brief Instance structure for the floating-point matrix structure.
46    */
47   typedef struct
48   {
49     uint16_t numRows;     /**< number of rows of the matrix.     */
50     uint16_t numCols;     /**< number of columns of the matrix.  */
51     float16_t *pData;     /**< points to the data of the matrix. */
52   } arm_matrix_instance_f16;
53 
54  /**
55    * @brief Floating-point matrix addition.
56    * @param[in]  pSrcA  points to the first input matrix structure
57    * @param[in]  pSrcB  points to the second input matrix structure
58    * @param[out] pDst   points to output matrix structure
59    * @return     The function returns either
60    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
61    */
62 arm_status arm_mat_add_f16(
63   const arm_matrix_instance_f16 * pSrcA,
64   const arm_matrix_instance_f16 * pSrcB,
65         arm_matrix_instance_f16 * pDst);
66 
67   /**
68    * @brief Floating-point, complex, matrix multiplication.
69    * @param[in]  pSrcA  points to the first input matrix structure
70    * @param[in]  pSrcB  points to the second input matrix structure
71    * @param[out] pDst   points to output matrix structure
72    * @return     The function returns either
73    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
74    */
75 arm_status arm_mat_cmplx_mult_f16(
76   const arm_matrix_instance_f16 * pSrcA,
77   const arm_matrix_instance_f16 * pSrcB,
78         arm_matrix_instance_f16 * pDst);
79 
80   /**
81    * @brief Floating-point matrix transpose.
82    * @param[in]  pSrc  points to the input matrix
83    * @param[out] pDst  points to the output matrix
84    * @return    The function returns either  <code>ARM_MATH_SIZE_MISMATCH</code>
85    * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
86    */
87 arm_status arm_mat_trans_f16(
88   const arm_matrix_instance_f16 * pSrc,
89         arm_matrix_instance_f16 * pDst);
90 
91   /**
92    * @brief Floating-point complex matrix transpose.
93    * @param[in]  pSrc  points to the input matrix
94    * @param[out] pDst  points to the output matrix
95    * @return    The function returns either  <code>ARM_MATH_SIZE_MISMATCH</code>
96    * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
97    */
98 arm_status arm_mat_cmplx_trans_f16(
99   const arm_matrix_instance_f16 * pSrc,
100   arm_matrix_instance_f16 * pDst);
101 
102   /**
103    * @brief Floating-point matrix multiplication
104    * @param[in]  pSrcA  points to the first input matrix structure
105    * @param[in]  pSrcB  points to the second input matrix structure
106    * @param[out] pDst   points to output matrix structure
107    * @return     The function returns either
108    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
109    */
110 arm_status arm_mat_mult_f16(
111   const arm_matrix_instance_f16 * pSrcA,
112   const arm_matrix_instance_f16 * pSrcB,
113         arm_matrix_instance_f16 * pDst);
114   /**
115    * @brief Floating-point matrix and vector multiplication
116    * @param[in]  pSrcMat  points to the input matrix structure
117    * @param[in]  pVec     points to vector
118    * @param[out] pDst     points to output vector
119    */
120 void arm_mat_vec_mult_f16(
121   const arm_matrix_instance_f16 *pSrcMat,
122   const float16_t *pVec,
123   float16_t *pDst);
124 
125   /**
126    * @brief Floating-point matrix subtraction
127    * @param[in]  pSrcA  points to the first input matrix structure
128    * @param[in]  pSrcB  points to the second input matrix structure
129    * @param[out] pDst   points to output matrix structure
130    * @return     The function returns either
131    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
132    */
133 arm_status arm_mat_sub_f16(
134   const arm_matrix_instance_f16 * pSrcA,
135   const arm_matrix_instance_f16 * pSrcB,
136         arm_matrix_instance_f16 * pDst);
137 
138   /**
139    * @brief Floating-point matrix scaling.
140    * @param[in]  pSrc   points to the input matrix
141    * @param[in]  scale  scale factor
142    * @param[out] pDst   points to the output matrix
143    * @return     The function returns either
144    * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
145    */
146 arm_status arm_mat_scale_f16(
147   const arm_matrix_instance_f16 * pSrc,
148         float16_t scale,
149         arm_matrix_instance_f16 * pDst);
150 
151   /**
152    * @brief  Floating-point matrix initialization.
153    * @param[in,out] S         points to an instance of the floating-point matrix structure.
154    * @param[in]     nRows     number of rows in the matrix.
155    * @param[in]     nColumns  number of columns in the matrix.
156    * @param[in]     pData     points to the matrix data array.
157    */
158 void arm_mat_init_f16(
159         arm_matrix_instance_f16 * S,
160         uint16_t nRows,
161         uint16_t nColumns,
162         float16_t * pData);
163 
164 
165   /**
166    * @brief Floating-point matrix inverse.
167    * @param[in]  src   points to the instance of the input floating-point matrix structure.
168    * @param[out] dst   points to the instance of the output floating-point matrix structure.
169    * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
170    * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
171    */
172   arm_status arm_mat_inverse_f16(
173   const arm_matrix_instance_f16 * src,
174   arm_matrix_instance_f16 * dst);
175 
176 
177  /**
178    * @brief Floating-point Cholesky decomposition of Symmetric Positive Definite Matrix.
179    * @param[in]  src   points to the instance of the input floating-point matrix structure.
180    * @param[out] dst   points to the instance of the output floating-point matrix structure.
181    * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
182    * If the input matrix does not have a decomposition, then the algorithm terminates and returns error status ARM_MATH_DECOMPOSITION_FAILURE.
183    * If the matrix is ill conditioned or only semi-definite, then it is better using the LDL^t decomposition.
184    * The decomposition is returning a lower triangular matrix.
185    */
186   arm_status arm_mat_cholesky_f16(
187   const arm_matrix_instance_f16 * src,
188   arm_matrix_instance_f16 * dst);
189 
190  /**
191    * @brief Solve UT . X = A where UT is an upper triangular matrix
192    * @param[in]  ut  The upper triangular matrix
193    * @param[in]  a  The matrix a
194    * @param[out] dst The solution X of UT . X = A
195    * @return The function returns ARM_MATH_SINGULAR, if the system can't be solved.
196   */
197   arm_status arm_mat_solve_upper_triangular_f16(
198   const arm_matrix_instance_f16 * ut,
199   const arm_matrix_instance_f16 * a,
200   arm_matrix_instance_f16 * dst);
201 
202  /**
203    * @brief Solve LT . X = A where LT is a lower triangular matrix
204    * @param[in]  lt  The lower triangular matrix
205    * @param[in]  a  The matrix a
206    * @param[out] dst The solution X of LT . X = A
207    * @return The function returns ARM_MATH_SINGULAR, if the system can't be solved.
208    */
209   arm_status arm_mat_solve_lower_triangular_f16(
210   const arm_matrix_instance_f16 * lt,
211   const arm_matrix_instance_f16 * a,
212   arm_matrix_instance_f16 * dst);
213 
214 
215 
216 #endif /*defined(ARM_FLOAT16_SUPPORTED)*/
217 #ifdef   __cplusplus
218 }
219 #endif
220 
221 #endif /* ifndef _MATRIX_FUNCTIONS_F16_H_ */
222