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_HESSENBERG
00020 #define ACTION_HESSENBERG
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_hessenberg {
00032
00033 public :
00034
00035
00036
00037 Action_hessenberg( int size ):_size(size)
00038 {
00039 MESSAGE("Action_hessenberg Ctor");
00040
00041
00042 init_matrix<pseudo_random>(X_stl,_size);
00043
00044 init_matrix<null_function>(C_stl,_size);
00045 init_matrix<null_function>(resu_stl,_size);
00046
00047
00048 Interface::matrix_from_stl(X_ref,X_stl);
00049 Interface::matrix_from_stl(X,X_stl);
00050 Interface::matrix_from_stl(C,C_stl);
00051
00052 _cost = 0;
00053 for (int j=0; j<_size-2; ++j)
00054 {
00055 double r = std::max(0,_size-j-1);
00056 double b = std::max(0,_size-j-2);
00057 _cost += 6 + 3*b + r*r*4 + r*_size*4;
00058 }
00059 }
00060
00061
00062
00063 Action_hessenberg( const Action_hessenberg & )
00064 {
00065 INFOS("illegal call to Action_hessenberg Copy Ctor");
00066 exit(1);
00067 }
00068
00069
00070
00071 ~Action_hessenberg( void ){
00072
00073 MESSAGE("Action_hessenberg Dtor");
00074
00075
00076 Interface::free_matrix(X_ref,_size);
00077 Interface::free_matrix(X,_size);
00078 Interface::free_matrix(C,_size);
00079 }
00080
00081
00082
00083 static inline std::string name( void )
00084 {
00085 return "hessenberg_"+Interface::name();
00086 }
00087
00088 double nb_op_base( void ){
00089 return _cost;
00090 }
00091
00092 inline void initialize( void ){
00093 Interface::copy_matrix(X_ref,X,_size);
00094 }
00095
00096 inline void calculate( void ) {
00097 Interface::hessenberg(X,C,_size);
00098 }
00099
00100 void check_result( void ){
00101
00102 Interface::matrix_to_stl(C,resu_stl);
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 }
00115
00116 private :
00117
00118 typename Interface::stl_matrix X_stl;
00119 typename Interface::stl_matrix C_stl;
00120 typename Interface::stl_matrix resu_stl;
00121
00122 typename Interface::gene_matrix X_ref;
00123 typename Interface::gene_matrix X;
00124 typename Interface::gene_matrix C;
00125
00126 int _size;
00127 double _cost;
00128 };
00129
00130 template<class Interface>
00131 class Action_tridiagonalization {
00132
00133 public :
00134
00135
00136
00137 Action_tridiagonalization( int size ):_size(size)
00138 {
00139 MESSAGE("Action_hessenberg Ctor");
00140
00141
00142 typename Interface::stl_matrix tmp;
00143 init_matrix<pseudo_random>(tmp,_size);
00144 init_matrix<null_function>(X_stl,_size);
00145 STL_interface<typename Interface::real_type>::ata_product(tmp,X_stl,_size);
00146
00147 init_matrix<null_function>(C_stl,_size);
00148 init_matrix<null_function>(resu_stl,_size);
00149
00150
00151 Interface::matrix_from_stl(X_ref,X_stl);
00152 Interface::matrix_from_stl(X,X_stl);
00153 Interface::matrix_from_stl(C,C_stl);
00154
00155 _cost = 0;
00156 for (int j=0; j<_size-2; ++j)
00157 {
00158 int r = std::max(0,_size-j-1);
00159 int b = std::max(0,_size-j-2);
00160 _cost += 6 + 3*b + r*r*8;
00161 }
00162 }
00163
00164
00165
00166 Action_tridiagonalization( const Action_tridiagonalization & )
00167 {
00168 INFOS("illegal call to Action_tridiagonalization Copy Ctor");
00169 exit(1);
00170 }
00171
00172
00173
00174 ~Action_tridiagonalization( void ){
00175
00176 MESSAGE("Action_tridiagonalization Dtor");
00177
00178
00179 Interface::free_matrix(X_ref,_size);
00180 Interface::free_matrix(X,_size);
00181 Interface::free_matrix(C,_size);
00182 }
00183
00184
00185
00186 static inline std::string name( void ) { return "tridiagonalization_"+Interface::name(); }
00187
00188 double nb_op_base( void ){
00189 return _cost;
00190 }
00191
00192 inline void initialize( void ){
00193 Interface::copy_matrix(X_ref,X,_size);
00194 }
00195
00196 inline void calculate( void ) {
00197 Interface::tridiagonalization(X,C,_size);
00198 }
00199
00200 void check_result( void ){
00201
00202 Interface::matrix_to_stl(C,resu_stl);
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 }
00215
00216 private :
00217
00218 typename Interface::stl_matrix X_stl;
00219 typename Interface::stl_matrix C_stl;
00220 typename Interface::stl_matrix resu_stl;
00221
00222 typename Interface::gene_matrix X_ref;
00223 typename Interface::gene_matrix X;
00224 typename Interface::gene_matrix C;
00225
00226 int _size;
00227 double _cost;
00228 };
00229
00230 #endif