00001
00002
00003
00004
00005
00006
00007 #ifndef __MATRIXLIB_H__
00008 #define __MATRIXLIB_H__
00009
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021
00030 #define CreateMatrix(rows, cols) CreateMatrices(rows, cols, 1)
00031
00037 #define FreeMatrix(matrix) FreeMatrices(matrix,1)
00038
00039
00048 #define CreateVector(rows) CreateMatrix(rows,1)
00049
00058 #define CreateVectors(rows,number) CreateMatrices(rows,1,number)
00059
00065 #define FreeVector(vector) FreeMatrix(vector)
00066
00073 #define FreeVectors(vectors, number) FreeMatrices(vectors, number)
00074
00075
00084 #define MatrixAdd(one, two) MatrixAddSub(one,two,true);
00085
00093 #define MatrixSub(one, two) MatrixAddSub(one,two,false);
00094
00095
00096 #ifndef __cplusplus
00097 typedef unsigned char bool;
00098
00099 #define false 0
00100 #define true 0
00101 #endif
00102
00103 typedef unsigned char tinyint;
00104
00105
00107 typedef struct _MATRIX
00108 {
00110 tinyint rows;
00112 tinyint cols;
00114 tinyint length;
00116 float *data;
00117 } _MATRIX, *LPMATRIX;
00118
00119
00120 extern LPMATRIX CreateIdentityMatrix(tinyint rows);
00121 extern LPMATRIX CreateMatrices(tinyint rows, tinyint cols, tinyint number);
00122 extern void FreeMatrices(LPMATRIX matrices, tinyint number);
00123 extern LPMATRIX MatrixCopy(LPMATRIX src);
00124
00125
00126 extern float MatrixGet(const LPMATRIX matrix, tinyint row, tinyint col);
00127 extern bool MatrixSet(LPMATRIX matrix, tinyint row, tinyint col, float data);
00128 extern void MatrixSetAll(LPMATRIX matrix, float value);
00129
00130
00131 extern LPMATRIX MatrixAddSub(const LPMATRIX one, const LPMATRIX two, bool bAdd);
00132 extern LPMATRIX MatrixMultiply(const LPMATRIX first, LPMATRIX second);
00133
00134
00135 extern LPMATRIX MatrixTranspose(const LPMATRIX matrix);
00136 extern LPMATRIX MatrixInverse(const LPMATRIX matrix);
00137 #ifdef __cplusplus
00138 }
00139 #endif
00140 #endif