action_matrix_matrix_product.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_matrix_matrix_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_MATRIX_MATRIX_PRODUCT
21 #define ACTION_MATRIX_MATRIX_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  // Ctor
37 
39  {
40  MESSAGE("Action_matrix_matrix_product Ctor");
41 
42  // STL matrix and vector initialization
43 
44  init_matrix<pseudo_random>(A_stl,_size);
45  init_matrix<pseudo_random>(B_stl,_size);
46  init_matrix<null_function>(X_stl,_size);
47  init_matrix<null_function>(resu_stl,_size);
48 
49  // generic matrix and vector initialization
50 
51  Interface::matrix_from_stl(A_ref,A_stl);
52  Interface::matrix_from_stl(B_ref,B_stl);
53  Interface::matrix_from_stl(X_ref,X_stl);
54 
55  Interface::matrix_from_stl(A,A_stl);
56  Interface::matrix_from_stl(B,B_stl);
57  Interface::matrix_from_stl(X,X_stl);
58 
59  }
60 
61  // invalidate copy ctor
62 
64  {
65  INFOS("illegal call to Action_matrix_matrix_product Copy Ctor");
66  exit(0);
67  }
68 
69  // Dtor
70 
72 
73  MESSAGE("Action_matrix_matrix_product Dtor");
74 
75  // deallocation
76 
77  Interface::free_matrix(A,_size);
78  Interface::free_matrix(B,_size);
79  Interface::free_matrix(X,_size);
80 
81  Interface::free_matrix(A_ref,_size);
82  Interface::free_matrix(B_ref,_size);
83  Interface::free_matrix(X_ref,_size);
84 
85  }
86 
87  // action name
88 
89  static inline std::string name( void )
90  {
91  return "matrix_matrix_"+Interface::name();
92  }
93 
94  double nb_op_base( void ){
95  return 2.0*_size*_size*_size;
96  }
97 
98  inline void initialize( void ){
99 
100  Interface::copy_matrix(A_ref,A,_size);
101  Interface::copy_matrix(B_ref,B,_size);
102  Interface::copy_matrix(X_ref,X,_size);
103 
104  }
105 
106  inline void calculate( void ) {
107  Interface::matrix_matrix_product(A,B,X,_size);
108  }
109 
110  void check_result( void ){
111 
112  // calculation check
113  if (_size<200)
114  {
115  Interface::matrix_to_stl(X,resu_stl);
117  typename Interface::real_type error=
119  if (error>1.e-6){
120  INFOS("WRONG CALCULATION...residual=" << error);
121  exit(1);
122  }
123  }
124  }
125 
126 private :
127 
128  typename Interface::stl_matrix A_stl;
129  typename Interface::stl_matrix B_stl;
130  typename Interface::stl_matrix X_stl;
131  typename Interface::stl_matrix resu_stl;
132 
133  typename Interface::gene_matrix A_ref;
134  typename Interface::gene_matrix B_ref;
135  typename Interface::gene_matrix X_ref;
136 
137  typename Interface::gene_matrix A;
138  typename Interface::gene_matrix B;
139  typename Interface::gene_matrix X;
140 
141 
142  int _size;
143 
144 };
145 
146 
147 #endif
148 
149 
150 
Action_matrix_matrix_product::nb_op_base
double nb_op_base(void)
Definition: action_matrix_matrix_product.hh:94
Action_matrix_matrix_product::name
static std::string name(void)
Definition: action_matrix_matrix_product.hh:89
Action_matrix_matrix_product::X_stl
Interface::stl_matrix X_stl
Definition: action_matrix_matrix_product.hh:130
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
Action_matrix_matrix_product::Action_matrix_matrix_product
Action_matrix_matrix_product(const Action_matrix_matrix_product &)
Definition: action_matrix_matrix_product.hh:63
STL_interface.hh
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Action_matrix_matrix_product::B_ref
Interface::gene_matrix B_ref
Definition: action_matrix_matrix_product.hh:134
Action_matrix_matrix_product::X_ref
Interface::gene_matrix X_ref
Definition: action_matrix_matrix_product.hh:135
X
#define X
Definition: icosphere.cpp:20
Action_matrix_matrix_product::X
Interface::gene_matrix X
Definition: action_matrix_matrix_product.hh:139
Action_matrix_matrix_product::A_stl
Interface::stl_matrix A_stl
Definition: action_matrix_matrix_product.hh:128
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
MESSAGE
#define MESSAGE(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:76
Action_matrix_matrix_product::check_result
void check_result(void)
Definition: action_matrix_matrix_product.hh:110
Action_matrix_matrix_product::A
Interface::gene_matrix A
Definition: action_matrix_matrix_product.hh:137
Action_matrix_matrix_product::_size
int _size
Definition: action_matrix_matrix_product.hh:142
Action_matrix_matrix_product::B_stl
Interface::stl_matrix B_stl
Definition: action_matrix_matrix_product.hh:129
Action_matrix_matrix_product::B
Interface::gene_matrix B
Definition: action_matrix_matrix_product.hh:138
STL_interface::matrix_matrix_product
static void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: STL_interface.hh:112
init_vector.hh
Action_matrix_matrix_product::initialize
void initialize(void)
Definition: action_matrix_matrix_product.hh:98
init_matrix.hh
Action_matrix_matrix_product::resu_stl
Interface::stl_matrix resu_stl
Definition: action_matrix_matrix_product.hh:131
Action_matrix_matrix_product::A_ref
Interface::gene_matrix A_ref
Definition: action_matrix_matrix_product.hh:133
Action_matrix_matrix_product::~Action_matrix_matrix_product
~Action_matrix_matrix_product(void)
Definition: action_matrix_matrix_product.hh:71
Action_matrix_matrix_product::calculate
void calculate(void)
Definition: action_matrix_matrix_product.hh:106
error
static double error
Definition: testRot3.cpp:37
INFOS
#define INFOS(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:22
std
Definition: BFloat16.h:88
copy_matrix
void copy_matrix(MatrixType &m)
Definition: bench_move_semantics.cpp:19
STL_interface::norm_diff
static real norm_diff(const stl_vector &A, const stl_vector &B)
Definition: STL_interface.hh:203
Action_matrix_matrix_product::Action_matrix_matrix_product
Action_matrix_matrix_product(int size)
Definition: action_matrix_matrix_product.hh:38
Action_matrix_matrix_product
Definition: action_matrix_matrix_product.hh:32


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:31:51