Functions | |
| static void | hpm_dsp_mat_add_f32 (const float32_t *src1, const float32_t *src2, float32_t *dst, uint32_t row, uint32_t col) |
| Addition of two floating-potint matrices. More... | |
| static void | hpm_dsp_mat_add_f64 (const float64_t *src1, const float64_t *src2, float64_t *dst, uint32_t row, uint32_t col) |
| Addition of two floating-potint matrices. More... | |
| static void | hpm_dsp_mat_add_q15 (const q15_t *src1, const q15_t *src2, q15_t *dst, uint32_t row, uint32_t col) |
| Addition of two q15 matrices. More... | |
| static void | hpm_dsp_mat_add_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t row, uint32_t col) |
| Addition of two q31 matrices. More... | |
| static int32_t | hpm_dsp_mat_inv_f32 (float32_t *src, float32_t *dst, uint32_t size) |
| Compute the inverse matrix of the floating-potint matrix. More... | |
| static int32_t | hpm_dsp_mat_inv_f64 (float64_t *src, float64_t *dst, uint32_t size) |
| static void | hpm_dsp_mat_mul_f32 (const float32_t *src1, const float32_t *src2, float32_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two floating-point matrices. More... | |
| static void | hpm_dsp_mat_mul_f64 (const float64_t *src1, const float64_t *src2, float64_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| static void | hpm_dsp_cmat_mul_f32 (const float32_t *src1, const float32_t *src2, float32_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two floating-point complex matrices. More... | |
| static void | hpm_dsp_mat_mul_q15 (const q15_t *src1, const q15_t *src2, q15_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two q15 matrices. More... | |
| static void | hpm_dsp_mat_mul_fast_q15 (const q15_t *src1, const q15_t *src2, q15_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| static void | hpm_dsp_cmat_mul_q15 (const q15_t *src1, const q15_t *src2, q15_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two q15 complex matrices. More... | |
| static void | hpm_dsp_mat_mul_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two q31 matrices. More... | |
| static void | hpm_dsp_mat_mul_fast_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| static void | hpm_dsp_cmat_mul_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two q31 complex matrices. More... | |
| static void | hpm_dsp_mat_mul_q7 (const q7_t *src1, const q7_t *src2, q7_t *dst, uint32_t row, uint32_t col, uint32_t col2) |
| Multiplication of two q7 matrices. More... | |
| static void | hpm_dsp_mat_mul_vxm_q7 (const q7_t *src1, const q7_t *src2, q7_t *dst, uint32_t col, uint32_t col2) |
| Multiplication of q7 vetor by matrix. More... | |
| static int32_t | hpm_dsp_mat_pwr2_cache_f64 (const float64_t *src, float64_t *dst, uint32_t size) |
| static void | hpm_dsp_mat_scale_f32 (const float32_t *src, float32_t scale, float32_t *dst, uint32_t row, uint32_t col) |
| Multiplt a scale value of floating-potint matrix. More... | |
| static void | hpm_dsp_mat_scale_q15 (const q15_t *src, q15_t scale_fract, int32_t shift, q15_t *dst, uint32_t row, uint32_t col) |
| Multiplt a scale value of q15 matrix. More... | |
| static void | hpm_dsp_mat_scale_q31 (const q31_t *src, q31_t scale_fract, int32_t shift, q31_t *dst, uint32_t row, uint32_t col) |
| Multiplt a scale value of q31 matrix. More... | |
| static void | hpm_dsp_mat_sub_f64 (const float64_t *src1, const float64_t *src2, float64_t *dst, uint32_t row, uint32_t col) |
| Substraction of two double-precision floating-potint matrices. More... | |
| static void | hpm_dsp_mat_sub_f32 (const float32_t *src1, const float32_t *src2, float32_t *dst, uint32_t row, uint32_t col) |
| Substraction of two floating-potint matrices. More... | |
| static void | hpm_dsp_mat_sub_q15 (const q15_t *src1, const q15_t *src2, q15_t *dst, uint32_t row, uint32_t col) |
| Substraction of two q15 matrices. More... | |
| static void | hpm_dsp_mat_sub_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t row, uint32_t col) |
| Substraction of two q31 matrices. More... | |
| static void | hpm_dsp_mat_trans_f64 (const float64_t *src, float64_t *dst, uint32_t row, uint32_t col) |
| Transpose the double-precision floating-potint matrices. More... | |
| static void | hpm_dsp_mat_trans_f32 (const float32_t *src, float32_t *dst, uint32_t row, uint32_t col) |
| Transpose the floating-potint matricex. More... | |
| static void | hpm_dsp_mat_trans_q15 (const q15_t *src, q15_t *dst, uint32_t row, uint32_t col) |
| Transpose the q15 matricex. More... | |
| static void | hpm_dsp_mat_trans_q31 (const q31_t *src, q31_t *dst, uint32_t row, uint32_t col) |
| Transpose the q31 matricex. More... | |
| static void | hpm_dsp_mat_trans_u8 (const uint8_t *src, uint8_t *dst, uint32_t row, uint32_t col) |
| Transpose the u8 matricex. More... | |
| static void | hpm_dsp_mat_trans_q7 (const q7_t *src, q7_t *dst, uint32_t row, uint32_t col) |
| Transpose the q7 matrices. More... | |
| static void | hpm_dsp_mat_oprod_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t size1, uint32_t size2) |
| Outer production of two q31 matrices. More... | |
| static void | hpm_dsp_mat_mul_mxv_f32 (const float32_t *src1, const float32_t *src2, float32_t *dst, uint32_t row, uint32_t col) |
| Matrix multiply vector for f32 formats. More... | |
| static void | hpm_dsp_mat_mul_mxv_q15 (const q15_t *src1, const q15_t *src2, q15_t *dst, uint32_t row, uint32_t col) |
| Matrix multiply vector for q15 formats. More... | |
| static void | hpm_dsp_mat_mul_mxv_q31 (const q31_t *src1, const q31_t *src2, q31_t *dst, uint32_t row, uint32_t col) |
| Matrix multiply vector for q31 formats. More... | |
| static void | hpm_dsp_mat_mul_mxv_q7 (const q7_t *src1, const q7_t *src2, q7_t *dst, uint32_t row, uint32_t col) |
| Matrix multiply vector for q7 formats. More... | |
This set of functions provides basic matrix math operations. The funciotn specifies the size of the matrix and then points to an array. For example, the function definition for the floating-point is shown below:
void riscv_dsp_funcname_f32(const float32_t *src1,
const float32_t *src2,
float32_t *dst,
uint32_t row,
uint32_t col,
uint32_t row2,
uint32_t col2)
where it can be transform to the two matrix. For the matrix 1 is a row * col matrix and the matrix 2 is a rol2 * col2 and the output matrix woild be different since the math operation. There are similar definitions for Q15 and Q31 data types.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two floating-point complex matrices.
| [in] | *src1 | points to the first input complex matrix. |
| [in] | *src2 | points to the second input complex matrix. |
| [out] | *dst | points to the output complex matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two q15 complex matrices.
| [in] | *src1 | points to the first input complex matrix. |
| [in] | *src2 | points to the second input complex matrix. |
| [out] | *dst | points to the output complex matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
Function notes:
The 1.15 format input is multiplied yields a 2.30 format, and then added without saturation to a 64-bit accumulator in 34.30 format. Finally, the added output is truncated to 34.15 format by discarding the lower 15 bits, and then saturated to yield a result in 1.15 format.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two q31 complex matrices.
| [in] | *src1 | points to the first input complex matrix. |
| [in] | *src2 | points to the second input complex matrix. |
| [out] | *dst | points to the output complex matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
Function notes:
The 1.31 format input is multiplied yields a 2.62 format. In order to avoid overflows, the input signal must be scaled down by log2(col) bits, Finally, the 2.62 accumulator is right shifted by 31 bits to yield a 1.31 format value.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Addition of two floating-potint matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Addition of two floating-potint matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Addition of two q15 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
The output results will be saturated in Q15 range [0x8000 0x7FFF].
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Addition of two q31 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
Ouput results will be saturated in Q31 range [0x80000000 0x7FFFFFFF].
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Compute the inverse matrix of the floating-potint matrix.
| [in] | *src | points to the input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | size | number of the matrix row or column. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two floating-point matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Matrix multiply vector for f32 formats.
| [in] | src1 | pointer of the input matrix |
| [in] | src2 | pointer of the input vector |
| [out] | dst | pointer of the output vector |
| [in] | row | number of rows in the matrix |
| [in] | col | number of columns in the matrix and the elements size of vector |
Example
#define Arow 2
#define Acol 3
float32_t src1[Arow * Acol] = {0.1, -0.1, 0.1, 0.2, -0.2, 0.3};
float32_t src2[Acol] = {0.2, -0.1, -0.7};
float32_t dst[Arow];
hpm_dsp_mat_mul_mxv_f32 (src1, src2, dst, Arow, Acol);
This example also serves as a reference for examples of Q31, Q15 or Q7 functions.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Matrix multiply vector for q15 formats.
| [in] | src1 | pointer of the input matrix |
| [in] | src2 | pointer of the input vector |
| [out] | dst | pointer of the output vector |
| [in] | row | number of rows in the matrix |
| [in] | col | number of columns in the matrix and the elements size of vector |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Matrix multiply vector for q31 formats.
| [in] | src1 | pointer of the input matrix |
| [in] | src2 | pointer of the input vector |
| [out] | dst | pointer of the output vector |
| [in] | row | number of rows in the matrix |
| [in] | col | number of columns in the matrix and the elements size of vector |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Matrix multiply vector for q7 formats.
| [in] | src1 | pointer of the input matrix |
| [in] | src2 | pointer of the input vector |
| [out] | dst | pointer of the output vector |
| [in] | row | number of rows in the matrix |
| [in] | col | number of columns in the matrix and the elements size of vector |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two q15 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
Function notes:
The 1.15 format input is multiplied yields a 2.30 format, and then added without saturation to a 64-bit accumulator in 34.30 format. Finally, the added output is truncated to 34.15 format by discarding the lower 15 bits, and then saturated to yield a result in 1.15 format.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two q31 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
Function notes:
The 1.31 format input is multiplied yields a 2.62 format. In order to avoid overflows, the input signal must be scaled down by log2(col) bits, Finally, the 2.62 accumulator is right shifted by 31 bits to yield a 1.31 format value.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of two q7 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the first input matrix rows. |
| [in] | col | number of the first input matrix columns. |
| [in] | col2 | number of the second input matrix columns. |
Function notes:
The 1.7 format input is multiplied yields a 2.15 format, and then added without saturation to a 32-bit accumulator in 17.15 format. Finally, the added output is truncated to 17.7 format by discarding the lower 7 bits, and then saturated to yield a result in 1.7 format.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplication of q7 vetor by matrix.
| [in] | *src1 | points to the first input vector. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output vector. |
| [in] | col | number of the first input vector columns. |
| [in] | col2 | number of the second input matrix columns. |
Function notes:
The 1.7 format input is multiplied yields a 2.15 format, and then added without saturation to a 32-bit accumulator in 17.15 format. Finally, the added output is truncated to 17.7 format by discarding the lower 7 bits, and then saturated to yield a result in 1.7 format.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Outer production of two q31 matrices.
| [in] | src1 | pointer of the first input matrix with a size of size1*1 |
| [in] | src2 | pointer of the second input matrix with a size of 1*size2 |
| [out] | dst | pointer of the output matrix with a size of size1 * size2 |
| [in] | size1 | number of rows in the first input matrix. |
| [in] | size2 | number of columns in the second input matrix. |
Note:
This function multiplies a one-column matrix with size1 rows, src1[size1, 1], with a one-row matrix with size2 columns, src2[1, size2], and stores the result into a matrix with size1 rows and size2 columns, dst[size1, size2]. It achieves better efficiency for vector-wise matrix multiplication than for regular matrix multiplication.
Example
The following equation shows the outer product of two matrices and its result.
Its code example is as follows:
#define Arow 3
#define Bcol 2
q31_t src1[Arow] = {0x200000, 0x100000, 0x50000};
q31_t src2[Bcol] = {0x10000, 0x30000};
q31_t dst[Arow * Bcol];
hpm_dsp_mat_oprod_q31 (src1, src2, dst, Arow, Bcol);
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplt a scale value of floating-potint matrix.
| [in] | *src | points to the input matrix. |
| [in] | scale | is the factor to be multiplied. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplt a scale value of q15 matrix.
| [in] | *src | points to the input matrix. |
| [in] | scale_fract | fractional multiplication. |
| [in] | shift | arithmetic shift. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
Function notes:
The 1.15 format inputs are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Multiplt a scale value of q31 matrix.
| [in] | *src | points to the input matrix. |
| [in] | scale_fract | fractional multiplication. |
| [in] | shift | arithmetic shift. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
Function notes:
The 1.31 format input are multiplied to yield a 2.62 intermediate result and this is shifted with saturation to 1.31 format.
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Substraction of two floating-potint matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Substraction of two double-precision floating-potint matrices.
| [in] | src1 | pointer of the first input matrix |
| [in] | src2 | pointer of the second input matrix |
| [out] | dst | pointer of the output matrix |
| [in] | row | number of rows in a matrix |
| [in] | col | number of columns in a matrix |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Substraction of two q15 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
The output results will be saturated in Q15 range [0x8000 0x7FFF].
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Substraction of two q31 matrices.
| [in] | *src1 | points to the first input matrix. |
| [in] | *src2 | points to the second input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
Ouput results will be saturated in Q31 range [0x80000000 0x7FFFFFFF].
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Transpose the floating-potint matricex.
| [in] | *src | points to the input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Transpose the double-precision floating-potint matrices.
| [in] | src | pointer of the input matrix |
| [out] | dst | pointer of the output matrix |
| [in] | row | number of rows in a matrix |
| [in] | col | number of columns in a matrix |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Transpose the q15 matricex.
| [in] | *src | points to the input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Transpose the q31 matricex.
| [in] | *src | points to the input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Transpose the q7 matrices.
| [in] | src | pointer of the input matrix |
| [out] | dst | pointer of the output matrix |
| [in] | row | number of rows in a matrix |
| [in] | col | number of columns in a matrix |
|
inlinestatic |
#include <middleware/hpm_math/hpm_math.h>
Transpose the u8 matricex.
| [in] | *src | points to the input matrix. |
| [out] | *dst | points to the output matrix. |
| [in] | row | number of the matrix rows. |
| [in] | col | number of the matrix columns. |