action_atv_product.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_atv_product.hh
3 // Author : L. Plagne <laurent.plagne@edf.fr)>
4 // Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
5 //=====================================================
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 //
20 #ifndef ACTION_ATV_PRODUCT
21 #define ACTION_ATV_PRODUCT
22 #include "utilities.h"
23 #include "STL_interface.hh"
24 #include <string>
25 #include "init/init_function.hh"
26 #include "init/init_vector.hh"
27 #include "init/init_matrix.hh"
28 
29 using namespace std;
30 
31 template<class Interface>
33 
34 public :
35 
36  Action_atv_product( int size ) : _size(size)
37  {
38  MESSAGE("Action_atv_product Ctor");
39 
40  // STL matrix and vector initialization
41 
42  init_matrix<pseudo_random>(A_stl,_size);
43  init_vector<pseudo_random>(B_stl,_size);
44  init_vector<null_function>(X_stl,_size);
45  init_vector<null_function>(resu_stl,_size);
46 
47  // generic matrix and vector initialization
48 
49  Interface::matrix_from_stl(A_ref,A_stl);
50  Interface::vector_from_stl(B_ref,B_stl);
51  Interface::vector_from_stl(X_ref,X_stl);
52 
53  Interface::matrix_from_stl(A,A_stl);
54  Interface::vector_from_stl(B,B_stl);
55  Interface::vector_from_stl(X,X_stl);
56  }
57 
58  // invalidate copy ctor
60  {
61  INFOS("illegal call to Action_atv_product Copy Ctor");
62  exit(1);
63  }
64 
66  {
67  MESSAGE("Action_atv_product Dtor");
68 
69  Interface::free_matrix(A,_size);
70  Interface::free_vector(B);
71  Interface::free_vector(X);
72 
73  Interface::free_matrix(A_ref,_size);
74  Interface::free_vector(B_ref);
75  Interface::free_vector(X_ref);
76  }
77 
78  static inline std::string name() { return "atv_" + Interface::name(); }
79 
80  double nb_op_base( void ) { return 2.0*_size*_size; }
81 
82  inline void initialize( void ){
83  Interface::copy_matrix(A_ref,A,_size);
84  Interface::copy_vector(B_ref,B,_size);
85  Interface::copy_vector(X_ref,X,_size);
86  }
87 
88  BTL_DONT_INLINE void calculate( void ) {
89  BTL_ASM_COMMENT("begin atv");
90  Interface::atv_product(A,B,X,_size);
91  BTL_ASM_COMMENT("end atv");
92  }
93 
94  void check_result( void )
95  {
96  if (_size>128) return;
97  Interface::vector_to_stl(X,resu_stl);
98 
100 
101  typename Interface::real_type error=
103 
104  if (error>1.e-6){
105  INFOS("WRONG CALCULATION...residual=" << error);
106  exit(1);
107  }
108  }
109 
110 private :
111 
112  typename Interface::stl_matrix A_stl;
113  typename Interface::stl_vector B_stl;
114  typename Interface::stl_vector X_stl;
115  typename Interface::stl_vector resu_stl;
116 
117  typename Interface::gene_matrix A_ref;
118  typename Interface::gene_vector B_ref;
119  typename Interface::gene_vector X_ref;
120 
121  typename Interface::gene_matrix A;
122  typename Interface::gene_vector B;
123  typename Interface::gene_vector X;
124 
125 
126  int _size;
127 
128 };
129 
130 
131 #endif
132 
133 
134 
Action_atv_product::nb_op_base
double nb_op_base(void)
Definition: action_atv_product.hh:80
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
STL_interface.hh
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Action_atv_product::calculate
BTL_DONT_INLINE void calculate(void)
Definition: action_atv_product.hh:88
Action_atv_product::name
static std::string name()
Definition: action_atv_product.hh:78
Action_atv_product::B_stl
Interface::stl_vector B_stl
Definition: action_atv_product.hh:113
X
#define X
Definition: icosphere.cpp:20
Action_atv_product::A_ref
Interface::gene_matrix A_ref
Definition: action_atv_product.hh:117
Action_atv_product::A_stl
Interface::stl_matrix A_stl
Definition: action_atv_product.hh:112
Action_atv_product::X_ref
Interface::gene_vector X_ref
Definition: action_atv_product.hh:119
Action_atv_product::Action_atv_product
Action_atv_product(const Action_atv_product &)
Definition: action_atv_product.hh:59
Action_atv_product::X_stl
Interface::stl_vector X_stl
Definition: action_atv_product.hh:114
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
name
static char name[]
Definition: rgamma.c:72
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
init_function.hh
Action_atv_product::_size
int _size
Definition: action_atv_product.hh:126
MESSAGE
#define MESSAGE(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:76
BTL_ASM_COMMENT
#define BTL_ASM_COMMENT(X)
Definition: btl.hh:44
Action_atv_product::X
Interface::gene_vector X
Definition: action_atv_product.hh:123
Action_atv_product
Definition: action_atv_product.hh:32
init_vector.hh
Action_atv_product::B_ref
Interface::gene_vector B_ref
Definition: action_atv_product.hh:118
init_matrix.hh
STL_interface::atv_product
static void atv_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: STL_interface.hh:171
error
static double error
Definition: testRot3.cpp:37
Action_atv_product::~Action_atv_product
~Action_atv_product(void)
Definition: action_atv_product.hh:65
Action_atv_product::check_result
void check_result(void)
Definition: action_atv_product.hh:94
Action_atv_product::resu_stl
Interface::stl_vector resu_stl
Definition: action_atv_product.hh:115
INFOS
#define INFOS(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:22
std
Definition: BFloat16.h:88
Action_atv_product::Action_atv_product
Action_atv_product(int size)
Definition: action_atv_product.hh:36
Action_atv_product::A
Interface::gene_matrix A
Definition: action_atv_product.hh:121
copy_matrix
void copy_matrix(MatrixType &m)
Definition: bench_move_semantics.cpp:19
Action_atv_product::initialize
void initialize(void)
Definition: action_atv_product.hh:82
STL_interface::norm_diff
static real norm_diff(const stl_vector &A, const stl_vector &B)
Definition: STL_interface.hh:203
Action_atv_product::B
Interface::gene_vector B
Definition: action_atv_product.hh:122
BTL_DONT_INLINE
#define BTL_DONT_INLINE
Definition: btl.hh:38


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:00:25