Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ACTION_TRISOLVE
00020 #define ACTION_TRISOLVE
00021 #include "utilities.h"
00022 #include "STL_interface.hh"
00023 #include <string>
00024 #include "init/init_function.hh"
00025 #include "init/init_vector.hh"
00026 #include "init/init_matrix.hh"
00027
00028 using namespace std;
00029
00030 template<class Interface>
00031 class Action_trisolve {
00032
00033 public :
00034
00035
00036
00037 Action_trisolve( int size ):_size(size)
00038 {
00039 MESSAGE("Action_trisolve Ctor");
00040
00041
00042 init_matrix<pseudo_random>(L_stl,_size);
00043 init_vector<pseudo_random>(B_stl,_size);
00044 init_vector<null_function>(X_stl,_size);
00045 for (int j=0; j<_size; ++j)
00046 {
00047 for (int i=0; i<j; ++i)
00048 L_stl[j][i] = 0;
00049 L_stl[j][j] += 3;
00050 }
00051
00052 init_vector<null_function>(resu_stl,_size);
00053
00054
00055 Interface::matrix_from_stl(L,L_stl);
00056 Interface::vector_from_stl(X,X_stl);
00057 Interface::vector_from_stl(B,B_stl);
00058
00059 _cost = 0;
00060 for (int j=0; j<_size; ++j)
00061 {
00062 _cost += 2*j + 1;
00063 }
00064 }
00065
00066
00067
00068 Action_trisolve( const Action_trisolve & )
00069 {
00070 INFOS("illegal call to Action_trisolve Copy Ctor");
00071 exit(1);
00072 }
00073
00074
00075
00076 ~Action_trisolve( void ){
00077
00078 MESSAGE("Action_trisolve Dtor");
00079
00080
00081 Interface::free_matrix(L,_size);
00082 Interface::free_vector(B);
00083 Interface::free_vector(X);
00084 }
00085
00086
00087
00088 static inline std::string name( void )
00089 {
00090 return "trisolve_vector_"+Interface::name();
00091 }
00092
00093 double nb_op_base( void ){
00094 return _cost;
00095 }
00096
00097 inline void initialize( void ){
00098
00099 }
00100
00101 inline void calculate( void ) {
00102 Interface::trisolve_lower(L,B,X,_size);
00103 }
00104
00105 void check_result(){
00106 if (_size>128) return;
00107
00108 Interface::vector_to_stl(X,resu_stl);
00109
00110 STL_interface<typename Interface::real_type>::trisolve_lower(L_stl,B_stl,X_stl,_size);
00111
00112 typename Interface::real_type error=
00113 STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
00114
00115 if (error>1.e-4){
00116 INFOS("WRONG CALCULATION...residual=" << error);
00117 exit(2);
00118 }
00119
00120 }
00121
00122 private :
00123
00124 typename Interface::stl_matrix L_stl;
00125 typename Interface::stl_vector X_stl;
00126 typename Interface::stl_vector B_stl;
00127 typename Interface::stl_vector resu_stl;
00128
00129 typename Interface::gene_matrix L;
00130 typename Interface::gene_vector X;
00131 typename Interface::gene_vector B;
00132
00133 int _size;
00134 double _cost;
00135 };
00136
00137 #endif