00001 #ifndef __FThomasLS_H__
00002 #define __FThomasLS_H__
00003 
00004 
00005 
00030 #include "AbsFTriDiagonalLS.hpp"
00031 
00032 
00033 class FThomasLS : public AbsFTriDiagonalLS
00034 {
00035 private:
00036                                                 
00037 FloatVector*                    uOut;   
00038 FloatVector*                    dOut;
00039 FloatVector*                    lOut;   
00040 
00041 FloatVector*                    y;              
00042 
00043 protected:
00044 
00046 inline void computeLRdecomposition()
00047         {
00048         dOut->set0(0, A->getD0(0) );
00049 
00050         for(int j=1; j<N; j++)
00051                 {
00052                 lOut->set(j, A->getL(j)/dOut->get(j) );
00053         
00054                 dOut->set0(j, A->getD0(j) - lOut->get(j)*A->getU(j) );
00055                 }
00056         }
00057 
00059 inline void forwardSubstitution()
00060         {
00061         y->set0(0, b->get0(0) );
00062 
00063         for(int j=1; j<N; j++)
00064                 y->set0(j, b->get0(j) - lOut->get(j)*y->get(j) );
00065         }
00066 
00068 inline void backwardSubstitution()
00069         {
00070         x->set(N, y->get(N)/dOut->get(N) );
00071 
00072         for(int j=N-1; j>0; j--)
00073                 x->set(j, (y->get(j) - A->getU(j)*x->get0(j))/dOut->get(j) );
00074         }
00075 
00076 public:
00077         
00078 FThomasLS(int asize):AbsFTriDiagonalLS(asize)
00079         {
00080         uOut= new FloatVector(N-1);
00081         dOut= new FloatVector(N);
00082         lOut= new FloatVector(N-1);
00083 
00084         y= new FloatVector(N);
00085         }
00086 
00087 virtual ~FThomasLS(){delete uOut; delete dOut; delete lOut; delete y;}
00088 
00089 virtual void loadA(FTriDiagonalMatrix* m);
00090 virtual void loadMatrix(FloatVector* u1, FloatVector* d1, FloatVector* l1);
00091 virtual void loadX(FloatVector* data);
00092 virtual void loadB(FloatVector* data);
00093 
00094 
00095 virtual bool solve();                                                           
00096 
00097         
00098 virtual void output()
00099         {
00100         printf("Thomas ");
00101         AbsFTriDiagonalLS::output();
00102         }
00103 
00104 virtual void output(FILE* file)
00105         {
00106         fprintf(file, "Thomas ");
00107         AbsFTriDiagonalLS::output(file);
00108         }
00109 };
00110 
00111 #endif
00112 
00113