action_symv.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_symv.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_SYMV
21 #define ACTION_SYMV
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>
32 class Action_symv {
33 
34 public :
35 
36  // Ctor
37 
38  BTL_DONT_INLINE Action_symv( int size ):_size(size)
39  {
40  MESSAGE("Action_symv Ctor");
41 
42  // STL matrix and vector initialization
43  init_matrix_symm<pseudo_random>(A_stl,_size);
44  init_vector<pseudo_random>(B_stl,_size);
45  init_vector<null_function>(X_stl,_size);
46  init_vector<null_function>(resu_stl,_size);
47 
48  // generic matrix and vector initialization
49  Interface::matrix_from_stl(A_ref,A_stl);
50  Interface::matrix_from_stl(A,A_stl);
51  Interface::vector_from_stl(B_ref,B_stl);
52  Interface::vector_from_stl(B,B_stl);
53  Interface::vector_from_stl(X_ref,X_stl);
54  Interface::vector_from_stl(X,X_stl);
55 
56  }
57 
58  // invalidate copy ctor
59 
61  {
62  INFOS("illegal call to Action_symv Copy Ctor");
63  exit(1);
64  }
65 
66  // Dtor
68  Interface::free_matrix(A,_size);
69  Interface::free_vector(B);
70  Interface::free_vector(X);
71  Interface::free_matrix(A_ref,_size);
72  Interface::free_vector(B_ref);
73  Interface::free_vector(X_ref);
74  }
75 
76  // action name
77 
78  static inline std::string name( void )
79  {
80  return "symv_" + Interface::name();
81  }
82 
83  double nb_op_base( void ){
84  return 2.0*_size*_size;
85  }
86 
88 
89  Interface::copy_matrix(A_ref,A,_size);
90  Interface::copy_vector(B_ref,B,_size);
91  Interface::copy_vector(X_ref,X,_size);
92 
93  }
94 
95  BTL_DONT_INLINE void calculate( void ) {
96  BTL_ASM_COMMENT("#begin symv");
97  Interface::symv(A,B,X,_size);
98  BTL_ASM_COMMENT("end symv");
99  }
100 
102  if (_size>128) return;
103  // calculation check
104  Interface::vector_to_stl(X,resu_stl);
105 
107 
108  typename Interface::real_type error=
110 
111  if (error>1.e-5){
112  INFOS("WRONG CALCULATION...residual=" << error);
113  exit(0);
114  }
115 
116  }
117 
118 private :
119 
120  typename Interface::stl_matrix A_stl;
121  typename Interface::stl_vector B_stl;
122  typename Interface::stl_vector X_stl;
123  typename Interface::stl_vector resu_stl;
124 
125  typename Interface::gene_matrix A_ref;
126  typename Interface::gene_vector B_ref;
127  typename Interface::gene_vector X_ref;
128 
129  typename Interface::gene_matrix A;
130  typename Interface::gene_vector B;
131  typename Interface::gene_vector X;
132 
133 
134  int _size;
135 
136 };
137 
138 
139 #endif
Interface::stl_vector B_stl
Definition: action_symv.hh:121
BTL_DONT_INLINE ~Action_symv(void)
Definition: action_symv.hh:67
BTL_DONT_INLINE void check_result(void)
Definition: action_symv.hh:101
BTL_DONT_INLINE Action_symv(int size)
Definition: action_symv.hh:38
Interface::gene_vector X_ref
Definition: action_symv.hh:127
#define BTL_DONT_INLINE
Definition: btl.hh:38
static std::string name(void)
Definition: action_symv.hh:78
Interface::stl_vector resu_stl
Definition: action_symv.hh:123
Interface::gene_vector B
Definition: action_symv.hh:130
Definition: Half.h:150
Matrix< SCALARB, Dynamic, Dynamic > B
Definition: bench_gemm.cpp:36
Interface::stl_vector X_stl
Definition: action_symv.hh:122
double nb_op_base(void)
Definition: action_symv.hh:83
BTL_DONT_INLINE void calculate(void)
Definition: action_symv.hh:95
BTL_DONT_INLINE void initialize(void)
Definition: action_symv.hh:87
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Interface::gene_matrix A_ref
Definition: action_symv.hh:125
Action_symv(const Action_symv &)
Definition: action_symv.hh:60
#define BTL_ASM_COMMENT(X)
Definition: btl.hh:44
Array< double, 1, 3 > e(1./3., 0.5, 2.)
int EIGEN_BLAS_FUNC() symv(const char *uplo, const int *n, const RealScalar *palpha, const RealScalar *pa, const int *lda, const RealScalar *px, const int *incx, const RealScalar *pbeta, RealScalar *py, const int *incy)
Interface::gene_vector X
Definition: action_symv.hh:131
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
Interface::gene_vector B_ref
Definition: action_symv.hh:126
Interface::stl_matrix A_stl
Definition: action_symv.hh:120
Interface::gene_matrix A
Definition: action_symv.hh:129
static void symv(gene_matrix &A, gene_vector &B, gene_vector &X, int N)


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