action_trmm.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  action_matrix_matrix_product.hh
00003 // Author :  L. Plagne <laurent.plagne@edf.fr)>
00004 // Copyright (C) EDF R&D,  lun sep 30 14:23:19 CEST 2002
00005 //=====================================================
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 //
00020 #ifndef ACTION_TRMM
00021 #define ACTION_TRMM
00022 #include "utilities.h"
00023 #include "STL_interface.hh"
00024 #include <string>
00025 #include "init/init_function.hh"
00026 #include "init/init_vector.hh"
00027 #include "init/init_matrix.hh"
00028 
00029 using namespace std;
00030 
00031 template<class Interface>
00032 class Action_trmm {
00033 
00034 public :
00035 
00036   // Ctor
00037 
00038   Action_trmm( int size ):_size(size)
00039   {
00040     MESSAGE("Action_trmm Ctor");
00041 
00042     // STL matrix and vector initialization
00043 
00044     init_matrix<pseudo_random>(A_stl,_size);
00045     init_matrix<pseudo_random>(B_stl,_size);
00046     init_matrix<null_function>(X_stl,_size);
00047     init_matrix<null_function>(resu_stl,_size);
00048 
00049     for (int j=0; j<_size; ++j)
00050     {
00051       for (int i=0; i<j; ++i)
00052         A_stl[j][i] = 0;
00053       A_stl[j][j] += 3;
00054     }
00055 
00056     // generic matrix and vector initialization
00057 
00058     Interface::matrix_from_stl(A_ref,A_stl);
00059     Interface::matrix_from_stl(B_ref,B_stl);
00060     Interface::matrix_from_stl(X_ref,X_stl);
00061 
00062     Interface::matrix_from_stl(A,A_stl);
00063     Interface::matrix_from_stl(B,B_stl);
00064     Interface::matrix_from_stl(X,X_stl);
00065 
00066     _cost = 0;
00067     for (int j=0; j<_size; ++j)
00068     {
00069       _cost += 2*j + 1;
00070     }
00071     _cost *= _size;
00072   }
00073 
00074   // invalidate copy ctor
00075 
00076   Action_trmm( const  Action_trmm & )
00077   {
00078     INFOS("illegal call to Action_trmm Copy Ctor");
00079     exit(0);
00080   }
00081 
00082   // Dtor
00083 
00084   ~Action_trmm( void ){
00085 
00086     MESSAGE("Action_trmm Dtor");
00087 
00088     // deallocation
00089 
00090     Interface::free_matrix(A,_size);
00091     Interface::free_matrix(B,_size);
00092     Interface::free_matrix(X,_size);
00093 
00094     Interface::free_matrix(A_ref,_size);
00095     Interface::free_matrix(B_ref,_size);
00096     Interface::free_matrix(X_ref,_size);
00097 
00098   }
00099 
00100   // action name
00101 
00102   static inline std::string name( void )
00103   {
00104     return "trmm_"+Interface::name();
00105   }
00106 
00107   double nb_op_base( void ){
00108     return _cost;
00109   }
00110 
00111   inline void initialize( void ){
00112 
00113     Interface::copy_matrix(A_ref,A,_size);
00114     Interface::copy_matrix(B_ref,B,_size);
00115     Interface::copy_matrix(X_ref,X,_size);
00116 
00117   }
00118 
00119   inline void calculate( void ) {
00120       Interface::trmm(A,B,X,_size);
00121   }
00122 
00123   void check_result( void ){
00124 
00125     // calculation check
00126 
00127 //     Interface::matrix_to_stl(X,resu_stl);
00128 //
00129 //     STL_interface<typename Interface::real_type>::matrix_matrix_product(A_stl,B_stl,X_stl,_size);
00130 //
00131 //     typename Interface::real_type error=
00132 //       STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
00133 //
00134 //     if (error>1.e-6){
00135 //       INFOS("WRONG CALCULATION...residual=" << error);
00136 // //       exit(1);
00137 //     }
00138 
00139   }
00140 
00141 private :
00142 
00143   typename Interface::stl_matrix A_stl;
00144   typename Interface::stl_matrix B_stl;
00145   typename Interface::stl_matrix X_stl;
00146   typename Interface::stl_matrix resu_stl;
00147 
00148   typename Interface::gene_matrix A_ref;
00149   typename Interface::gene_matrix B_ref;
00150   typename Interface::gene_matrix X_ref;
00151 
00152   typename Interface::gene_matrix A;
00153   typename Interface::gene_matrix B;
00154   typename Interface::gene_matrix X;
00155 
00156   int _size;
00157   double _cost;
00158 
00159 };
00160 
00161 
00162 #endif
00163 
00164 
00165 


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:28