Matrix Addition

riscv_status riscv_mat_add_f32(const riscv_matrix_instance_f32 *pSrcA, const riscv_matrix_instance_f32 *pSrcB, riscv_matrix_instance_f32 *pDst)
riscv_status riscv_mat_add_q15(const riscv_matrix_instance_q15 *pSrcA, const riscv_matrix_instance_q15 *pSrcB, riscv_matrix_instance_q15 *pDst)
riscv_status riscv_mat_add_q31(const riscv_matrix_instance_q31 *pSrcA, const riscv_matrix_instance_q31 *pSrcB, riscv_matrix_instance_q31 *pDst)
group MatrixAdd

Adds two matrices.

../../../_images/MatrixAddition.png

The functions check to make sure that pSrcA, pSrcB, and pDst have the same number of rows and columns.

Functions

riscv_status riscv_mat_add_f32(const riscv_matrix_instance_f32 *pSrcA, const riscv_matrix_instance_f32 *pSrcB, riscv_matrix_instance_f32 *pDst)

Floating-point matrix addition.

Return

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_SIZE_MISMATCH : Matrix size check failed

Parameters
  • [in] pSrcA: points to first input matrix structure

  • [in] pSrcB: points to second input matrix structure

  • [out] pDst: points to output matrix structure

riscv_status riscv_mat_add_q15(const riscv_matrix_instance_q15 *pSrcA, const riscv_matrix_instance_q15 *pSrcB, riscv_matrix_instance_q15 *pDst)

Q15 matrix addition.

Return

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_SIZE_MISMATCH : Matrix size check failed

Scaling and Overflow Behavior

The function uses saturating arithmetic. Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated.

Parameters
  • [in] pSrcA: points to first input matrix structure

  • [in] pSrcB: points to second input matrix structure

  • [out] pDst: points to output matrix structure

riscv_status riscv_mat_add_q31(const riscv_matrix_instance_q31 *pSrcA, const riscv_matrix_instance_q31 *pSrcB, riscv_matrix_instance_q31 *pDst)

Q31 matrix addition.

Return

execution status

  • RISCV_MATH_SUCCESS : Operation successful

  • RISCV_MATH_SIZE_MISMATCH : Matrix size check failed

Scaling and Overflow Behavior

The function uses saturating arithmetic. Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated.

Parameters
  • [in] pSrcA: points to first input matrix structure

  • [in] pSrcB: points to second input matrix structure

  • [out] pDst: points to output matrix structure