00001 /* -*- mode: C++ -*- */ 00002 00003 // $Id: Matrix.h 85 2010-03-25 23:54:08Z jack.oquin $ 00004 00005 #ifndef _Matrix_h_DEFINED 00006 #define _Matrix_h_DEFINED 00007 00008 class Matrix 00009 { 00010 public: 00011 int M; // number of rows 00012 int N; // number of columns 00013 float* X; // matrix pointer 00014 00015 int getm() const; // return number of rows 00016 int getn() const; // return number of columns 00017 float* getx() const; // return pointer to array 00018 00019 // Constructors 00020 Matrix(); 00021 Matrix(int m, int n, bool I=false); 00022 Matrix(const Matrix& a); 00023 ~Matrix(); 00024 00025 Matrix transp(); // Matrix Transpose 00026 Matrix& operator = (const Matrix& a); // Overloaded Operator 00027 float* operator [] (int i) const; // Overloaded Operator 00028 00029 }; 00030 00031 // Overloaded Operators 00032 Matrix operator + (const Matrix& a, const Matrix& b); 00033 Matrix operator - (const Matrix& a, const Matrix& b); 00034 Matrix operator * (const Matrix& a, const Matrix& b); 00035 Matrix operator * (const float& a, const Matrix& b); 00036 Matrix operator * (const Matrix& a, const float& b); 00037 Matrix operator / (const Matrix& a, const float& b); 00038 00039 00040 // 2x2 Matrix Inversion 00041 Matrix Invert22(const Matrix& a); 00042 00043 inline float convDble(const Matrix& a) { return a[0][0]; } // Convert 1x1 matrix to Double 00044 inline int Matrix::getm() const { return M; } 00045 inline int Matrix::getn() const { return N; } 00046 inline float* Matrix::getx() const { return X; } 00047 00048 #endif