00001 #ifndef _MATRIX_H 00002 #define _MATRIX_H 00003 00004 #include "defines.h" 00005 00006 namespace annie 00007 { 00008 00014 class Matrix 00015 { 00016 private: 00017 int _m,_n; 00018 real **_M; 00019 00020 void _allocateMatrix(int m, int n); 00021 void _freeMatrix(); 00022 public: 00029 Matrix(int m,int n); 00030 00032 Matrix(Matrix &M); 00033 00035 Matrix(Matrix *M); 00036 00037 virtual ~Matrix(); 00038 00040 virtual void print(); 00041 00047 virtual real& elementAt(int i,int j); 00048 00056 virtual Matrix *multiply(Matrix &other); 00057 00065 virtual Matrix *multiply(Matrix *other); 00066 00068 virtual void multiply(real f); 00069 00071 virtual void swapRows(int i, int j); 00072 00077 virtual Matrix *transpose(); 00078 00085 virtual Matrix *inverse(); 00086 00092 static Matrix *Identity(int n); 00093 00095 friend std::ostream& operator << (std::ostream& s, Matrix &M); 00096 }; 00097 }; //namespace annie 00098 #endif // define _MATRIX_H 00099