Wm4GMatrix.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef WM4GMATRIX_H
00018 #define WM4GMATRIX_H
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "Wm4FoundationLIB.h"
00034 #include "Wm4GVector.h"
00035
00036 namespace Wm4
00037 {
00038
00039 template <class Real>
00040 class GMatrix
00041 {
00042 public:
00043
00044 GMatrix (int iRows = 0, int iCols = 0);
00045 GMatrix (int iRows, int iCols, const Real* afData);
00046 GMatrix (int iRows, int iCols, const Real** aafEntry);
00047 GMatrix (const GMatrix& rkM);
00048 ~GMatrix ();
00049
00050
00051 void SetSize (int iRows, int iCols);
00052 void GetSize (int& riRows, int& riCols) const;
00053 int GetRows () const;
00054 int GetColumns () const;
00055 int GetQuantity () const;
00056 operator const Real* () const;
00057 operator Real* ();
00058 const Real* operator[] (int iRow) const;
00059 Real* operator[] (int iRow);
00060 void SwapRows (int iRow0, int iRow1);
00061 Real operator() (int iRow, int iCol) const;
00062 Real& operator() (int iRow, int iCol);
00063 void SetRow (int iRow, const GVector<Real>& rkV);
00064 GVector<Real> GetRow (int iRow) const;
00065 void SetColumn (int iCol, const GVector<Real>& rkV);
00066 GVector<Real> GetColumn (int iCol) const;
00067 void SetMatrix (int iRows, int iCols, const Real* afEntry);
00068 void SetMatrix (int iRows, int iCols, const Real** aafMatrix);
00069 void GetColumnMajor (Real* afCMajor) const;
00070
00071
00072 GMatrix& operator= (const GMatrix& rkM);
00073
00074
00075 bool operator== (const GMatrix& rkM) const;
00076 bool operator!= (const GMatrix& rkM) const;
00077 bool operator< (const GMatrix& rkM) const;
00078 bool operator<= (const GMatrix& rkM) const;
00079 bool operator> (const GMatrix& rkM) const;
00080 bool operator>= (const GMatrix& rkM) const;
00081
00082
00083 GMatrix operator+ (const GMatrix& rkM) const;
00084 GMatrix operator- (const GMatrix& rkM) const;
00085 GMatrix operator* (const GMatrix& rkM) const;
00086 GMatrix operator* (Real fScalar) const;
00087 GMatrix operator/ (Real fScalar) const;
00088 GMatrix operator- () const;
00089
00090
00091 GMatrix& operator+= (const GMatrix& rkM);
00092 GMatrix& operator-= (const GMatrix& rkM);
00093 GMatrix& operator*= (Real fScalar);
00094 GMatrix& operator/= (Real fScalar);
00095
00096
00097 GMatrix Transpose () const;
00098 GMatrix TransposeTimes (const GMatrix& rkM) const;
00099 GMatrix TimesTranspose (const GMatrix& rkM) const;
00100
00101
00102 GVector<Real> operator* (const GVector<Real>& rkV) const;
00103 Real QForm (const GVector<Real>& rkU, const GVector<Real>& rkV)
00104 const;
00105
00106
00107
00108 bool GetInverse (GMatrix<Real>& rkInverse) const;
00109
00110 protected:
00111
00112
00113
00114 void Allocate (bool bSetToZero);
00115 void Deallocate ();
00116
00117
00118 int CompareArrays (const GMatrix& rkM) const;
00119
00120 int m_iRows, m_iCols, m_iQuantity;
00121
00122
00123 Real* m_afData;
00124
00125
00126
00127
00128 Real** m_aafEntry;
00129 };
00130
00131
00132 template <class Real>
00133 GMatrix<Real> operator* (Real fScalar, const GMatrix<Real>& rkM);
00134
00135
00136 template <class Real>
00137 GVector<Real> operator* (const GVector<Real>& rkV, const GMatrix<Real>& rkM);
00138
00139 }
00140
00141 #include "Wm4GMatrix.inl"
00142
00143 namespace Wm4
00144 {
00145 typedef GMatrix<float> GMatrixf;
00146 typedef GMatrix<double> GMatrixd;
00147 }
00148
00149 #endif