Matrices Library
mikroC PRO for dsPIC30/33 and PIC24 includes a library for operating and working with matrices. All routines work with fractional Q15 format.
Library Routines
Matrix_Transpose
Prototype |
void Matrix_Transpose(unsigned *src, unsigned *dest, unsigned numRows, unsigned numCols); |
---|---|
Description |
Function does matrix transposition. dstM[i][j] = srcM[j][i] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
int mx1[6] = {1,2,3,4,5,6}; int mxDest[9]; Matrix_Transpose(mx1, mxDest, 2,3); |
Notes | [W0..W5] used, not restored |
Matrix_Subtract
Prototype |
void Matrix_Subtract(unsigned *src1, unsigned *src2, unsigned *dest, unsigned num_rows, unsigned num_cols); |
---|---|
Description |
Function does matrix subtraction. dstM[i][j] = srcM1[i][j] - srcM2[i][j] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
int mx1[6] = {1,2,3,4,5,6}; int mx2[6] = {2,2,2,2,2,2}; int mxDest[9]; Matrix_Subtract(mx1, mx2, mxDest, 2, 3); |
Notes |
|
Matrix_Scale
Prototype |
void Matrix_Scale(unsigned ScaleValue, unsigned *src1, unsigned *dest, unsigned numRows, unsigned numCols); |
---|---|
Description |
Function does matrix scale. dstM[i][j] = sclVal * srcM[i][j] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
int mx1[6] = {0xA000,0xC000,0xE000, // -0.75 -0.5 -0.25 0x2000,0x4000,0x6000}; // 0.25 0.5 0.75 int mxDest[9]; Matrix_Scale(0x4000, mx1, mxDest, 2,3); |
Notes |
|
Matrix_Multiply
Prototype |
void Matrix_Multiply(unsigned *src1, unsigned *src2, unsigned *dest, unsigned numRows1, unsigned numCols2, unsigned numCols1Rows2); |
---|---|
Description |
Function does matrix multiplication.
|
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
int mx1[6] = {0x4000,0x4000,0x4000, // 0.5 0x4000,0x4000,0x4000}; int mxDest[9]; Matrix_Multiply(mx1,mx1,mxDest,2,2,3); |
Notes |
|
Matrix_Add
Prototype |
void Matrix_Add(unsigned *src1, unsigned *src2, unsigned *dest, unsigned numRows, unsigned numCols); |
---|---|
Description |
Function does matrix addition. dstM[i][j] = srcM1[i][j] + srcM2[i][j] |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Example |
int mx1[6] = {1,2,3,4,5,6}; int mx2[6] = {2,2,2,2,2,2}; int mxDest[9]; Matrix_Add(mx1,mx2, mxDest,2,3); |
Notes |
|
What do you think about this topic ? Send us feedback!