action_syr2.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_syr2.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_SYR2
21 #define ACTION_SYR2
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_syr2 {
33 
34 public :
35 
36  // Ctor
37 
39  {
40  // STL matrix and vector initialization
41  typename Interface::stl_matrix tmp;
42  init_matrix<pseudo_random>(A_stl,_size);
43  init_vector<pseudo_random>(B_stl,_size);
44  init_vector<pseudo_random>(X_stl,_size);
45  init_vector<null_function>(resu_stl,_size);
46 
47  // generic matrix and vector initialization
48  Interface::matrix_from_stl(A_ref,A_stl);
49  Interface::matrix_from_stl(A,A_stl);
50  Interface::vector_from_stl(B_ref,B_stl);
51  Interface::vector_from_stl(B,B_stl);
52  Interface::vector_from_stl(X_ref,X_stl);
53  Interface::vector_from_stl(X,X_stl);
54  }
55 
56  // invalidate copy ctor
58  {
59  INFOS("illegal call to Action_syr2 Copy Ctor");
60  exit(1);
61  }
62 
63  // Dtor
65  Interface::free_matrix(A,_size);
66  Interface::free_vector(B);
67  Interface::free_vector(X);
68  Interface::free_matrix(A_ref,_size);
69  Interface::free_vector(B_ref);
70  Interface::free_vector(X_ref);
71  }
72 
73  // action name
74 
75  static inline std::string name( void )
76  {
77  return "syr2_" + Interface::name();
78  }
79 
80  double nb_op_base( void ){
81  return 2.0*_size*_size;
82  }
83 
85  Interface::copy_matrix(A_ref,A,_size);
86  Interface::copy_vector(B_ref,B,_size);
87  Interface::copy_vector(X_ref,X,_size);
88  }
89 
90  BTL_DONT_INLINE void calculate( void ) {
91  BTL_ASM_COMMENT("#begin syr2");
92  Interface::syr2(A,B,X,_size);
93  BTL_ASM_COMMENT("end syr2");
94  }
95 
97  // calculation check
98  Interface::vector_to_stl(X,resu_stl);
99 
101 
102  typename Interface::real_type error=
104 
105  if (error>1.e-3){
106  INFOS("WRONG CALCULATION...residual=" << error);
107 // exit(0);
108  }
109 
110  }
111 
112 private :
113 
114  typename Interface::stl_matrix A_stl;
115  typename Interface::stl_vector B_stl;
116  typename Interface::stl_vector X_stl;
117  typename Interface::stl_vector resu_stl;
118 
119  typename Interface::gene_matrix A_ref;
120  typename Interface::gene_vector B_ref;
121  typename Interface::gene_vector X_ref;
122 
123  typename Interface::gene_matrix A;
124  typename Interface::gene_vector B;
125  typename Interface::gene_vector X;
126 
127 
128  int _size;
129 
130 };
131 
132 
133 #endif
Action_syr2::A_ref
Interface::gene_matrix A_ref
Definition: action_syr2.hh:119
Action_syr2::B
Interface::gene_vector B
Definition: action_syr2.hh:124
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
Action_syr2::Action_syr2
BTL_DONT_INLINE Action_syr2(int size)
Definition: action_syr2.hh:38
Action_syr2::A_stl
Interface::stl_matrix A_stl
Definition: action_syr2.hh:114
STL_interface.hh
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Action_syr2::nb_op_base
double nb_op_base(void)
Definition: action_syr2.hh:80
Action_syr2::check_result
BTL_DONT_INLINE void check_result(void)
Definition: action_syr2.hh:96
X
#define X
Definition: icosphere.cpp:20
Action_syr2::name
static std::string name(void)
Definition: action_syr2.hh:75
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_syr2::~Action_syr2
BTL_DONT_INLINE ~Action_syr2(void)
Definition: action_syr2.hh:64
BTL_ASM_COMMENT
#define BTL_ASM_COMMENT(X)
Definition: btl.hh:44
Action_syr2::resu_stl
Interface::stl_vector resu_stl
Definition: action_syr2.hh:117
init_vector.hh
init_matrix.hh
Action_syr2
Definition: action_syr2.hh:32
Action_syr2::_size
int _size
Definition: action_syr2.hh:128
Action_syr2::initialize
BTL_DONT_INLINE void initialize(void)
Definition: action_syr2.hh:84
Action_syr2::B_stl
Interface::stl_vector B_stl
Definition: action_syr2.hh:115
Action_syr2::A
Interface::gene_matrix A
Definition: action_syr2.hh:123
Action_syr2::X_stl
Interface::stl_vector X_stl
Definition: action_syr2.hh:116
error
static double error
Definition: testRot3.cpp:37
syr2
int EIGEN_BLAS_FUNC() syr2(const char *uplo, const int *n, const RealScalar *palpha, const RealScalar *px, const int *incx, const RealScalar *py, const int *incy, RealScalar *pc, const int *ldc)
Definition: level2_real_impl.h:105
Action_syr2::X_ref
Interface::gene_vector X_ref
Definition: action_syr2.hh:121
Action_syr2::B_ref
Interface::gene_vector B_ref
Definition: action_syr2.hh:120
INFOS
#define INFOS(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:22
Action_syr2::calculate
BTL_DONT_INLINE void calculate(void)
Definition: action_syr2.hh:90
std
Definition: BFloat16.h:88
copy_matrix
void copy_matrix(MatrixType &m)
Definition: bench_move_semantics.cpp:19
STL_interface::syr2
static void syr2(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: STL_interface.hh:153
STL_interface::norm_diff
static real norm_diff(const stl_vector &A, const stl_vector &B)
Definition: STL_interface.hh:203
Action_syr2::Action_syr2
Action_syr2(const Action_syr2 &)
Definition: action_syr2.hh:57
Action_syr2::X
Interface::gene_vector X
Definition: action_syr2.hh:125
BTL_DONT_INLINE
#define BTL_DONT_INLINE
Definition: btl.hh:38


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:48