action_rot.hh
Go to the documentation of this file.
00001 
00002 // This program is free software; you can redistribute it and/or
00003 // modify it under the terms of the GNU General Public License
00004 // as published by the Free Software Foundation; either version 2
00005 // of the License, or (at your option) any later version.
00006 //
00007 // This program is distributed in the hope that it will be useful,
00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 // GNU General Public License for more details.
00011 // You should have received a copy of the GNU General Public License
00012 // along with this program; if not, write to the Free Software
00013 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00014 //
00015 #ifndef ACTION_ROT
00016 #define ACTION_ROT
00017 #include "utilities.h"
00018 #include "STL_interface.hh"
00019 #include <string>
00020 #include "init/init_function.hh"
00021 #include "init/init_vector.hh"
00022 #include "init/init_matrix.hh"
00023 
00024 using namespace std;
00025 
00026 template<class Interface>
00027 class Action_rot {
00028 
00029 public :
00030 
00031   // Ctor
00032   BTL_DONT_INLINE Action_rot( int size ):_size(size)
00033   {
00034     MESSAGE("Action_rot Ctor");
00035 
00036     // STL matrix and vector initialization
00037     typename Interface::stl_matrix tmp;
00038     init_vector<pseudo_random>(A_stl,_size);
00039     init_vector<pseudo_random>(B_stl,_size);
00040 
00041     // generic matrix and vector initialization
00042     Interface::vector_from_stl(A_ref,A_stl);
00043     Interface::vector_from_stl(A,A_stl);
00044     Interface::vector_from_stl(B_ref,B_stl);
00045     Interface::vector_from_stl(B,B_stl);
00046   }
00047 
00048   // invalidate copy ctor
00049   Action_rot( const  Action_rot & )
00050   {
00051     INFOS("illegal call to Action_rot Copy Ctor");
00052     exit(1);
00053   }
00054 
00055   // Dtor
00056   BTL_DONT_INLINE ~Action_rot( void ){
00057     MESSAGE("Action_rot Dtor");
00058     Interface::free_vector(A);
00059     Interface::free_vector(B);
00060     Interface::free_vector(A_ref);
00061     Interface::free_vector(B_ref);
00062   }
00063 
00064   // action name
00065   static inline std::string name( void )
00066   {
00067     return "rot_" + Interface::name();
00068   }
00069 
00070   double nb_op_base( void ){
00071     return 6.0*_size;
00072   }
00073 
00074   BTL_DONT_INLINE  void initialize( void ){
00075     Interface::copy_vector(A_ref,A,_size);
00076     Interface::copy_vector(B_ref,B,_size);
00077   }
00078 
00079   BTL_DONT_INLINE void calculate( void ) {
00080     BTL_ASM_COMMENT("#begin rot");
00081     Interface::rot(A,B,0.5,0.6,_size);
00082     BTL_ASM_COMMENT("end rot");
00083   }
00084 
00085   BTL_DONT_INLINE void check_result( void ){
00086     // calculation check
00087 //     Interface::vector_to_stl(X,resu_stl);
00088 
00089 //     STL_interface<typename Interface::real_type>::rot(A_stl,B_stl,X_stl,_size);
00090 
00091 //     typename Interface::real_type error=
00092 //       STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
00093 
00094 //     if (error>1.e-3){
00095 //       INFOS("WRONG CALCULATION...residual=" << error);
00096 //       exit(0);
00097 //     }
00098 
00099   }
00100 
00101 private :
00102 
00103   typename Interface::stl_vector A_stl;
00104   typename Interface::stl_vector B_stl;
00105 
00106   typename Interface::gene_vector A_ref;
00107   typename Interface::gene_vector B_ref;
00108 
00109   typename Interface::gene_vector A;
00110   typename Interface::gene_vector B;
00111 
00112   int _size;
00113 };
00114 
00115 
00116 #endif


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