Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

FBandSMatrix.hpp

00001 #ifndef __FBandSMatrix_H__
00002 #define __FBandSMatrix_H__
00003 
00004 
00025 #include <stdio.h>
00026 #include "FloatVector.hpp"
00027 
00028 #include "AFSymMatrix.hpp"
00029 
00030 class FBandSMatrix : public AFSymMatrix
00031 {
00032 protected:
00033 
00034 int                             n, middle, nmax;                                // n bands
00035 
00036 int                             nL0, nD, nU0;
00037 
00038 int*                            index;                          // 0=diagonal, <0 L, >0 U
00039 FloatVector**           band;                                   // N-1 size upper diagonal 
00040 
00041 public:
00042         
00043 FBandSMatrix(int asize, int nband, int* iband, float val=0.0);
00044 FBandSMatrix(int asize, int nband, int* iband, float* val);
00045 FBandSMatrix(const FBandSMatrix& v);
00046 FBandSMatrix operator=(const FBandSMatrix& v);
00047 
00048 virtual ~FBandSMatrix();
00049 
00050 virtual AFloatMatrix* copy();
00051 virtual AFloatMatrix* t(AFloatMatrix* result=0){return (AFloatMatrix*)0;}
00052 
00053 // no diagonal
00054 virtual AFSymMatrix* copyL0();                          
00055 virtual AFSymMatrix* copyU0();
00056 // with diagonal
00057 virtual AFSymMatrix* copyL();                           
00058 virtual AFSymMatrix* copyU();
00059 // with unit diagonal
00060 virtual AFSymMatrix* copyL1();                          
00061 virtual AFSymMatrix* copyU1();
00062 
00063 virtual int numberOfBands(){ return n; }
00064 virtual int numberOfL0Bands(){ return nL0; }
00065 virtual int numberOfDBands(){ return nD;}
00066 virtual int numberOfU0Bands(){ return nU0; }
00067 
00068 virtual int getIndexBand(int i){ return index[i]; }
00069 
00070 virtual int size()const;
00071 
00072 FloatVector* getBand(int i){ return band[i]; }
00073 FloatVector* getUvalues(int i){ return band[middle+i]; }
00074 FloatVector* getDvalues(){ return band[middle]; }
00075 FloatVector* getLvalues(int i){ return band[middle-i]; }
00076 
00077 virtual void setBand(int i, FloatVector* v){band[i]->load(v);}
00078 
00079 // base 0
00080 virtual void set0(int i, int j, float value);
00081 virtual float get0(int i, int j);
00082 
00083 virtual void setD0(int i, float value);
00084 virtual float getD0(int i)const;
00085 
00086 virtual void setU0(int iband, int i, float value);
00087 virtual float getU0(int iband, int i)const;
00088 
00089 virtual void setL0(int iband, int i, float value);
00090 virtual float getL0(int iband, int i)const;
00091 
00092 virtual Simple1DIndexList* indexesInRow0(int k, Simple1DIndexList* oldRow=0);
00093 virtual Simple1DIndexList* indexesInCol0(int k, Simple1DIndexList* oldCol=0);
00094 
00095 // base 1
00096 virtual void set(int i, int j, float value){ set0(i-1,j-1, value); }
00097 virtual float get(int i, int j){ return get0(i-1,j-1); }
00098 
00099 virtual void setD(int i, float value);
00100 virtual float getD(int i)const;
00101 
00102 virtual void setU(int iband, int i, float value);
00103 virtual float getU(int iband, int i)const;
00104 
00105 virtual void setL(int iband, int i, float value);
00106 virtual float getL(int iband, int i)const;
00107 
00108 virtual Simple1DIndexList* indexesInRow(int k, Simple1DIndexList* oldRow=0);
00109 virtual Simple1DIndexList* indexesInCol(int k, Simple1DIndexList* oldCol=0);
00110 
00111 // direct solvers: optimal band Ax=b, O(nband*N)
00112 virtual FloatVector* linearSolverU0(FloatVector* b, FloatVector* x=0);          // Ux=b
00113 virtual FloatVector* linearSolverU1(FloatVector* b, FloatVector* x=0);          // U1x=b
00114 virtual FloatVector* linearSolverL0(FloatVector* b, FloatVector* x=0);          // Lx=b
00115 virtual FloatVector* linearSolverL1(FloatVector* b, FloatVector* x=0);          // L1x=b
00116 
00117 // computations
00118 
00119 virtual void setAll(float value=0.0);
00120 
00121 virtual float det();
00122 virtual float trace();
00123 
00124 virtual float norme2();
00125 virtual float sum();
00126 
00127 virtual float minimum();
00128 virtual float maximum();
00129 virtual float sigma();
00130 
00131 
00132 // single step iterative linear solvers: Au=b, single iteration
00133 // virtual FloatVector* gaussSeidel(FloatVector* b, FloatVector* x=0);
00134 // virtual FloatVector* jacobi(FloatVector* b, FloatVector* x=0, FloatVector* dest=0);
00135 // virtual FloatVector* sor(FloatVector* b, float omega=1.0, FloatVector* x=0);
00136 
00137 virtual AFSymMatrix* jacobiMatrix();                                    // used to compute SOR omega
00138 
00139 // scalar single operations
00140 void operator*=(float value);
00141 void operator/=(float value);
00142 
00143 virtual void add(float value){}
00144 virtual void subst(float value){}
00145 virtual void mult(float value);
00146 virtual void div(float value);
00147 
00148 virtual void add(AFloatMatrix& m){}
00149 virtual void subst(AFloatMatrix& m){}
00150 
00151 
00152 // u= A*v including implicit transposition
00153 FloatVector* mult_Av(FloatVector* v, FloatVector* result=0);
00154 FloatVector* mult_ATv(FloatVector* v, FloatVector* result=0);
00155 // u= v*A
00156 FloatVector* mult_vA(FloatVector* v, FloatVector* result=0)     { return mult_ATv(v, result); }
00157 FloatVector* mult_vAT(FloatVector* vt, FloatVector* result=0){ return mult_Av(vt, result); }
00158 
00159 // sub vector usage
00160 // u= A*v
00161 FloatVector* mult_Av(FloatVector* v, int col0, int row0, bool incremental=false, FloatVector* result=0);
00162 FloatVector* mult_ATv(FloatVector* v, int col0, int row0, bool incremental=false, FloatVector* result=0);
00163 // u= v*A
00164 FloatVector* mult_vA(FloatVector* v, int row0, int col0, bool incremental=false, FloatVector* result=0)
00165                         { return mult_ATv(v, col0, row0, incremental, result); }
00166 FloatVector* mult_vAT(FloatVector* vt, int row0, int col0, bool incremental=false, FloatVector* result=0)
00167                         { return mult_Av(vt, col0, row0, incremental, result); }
00168 
00169 
00170 // incomplete factorisation
00171 virtual AFloatMatrix* ilu0();
00172 virtual AFloatMatrix* iluth(double threshold=0.001);
00173 
00174 virtual void output(){ printf("Band(%d) ", numberOfBands()); AFSymMatrix::output(); }
00175 };
00176 
00177 #endif
00178 
00179 
00180          
SourceForge.net Logo
Restoreinpaint sourceforge project `C++/Java Image Processing, Restoration, Inpainting Project'.

Bernard De Cuyper: Open Project Leader: Concept, design and development.
Bernard De Cuyper & Eddy Fraiha 2002, 2003. Bernard De Cuyper 2004. Open and free, for friendly usage only.
Modifications on Belgium ground of this piece of artistic work, by governement institutions or companies, must be notified to Bernard De Cuyper.
bern_bdc@hotmail.com