• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 // GNU General Public License for more details.
11 // You should have received a copy of the GNU General Public License
12 // along with this program; if not, write to the Free Software
13 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
14 //
15 #ifndef ACTION_ROT
16 #define ACTION_ROT
17 #include "utilities.h"
18 #include "STL_interface.hh"
19 #include <string>
20 #include "init/init_function.hh"
21 #include "init/init_vector.hh"
22 #include "init/init_matrix.hh"
23 
24 using namespace std;
25 
26 template<class Interface>
27 class Action_rot {
28 
29 public :
30 
31   // Ctor
Action_rot(int size)32   BTL_DONT_INLINE Action_rot( int size ):_size(size)
33   {
34     MESSAGE("Action_rot Ctor");
35 
36     // STL matrix and vector initialization
37     typename Interface::stl_matrix tmp;
38     init_vector<pseudo_random>(A_stl,_size);
39     init_vector<pseudo_random>(B_stl,_size);
40 
41     // generic matrix and vector initialization
42     Interface::vector_from_stl(A_ref,A_stl);
43     Interface::vector_from_stl(A,A_stl);
44     Interface::vector_from_stl(B_ref,B_stl);
45     Interface::vector_from_stl(B,B_stl);
46   }
47 
48   // invalidate copy ctor
Action_rot(const Action_rot &)49   Action_rot( const  Action_rot & )
50   {
51     INFOS("illegal call to Action_rot Copy Ctor");
52     exit(1);
53   }
54 
55   // Dtor
~Action_rot(void)56   BTL_DONT_INLINE ~Action_rot( void ){
57     MESSAGE("Action_rot Dtor");
58     Interface::free_vector(A);
59     Interface::free_vector(B);
60     Interface::free_vector(A_ref);
61     Interface::free_vector(B_ref);
62   }
63 
64   // action name
name(void)65   static inline std::string name( void )
66   {
67     return "rot_" + Interface::name();
68   }
69 
nb_op_base(void)70   double nb_op_base( void ){
71     return 6.0*_size;
72   }
73 
initialize(void)74   BTL_DONT_INLINE  void initialize( void ){
75     Interface::copy_vector(A_ref,A,_size);
76     Interface::copy_vector(B_ref,B,_size);
77   }
78 
calculate(void)79   BTL_DONT_INLINE void calculate( void ) {
80     BTL_ASM_COMMENT("#begin rot");
81     Interface::rot(A,B,0.5,0.6,_size);
82     BTL_ASM_COMMENT("end rot");
83   }
84 
check_result(void)85   BTL_DONT_INLINE void check_result( void ){
86     // calculation check
87 //     Interface::vector_to_stl(X,resu_stl);
88 
89 //     STL_interface<typename Interface::real_type>::rot(A_stl,B_stl,X_stl,_size);
90 
91 //     typename Interface::real_type error=
92 //       STL_interface<typename Interface::real_type>::norm_diff(X_stl,resu_stl);
93 
94 //     if (error>1.e-3){
95 //       INFOS("WRONG CALCULATION...residual=" << error);
96 //       exit(0);
97 //     }
98 
99   }
100 
101 private :
102 
103   typename Interface::stl_vector A_stl;
104   typename Interface::stl_vector B_stl;
105 
106   typename Interface::gene_vector A_ref;
107   typename Interface::gene_vector B_ref;
108 
109   typename Interface::gene_vector A;
110   typename Interface::gene_vector B;
111 
112   int _size;
113 };
114 
115 
116 #endif
117