Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

matrix.h

Go to the documentation of this file.
00001 //-------------------------------
00002 //   interface of Matrix Class
00003 //-------------------------------
00004 
00005 // Written by:               Tony Veit (tv_man21@hotmail.com) -- November 16, 2003
00006 
00007 #ifndef _MATRIX_H_
00008 #define _MATRIX_H_
00009 
00010 #include <iostream>
00011 #include <fstream>
00012 #include "..\common\types.h"
00013 using namespace std;
00014 
00019 class Matrix {
00020 private:
00021         double** m_pData;                                                  //the actual data
00022         int m_nCols;                                                       //number of columns
00023         int m_nRows;                                                       //number of rows
00024 
00025 
00026         //private functions
00027 
00028         Matrix& RightAppendIdentity();
00029         Matrix& LeftRemoveIdentity();
00030 public:
00031         //constructors and destructor
00032 
00033         Matrix();
00034         Matrix(double InitVal, int Rows, int Cols);
00035         Matrix(double* Data, int Rows, int Cols);
00036         Matrix(double** Data, int Rows, int Cols);
00037         Matrix(const Matrix& obj);
00038         ~Matrix();
00039 
00040 
00041         //operators
00042 
00043         Matrix& operator +(const Matrix& obj) const;
00044         Matrix& operator -(const Matrix& obj) const;
00045         Matrix& operator *(const Matrix& obj) const;
00046         Matrix& operator *(const double _d) const;
00047         Matrix& operator *(const int _i) const;
00048         Matrix& operator /(const Matrix& obj) const;
00049         Matrix& operator /(const double _d) const;
00050         Matrix& operator /(const int _i) const;
00051         Matrix& operator +=(const Matrix& obj);
00052         Matrix& operator -=(const Matrix& obj);
00053         Matrix& operator *=(const Matrix& obj);
00054         Matrix& operator *=(const double _d);
00055         Matrix& operator *=(const int _i);
00056         Matrix& operator /=(const Matrix& obj);
00057         Matrix& operator /=(const double _d);
00058         Matrix& operator /=(const int _i);
00059         Matrix& operator =(const Matrix& obj);
00060         Matrix& operator ~() const;
00061         bool operator ==(const Matrix& obj) const;
00062         bool operator !=(const Matrix& obj) const;
00063         double* operator [](const int _i) const;
00064         double& operator ()(const int _i, const int _j) const;
00065 
00066 
00067         //other non-static functions, no specific order, but generally by return-type
00068         // and generally grouped by similar function
00069 
00070         bool IsIdentity() const;
00071         bool IsEmpty() const;
00072 
00073         double Determinant() const;
00074 
00075         double SumAll() const;
00076         double SumAllSquared() const;
00077         double SumRow(const int Row) const;
00078         double SumColumn(const int Col) const;
00079         double SumRowSquared(const int Row) const;
00080         double SumColumnSquared(const int Col) const;
00081 
00082         double GetMax() const;
00083         double GetMin() const;
00084         double GetRowMax(const int Row) const;
00085         double GetRowMin(const int Row) const;
00086         double GetColumnMax(const int Col) const;
00087         double GetColumnMin(const int Col) const;
00088         double GetRange() const;
00089         double GetRowRange(const int Row) const;
00090         double GetColumnRange(const int Col) const;
00091 
00092         double* GetDataOneDimen() const;
00093         double** GetDataTwoDimen() const;
00094 
00095         int GetRows() const;
00096         int GetColumns() const;
00097 
00098         Matrix& Clear();
00099         Matrix& ClearRow(const int Row);
00100         Matrix& ClearColumn(const int Col);
00101 
00103         Matrix& SetValue(int Row,int Col,double _d);
00104         Matrix& Fill(const double _d);
00105         Matrix& FillRow(const int Row, const double _d);
00106         Matrix& FillColumn(const int Col, const double _d);
00107 
00108         Matrix& GetInverse() const;
00109         Matrix& Invert();
00110 
00111         Matrix& AddRows(const int SourceRow, const int DestRow, const double factor = 1);
00112         Matrix& MultiplyRow(const int Row, const double _d);
00113         Matrix& DivideRow(const int Row, const double _d);
00114         Matrix& AddColumns(const int SourceCol, const int DestCol, const double factor = 1);
00115         Matrix& MultiplyColumn(const int Col, const double _d);
00116         Matrix& DivideColumn(const int Col, const double _d);
00117 
00118         Matrix& REF();
00119         Matrix& RREF();
00120         Matrix& GetREF() const;
00121         Matrix& GetRREF() const;
00122 
00124         Matrix& CholeskyDecomposition();
00125 
00126         Matrix& GetMinor(const int RowSpot, const int ColSpot) const;
00127         Matrix* GetMinorNew(const int RowSpot, const int ColSpot) const;
00128         Matrix& GetSubMatrix(const int RowSpot, const int ColSpot, const int RowLen, const int ColLen) const;
00129         Matrix& SetSubMatrix(const int RowSpot, const int ColSpot, const int RowLen, const int ColLen);
00130 
00131         Matrix& SwapRows(const int Row1, const int Row2);
00132         Matrix& SwapCols(const int Col1, const int Col2);
00133 
00134         Matrix& GetTransposed() const;
00135         Matrix& Transpose();
00136 
00137         Matrix& GetNumericRange(double& Min, double& Max) const;
00138         Matrix& GetNumericRangeOfRow(double& Min, double& Max, const int Row) const;
00139         Matrix& GetNumericRangeOfColumn(double& Min, double& Max, const int Col) const;
00140 
00141         Matrix& CMAR(const Matrix& obj);
00142         Matrix& CMAC(const Matrix& obj);
00143         Matrix& GetCMAR(const Matrix& obj) const;
00144         Matrix& GetCMAC(const Matrix& obj) const;
00145 
00146         Matrix& ConcatenateRow(const double* RowData);
00147         Matrix& ConcatenateColumn(const double* ColumnData);
00148         Matrix& SpliceInRow(const double* RowData, const int RowSpot);
00149         Matrix& SpliceInColumn(const double* ColumnData, const int ColumnSpot);
00150         Matrix& RemoveRow(const int Row);
00151         Matrix& RemoveColumn(const int Column);
00152 
00153         Matrix& SortAscend();
00154         Matrix& SortDescend();
00155 
00156         Matrix& GetNormalized(const double Min, const double Max) const;
00157         Matrix& Normalize(const double Min, const double Max);
00158 
00159         Matrix& GetCovariant() const;
00160         Matrix& MakeCovariant();
00161 
00162         void Display() const;
00163         void Output(ostream& ostr = cout) const;
00164         void Input(istream& istr = cin);
00165         void Read(ifstream& istr);
00166         void Write(ofstream& ostr) const;
00167 
00168 
00169         //static functions
00170 
00171         static Matrix& IdentityMatrix(int Diagonal);
00172 };
00173 
00174 Matrix& IdentityMatrix(int Diagonal);
00175 
00176 ostream& operator <<(ostream& ostr, const Matrix& obj);
00177 
00178 #endif /* def _MATRIX_H_ */

Note: Generated nightly - reload for latest version
Generated on Thu Dec 22 23:12:36 2005 for terreneuve by doxygen 1.3.6