00001 #ifndef __RPentaDiagonalMatrix_H__ 00002 #define __RPentaDiagonalMatrix_H__ 00003 00004 00005 00025 #include <stdio.h> 00026 #include "RealVector.hpp" 00027 00028 class RPentaDiagonalMatrix 00029 { 00030 private: 00031 00032 int N; 00033 int order; 00034 00035 RealVector** up; // N-1 size upper diagonal 00036 RealVector* d; // N size diagonal 00037 RealVector** low; // N-1 size lower diagonal 00038 00039 public: 00040 00041 RPentaDiagonalMatrix(int asize); 00042 RPentaDiagonalMatrix(const RPentaDiagonalMatrix& v); 00043 RPentaDiagonalMatrix operator=(const RPentaDiagonalMatrix& v); 00044 00045 ~RPentaDiagonalMatrix(){ delete d; delete[] up; delete[] low;} 00046 00047 RPentaDiagonalMatrix t(); 00048 00049 void load(RPentaDiagonalMatrix* m); 00050 void load(RealVector* u2, RealVector* u1, RealVector* d1, RealVector* l1, RealVector* l2); 00051 00052 inline int size()const { return (5*N-6); } 00053 00054 inline int getWidth()const { return N; } 00055 inline int getHeight()const { return N; } 00056 00057 RealVector* getUvalues(int idiag){ return up[idiag]; } 00058 RealVector* getDvalues(){ return d; } 00059 RealVector* getLvalues(int idiag){ return low[idiag]; } 00060 00061 // base 0 00062 void set0(int i, int j, double value); 00063 double get0(int i, int j)const ; 00064 00065 inline void setD0(int i, double value){ d->set0(i, value); } 00066 inline double getD0(int i)const { return d->get0(i); } 00067 00068 inline void setU0(int idiag, int i, double value){ up[idiag]->set0(i, value); } 00069 inline double getU0(int idiag, int i)const { return up[idiag]->get0(i); } 00070 00071 inline void setL0(int idiag, int i, double value){ low[idiag]->set0(i, value); } 00072 inline double getL0(int idiag, int i)const { return low[idiag]->get0(i); } 00073 00074 // base 1 00075 void set(int i, int j, double value); 00076 double get(int i, int j)const ; 00077 00078 inline void setD(int i, double value){ d->set(i, value); } 00079 inline double getD(int i)const { return d->get(i); } 00080 00081 inline void setU(int idiag, int i, double value){ up[idiag]->set(i, value); } 00082 inline double getU(int idiag, int i)const { return up[idiag]->get(i); } 00083 00084 inline void setL(int idiag, int i, double value){ low[idiag]->set(i, value); } 00085 inline double getL(int idiag, int i)const { return low[idiag]->get(i); } 00086 00087 00088 // computations 00089 double det(); 00090 double trace(); 00091 00092 00093 double norme2(); 00094 double sum(); 00095 00096 double minimum(); 00097 double maximum(); 00098 double mean(){ return sum()/size(); } 00099 double sigma(); 00100 00101 // scalar single operations 00102 void operator+=(double value); 00103 void operator-=(double value); 00104 void operator*=(double value); 00105 void operator/=(double value); 00106 00107 // vector single operations 00108 void operator+=(const RPentaDiagonalMatrix& m); 00109 void operator-=(const RPentaDiagonalMatrix& m); 00110 00111 // friends 00112 friend RealVectorT operator*(const RealVectorT& vt, const RPentaDiagonalMatrix& m); 00113 friend RealVector operator*(const RPentaDiagonalMatrix& m, const RealVector& v); 00114 00115 void output(); 00116 void output(FILE* file); 00117 }; 00118 00119 #endif 00120 00121