STM32F1 CMSIS DSP Matrix Functions

Started by tha, July 20, 2021, 07:01:47 AM

Previous topic - Next topic

tha



Description

เซ็ตของฟังชั่นนี้จัดให้มี basic matrix math operations. The functions ทำงานบน matrix data structures. ตัวอย่างเช่น, the type definition สำหรับ the floating-point matrix structure ถูกแสดงข้างล่าง :

    typedef struct
    {
      uint16_t numRows;     // number of rows of the matrix.
      uint16_t numCols;     // number of columns of the matrix.
      float32_t *pData;     // points to the data of the matrix.
    } arm_matrix_instance_f32;

มี definitions ที่เหมือนกันสำหรับ Q15 and Q31 data type

The structure ระบุขนาดของ the matrix และจากนั้นชี้ไปยัง an array of data. The array มีขนาด numRows X numCols และ the values ถูกจัดเรียงใน row order. นั่นคือ, the matrix element (i, j) ถูกเก็บที่ :

  pData[i*numCols + j]

tha

Init Functions

มี an associated initialization function สำหรับแต่ละประเภทของ matrix data structure. The initialization function เซ็ตค่าของ the internal structure fields. อ้างอิงถึง the function arm_mat_init_f32(), arm_mat_init_q31() and arm_mat_init_q15() สำหรับ floating-point, Q31 and Q15 types, ตามลำดับ.

การใช้ของ the initialization function เป็นทางเลือก. อย่างไรก็ตาม, ถ้า initialization function ถูกใช้ดังนั้น the instance structure ไม่สามารถถูกวางลงใน a const data section. เพื่อวาง the instance structure ใน a const data section, เริ่มต้นอย่างแมนน้วล the data structure. ตัวอย่างเช่น:

arm_matrix_instance_f32 S = {nRows, nColumns, pData};
arm_matrix_instance_q31 S = {nRows, nColumns, pData};
arm_matrix_instance_q15 S = {nRows, nColumns, pData};

โดยที่ nRows ระบุจำนวนของ rows, nColumns ระบุจำนวนของ columns, และ pData ชี้ไปยัง the data array.

tha

Size Checking

โดยค่าเริ่มต้นทุก the matrix functions ดำเนินการ size checking บน the input และ output matrices. ตัวอย่างเช่น, the matrix addition function จะตรวจสอบว่า the two input matrices และ the output matrix ทั้งหมดมีจำนวนเดียวกันของ rows และ columns. ถ้า the size check ล้มเหลว the functions คืนค่า :

    ARM_MATH_SIZE_MISMATCH

มิฉะนั้น the functions คืนค่า

    ARM_MATH_SUCCESS

มีโสหุ้ยบางอย่างที่เกี่ยวข้องกับ matrix size checking นี้. The matrix size checking ถูกเปิดการใช้งานโดยทาง the #define

    ARM_MATH_MATRIX_CHECK

ภายใน the library project settings. โดยค่าเริ่มต้น macro นี้ถูก defined และ size checking ถูกเปิดการใช้งาน. โดยการเปลี่ยน the project settings และการไม่กำหนด macro size checking นี้ถูกเอาออกและ the functions จะรันเร็วขึ้นเล็กน้อย. ด้วย size checking ถูกปิดการใช้งาน the functions จะคืนค่า ARM_MATH_SUCCESS เสมอ.


tha



Description

เริ่มต้น the underlying matrix data structure. The functions เซ็ต the numRows, numCols, และ pData fields ของ the matrix data structure.

tha



References arm_matrix_instance_f32::numCols, arm_matrix_instance_f32::numRows, and arm_matrix_instance_f32::pData.

Referenced by main().

tha


tha


tha



Description

บวก two matrices.



The functions จะเช็คเพื่อทำให้แน่ใจว่า pSrcA, pSrcB, and pDst มี the same number of rows and columns.