Go to the documentation of this file.00001
00009 #ifndef _SPARSEMATRIX_H_
00010 #define _SPARSEMATRIX_H_
00011
00012 #include <vector>
00013 #include <algorithm>
00014 using std::vector;
00015 #include "umfpack.h"
00016
00017 namespace MeshLib{
00018
00023 struct _Entry
00024 {
00025 int i;
00026 int j;
00027 double val;
00028 };
00029
00030
00042
00043
00044 class CSparseMatrix
00045 {
00046 protected:
00050 int m_nRows;
00054 int m_nCols;
00055
00059 bool* m_bAccessed;
00060 int m_nHashCode;
00061
00065 vector<_Entry>* m_pEntries;
00071 int CalcHashCode(int nRow, int nCol);
00072
00073 public:
00079 CSparseMatrix(int nRows, int nCols, int nnz = 0);
00085 void AddElement(int nRow, int nCol, double dVal);
00086
00092 void AddElementTail(int nRow, int nCol, double dVal);
00093
00094
00101 bool CGSolver( double b[], double x[], double eps, int& itrs );
00108 bool CGSolverStable( double b[], double x[], double eps, int& itrs );
00109
00110
00115 bool SolverUMF(double b[], double x[]);
00116
00117
00123 void Multiply(double iVector[], double oVector[]);
00129 void TransMul(double iVector[], double oVector[]);
00130
00134 int GetCols()
00135 {
00136 return m_nCols;
00137 }
00141 int GetRows()
00142 {
00143 return m_nRows;
00144 }
00148 virtual ~CSparseMatrix();
00149 };
00150
00151 }
00152
00153 #endif