00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _SYSMAT_H
00014 #define _SYSMAT_H
00015
00016
00017
00018
00019 class cVector;
00020
00021
00022
00023
00024 class cSysMatrix
00025 {
00026 friend class cVector;
00027
00028 protected:
00029 int dim;
00030 int nelm;
00031 int maxit;
00032 double tol;
00033
00034 protected:
00035 int IsSup(int i, int j) { return(i < j); }
00036 int IsInf(int i, int j) { return(i > j); }
00037
00038 public:
00039 cSysMatrix(int n = 1) { dim = n; nelm = 0;
00040 maxit = n; tol = 1.0e-05; }
00041 virtual ~cSysMatrix(void) { }
00042 int GetNumElm (void) { return nelm; }
00043 int Dim (void) { return dim; }
00044 void SetParam (int k, double t) { maxit = k; tol = t; }
00045 virtual double **Val (void) { return 0; }
00046 virtual void Zero (void) { }
00047 virtual int Solve (cVector &, cVector &) { return 0; }
00048 virtual int GetSmlPvt (void) { return 0; }
00049 virtual int GetLgtPvt (void) { return 0; }
00050 virtual int GetNgtPvt (void) { return 0; }
00051 virtual double Get (int, int) = 0;
00052 virtual void Add (int, int, double) = 0;
00053 virtual void Print (void) = 0;
00054 virtual void MultVect (double *, double *) = 0;
00055 };
00056
00057
00058
00059
00060 class cSymSkylMatrix : public cSysMatrix
00061 {
00062 protected:
00063 int dec;
00064 int *skl;
00065 double **val;
00066
00067 public:
00068 cSymSkylMatrix(int, int *);
00069 ~cSymSkylMatrix(void);
00070 double& operator() (int i, int j) { return val[i][j]; }
00071 double **Val (void) { return val; }
00072 void Zero (void);
00073 int Solve (cVector &, cVector &);
00074 int GetSmlPvt (void);
00075 int GetLgtPvt (void);
00076 int GetNgtPvt (void);
00077 double Get (int, int);
00078 void Add (int, int, double);
00079 void Print (void);
00080 void MultVect (double *, double *);
00081 };
00082
00083
00084
00085
00086 typedef struct _spelm SpElm;
00087
00088 struct _spelm
00089 {
00090 int col;
00091 double val;
00092 SpElm *nxt;
00093 };
00094
00095
00096
00097
00098 class cSprsMatrix : public cSysMatrix
00099 {
00100 protected:
00101 SpElm **row;
00102
00103 public:
00104 cSprsMatrix(int n = 1);
00105 virtual ~cSprsMatrix(void);
00106 virtual double Get (int, int);
00107 virtual void Add (int, int, double);
00108 virtual void Print (void);
00109 virtual void MultVect (double *, double *);
00110 };
00111
00112
00113
00114
00115 class cSymSprsMatrix : public cSprsMatrix
00116 {
00117 public:
00118 cSymSprsMatrix(int n = 1);
00119 ~cSymSprsMatrix(void) { }
00120 int Solve (cVector &, cVector &);
00121 double Get (int, int);
00122 void Add (int, int, double);
00123 void Print (void);
00124 void MultVect (double *, double *);
00125 };
00126
00127
00128
00129
00130 int PCGSolver(int maxit, double tol, cSysMatrix *K, cVector &f,
00131 cVector &u);
00132
00133 int FstEigPair(int maxit, double tol, cSysMatrix *K, double *, cVector &v);
00134
00135 #endif