action_ata_product.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  action_ata_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_ATA_PRODUCT
00021 #define ACTION_ATA_PRODUCT
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_ata_product {
00033 
00034 public :
00035 
00036   // Ctor
00037 
00038   Action_ata_product( int size ):_size(size)
00039   {
00040     MESSAGE("Action_ata_product Ctor");
00041 
00042     // STL matrix and vector initialization
00043 
00044     init_matrix<pseudo_random>(A_stl,_size);
00045     init_matrix<null_function>(X_stl,_size);
00046     init_matrix<null_function>(resu_stl,_size);
00047 
00048     // generic matrix and vector initialization
00049 
00050     Interface::matrix_from_stl(A_ref,A_stl);
00051     Interface::matrix_from_stl(X_ref,X_stl);
00052 
00053     Interface::matrix_from_stl(A,A_stl);
00054     Interface::matrix_from_stl(X,X_stl);
00055 
00056   }
00057 
00058   // invalidate copy ctor
00059 
00060   Action_ata_product( const  Action_ata_product & )
00061   {
00062     INFOS("illegal call to Action_ata_product Copy Ctor");
00063     exit(0);
00064   }
00065 
00066   // Dtor
00067 
00068   ~Action_ata_product( void ){
00069 
00070     MESSAGE("Action_ata_product Dtor");
00071 
00072     // deallocation
00073 
00074     Interface::free_matrix(A,_size);
00075     Interface::free_matrix(X,_size);
00076 
00077     Interface::free_matrix(A_ref,_size);
00078     Interface::free_matrix(X_ref,_size);
00079 
00080   }
00081 
00082   // action name
00083 
00084   static inline std::string name( void )
00085   {
00086     return "ata_"+Interface::name();
00087   }
00088 
00089   double nb_op_base( void ){
00090     return 2.0*_size*_size*_size;
00091   }
00092 
00093   inline void initialize( void ){
00094 
00095     Interface::copy_matrix(A_ref,A,_size);
00096     Interface::copy_matrix(X_ref,X,_size);
00097 
00098   }
00099 
00100   inline void calculate( void ) {
00101 
00102       Interface::ata_product(A,X,_size);
00103 
00104   }
00105 
00106   void check_result( void ){
00107     if (_size>128) return;
00108     // calculation check
00109 
00110     Interface::matrix_to_stl(X,resu_stl);
00111 
00112     STL_interface<typename Interface::real_type>::ata_product(A_stl,X_stl,_size);
00113 
00114     typename Interface::real_type error=
00115       STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
00116 
00117     if (error>1.e-6){
00118       INFOS("WRONG CALCULATION...residual=" << error);
00119       exit(1);
00120     }
00121 
00122   }
00123 
00124 private :
00125 
00126   typename Interface::stl_matrix A_stl;
00127   typename Interface::stl_matrix X_stl;
00128   typename Interface::stl_matrix resu_stl;
00129 
00130   typename Interface::gene_matrix A_ref;
00131   typename Interface::gene_matrix X_ref;
00132 
00133   typename Interface::gene_matrix A;
00134   typename Interface::gene_matrix X;
00135 
00136 
00137   int _size;
00138 
00139 };
00140 
00141 
00142 #endif
00143 
00144 
00145 


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:42