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