action_matrix_vector_product.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_matrix_vector_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_VECTOR_PRODUCT
21 #define ACTION_MATRIX_VECTOR_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_vector_product Ctor");
41 
42  // STL matrix and vector initialization
43 
44  init_matrix<pseudo_random>(A_stl,_size);
45  init_vector<pseudo_random>(B_stl,_size);
46  init_vector<null_function>(X_stl,_size);
47  init_vector<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(A,A_stl);
53  Interface::vector_from_stl(B_ref,B_stl);
54  Interface::vector_from_stl(B,B_stl);
55  Interface::vector_from_stl(X_ref,X_stl);
56  Interface::vector_from_stl(X,X_stl);
57 
58  }
59 
60  // invalidate copy ctor
61 
63  {
64  INFOS("illegal call to Action_matrix_vector_product Copy Ctor");
65  exit(1);
66  }
67 
68  // Dtor
69 
71 
72  MESSAGE("Action_matrix_vector_product Dtor");
73 
74  // deallocation
75 
76  Interface::free_matrix(A,_size);
77  Interface::free_vector(B);
78  Interface::free_vector(X);
79 
80  Interface::free_matrix(A_ref,_size);
81  Interface::free_vector(B_ref);
82  Interface::free_vector(X_ref);
83 
84  }
85 
86  // action name
87 
88  static inline std::string name( void )
89  {
90  return "matrix_vector_" + Interface::name();
91  }
92 
93  double nb_op_base( void ){
94  return 2.0*_size*_size;
95  }
96 
98 
99  Interface::copy_matrix(A_ref,A,_size);
100  Interface::copy_vector(B_ref,B,_size);
101  Interface::copy_vector(X_ref,X,_size);
102 
103  }
104 
105  BTL_DONT_INLINE void calculate( void ) {
106  BTL_ASM_COMMENT("#begin matrix_vector_product");
107  Interface::matrix_vector_product(A,B,X,_size);
108  BTL_ASM_COMMENT("end matrix_vector_product");
109  }
110 
112 
113  // calculation check
114 
115  Interface::vector_to_stl(X,resu_stl);
116 
118 
119  typename Interface::real_type error=
121 
122  if (error>1.e-5){
123  INFOS("WRONG CALCULATION...residual=" << error);
124  exit(0);
125  }
126 
127  }
128 
129 private :
130 
131  typename Interface::stl_matrix A_stl;
132  typename Interface::stl_vector B_stl;
133  typename Interface::stl_vector X_stl;
134  typename Interface::stl_vector resu_stl;
135 
136  typename Interface::gene_matrix A_ref;
137  typename Interface::gene_vector B_ref;
138  typename Interface::gene_vector X_ref;
139 
140  typename Interface::gene_matrix A;
141  typename Interface::gene_vector B;
142  typename Interface::gene_vector X;
143 
144 
145  int _size;
146 
147 };
148 
149 
150 #endif
151 
152 
153 
#define BTL_DONT_INLINE
Definition: btl.hh:38
Definition: Half.h:150
Matrix< SCALARB, Dynamic, Dynamic > B
Definition: bench_gemm.cpp:36
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
BTL_DONT_INLINE Action_matrix_vector_product(int size)
BTL_DONT_INLINE ~Action_matrix_vector_product(void)
#define BTL_ASM_COMMENT(X)
Definition: btl.hh:44
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Action_matrix_vector_product(const Action_matrix_vector_product &)
static void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
static double error
Definition: testRot3.cpp:39
static real norm_diff(const stl_vector &A, const stl_vector &B)
#define X
Definition: icosphere.cpp:20


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:36