00001 #ifndef __AbsF4TriDiagonalLS_H__ 00002 #define __AbsF4TriDiagonalLS_H__ 00003 00004 00029 #include <stdio.h> 00030 #include "F4TriDiagonalMatrix.hpp" 00031 #include "Float4Vector.hpp" 00032 00033 class AbsF4TriDiagonalLS 00034 { 00035 protected: 00036 00037 int nLines; 00038 int N; 00039 00040 int N4; 00041 00042 00043 F4TriDiagonalMatrix* A; 00044 Float4Vector* x; 00045 00046 Float4Vector* b; 00047 00048 public: 00049 00050 AbsF4TriDiagonalLS(int asize) 00051 { 00052 nLines= 1; 00053 00054 N=asize; 00055 N4= N<<2; 00056 00057 x= new Float4Vector(N); 00058 b= new Float4Vector(N); 00059 00060 A= new F4TriDiagonalMatrix(N); 00061 } 00062 00063 AbsF4TriDiagonalLS(int asize, int lines) 00064 { 00065 nLines= lines; 00066 00067 N=asize; 00068 N4= N<<2; 00069 00070 x= new Float4Vector(N); 00071 b= new Float4Vector(N); 00072 00073 A= new F4TriDiagonalMatrix(N); 00074 } 00075 00076 00077 virtual ~AbsF4TriDiagonalLS() 00078 { 00079 delete A; 00080 delete x; 00081 delete b; 00082 } 00083 00084 virtual void loadA(F4TriDiagonalMatrix* m){ A->load(m); } 00085 virtual void loadMatrix(Float4Vector* u1, Float4Vector* d1, Float4Vector* l1){ A->load(u1,d1,l1); } 00086 virtual void loadX(Float4Vector* data){ x->load(data); } 00087 virtual void loadB(Float4Vector* data){ b->load(data); } 00088 00089 virtual int numberOfLines(){return nLines;} 00090 00091 virtual int size(){ return (3*N-2); } 00092 00093 virtual int getWidth(){ return N; } 00094 virtual int getHeight(){ return N; } 00095 00096 virtual Float4Vector* getX(){ return x; } 00097 virtual Float4Vector* getB(){ return b; } 00098 virtual F4TriDiagonalMatrix* getA(){ return A; } 00099 00100 /* 00101 virtual void solve()=0; // SOLVING 1 to 4 channels to define later 00102 00103 virtual void solve(Float4Vector* aX, Float4Vector* aB) // A not changed 00104 { 00105 loadX(aX); 00106 loadB(aB); 00107 00108 solve(); 00109 } 00110 00111 virtual void solve(F4TriDiagonalMatrix* aA, Float4Vector* aX, Float4Vector* aB) // new system 00112 { 00113 loadA(aA); 00114 00115 loadX(aX); 00116 loadB(aB); 00117 00118 solve(); 00119 } 00120 00121 00122 virtual Float4Vector* evaluate(Float4Vector* aX, Float4Vector* aB) 00123 { 00124 solve(aX, aB); 00125 00126 return getX(); 00127 } 00128 00129 virtual Float4Vector* evaluate(F4TriDiagonalMatrix* aA, Float4Vector* aX, Float4Vector* aB) 00130 { 00131 solve(aA, aX, aB); 00132 00133 return getX(); 00134 } 00135 */ 00136 virtual void output() 00137 { 00138 printf("Linear System\n"); 00139 A->output(); 00140 printf("x: "); x->output(); 00141 printf("b: "); b->output(); 00142 } 00143 00144 virtual void output(FILE* file) 00145 { 00146 fprintf(file, "Linear System\n"); 00147 A->output(file); 00148 fprintf(file, "x: "); x->output(file); 00149 fprintf(file, "b: "); b->output(file); 00150 } 00151 }; 00152 00153 #endif 00154