action_axpby.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : action_axpby.hh
3 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
4 //=====================================================
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 #ifndef ACTION_AXPBY
20 #define ACTION_AXPBY
21 #include "utilities.h"
22 #include "STL_interface.hh"
23 #include <string>
24 #include "init/init_function.hh"
25 #include "init/init_vector.hh"
26 #include "init/init_matrix.hh"
27 
28 using namespace std;
29 
30 template<class Interface>
31 class Action_axpby {
32 
33 public :
34 
35  // Ctor
36  Action_axpby( int size ):_alpha(0.5),_beta(0.95),_size(size)
37  {
38  MESSAGE("Action_axpby Ctor");
39 
40  // STL vector initialization
41  init_vector<pseudo_random>(X_stl,_size);
42  init_vector<pseudo_random>(Y_stl,_size);
43  init_vector<null_function>(resu_stl,_size);
44 
45  // generic matrix and vector initialization
46  Interface::vector_from_stl(X_ref,X_stl);
47  Interface::vector_from_stl(Y_ref,Y_stl);
48 
49  Interface::vector_from_stl(X,X_stl);
50  Interface::vector_from_stl(Y,Y_stl);
51  }
52 
53  // invalidate copy ctor
55  {
56  INFOS("illegal call to Action_axpby Copy Ctor");
57  exit(1);
58  }
59 
60  // Dtor
61  ~Action_axpby( void ){
62  MESSAGE("Action_axpby Dtor");
63 
64  // deallocation
65  Interface::free_vector(X_ref);
66  Interface::free_vector(Y_ref);
67 
68  Interface::free_vector(X);
69  Interface::free_vector(Y);
70  }
71 
72  // action name
73  static inline std::string name( void )
74  {
75  return "axpby_"+Interface::name();
76  }
77 
78  double nb_op_base( void ){
79  return 3.0*_size;
80  }
81 
82  inline void initialize( void ){
83  Interface::copy_vector(X_ref,X,_size);
84  Interface::copy_vector(Y_ref,Y,_size);
85  }
86 
87  inline void calculate( void ) {
88  BTL_ASM_COMMENT("mybegin axpby");
89  Interface::axpby(_alpha,X,_beta,Y,_size);
90  BTL_ASM_COMMENT("myend axpby");
91  }
92 
93  void check_result( void ){
94  if (_size>128) return;
95  // calculation check
96  Interface::vector_to_stl(Y,resu_stl);
97 
98  STL_interface<typename Interface::real_type>::axpby(_alpha,X_stl,_beta,Y_stl,_size);
99 
100  typename Interface::real_type error=
102 
103  if (error>1.e-6){
104  INFOS("WRONG CALCULATION...residual=" << error);
105  exit(2);
106  }
107  }
108 
109 private :
110 
111  typename Interface::stl_vector X_stl;
112  typename Interface::stl_vector Y_stl;
113  typename Interface::stl_vector resu_stl;
114 
115  typename Interface::gene_vector X_ref;
116  typename Interface::gene_vector Y_ref;
117 
118  typename Interface::gene_vector X;
119  typename Interface::gene_vector Y;
120 
121  typename Interface::real_type _alpha;
122  typename Interface::real_type _beta;
123 
124  int _size;
125 };
126 
127 #endif
STL_interface.hh
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
Action_axpby::name
static std::string name(void)
Definition: action_axpby.hh:73
Action_axpby::_alpha
Interface::real_type _alpha
Definition: action_axpby.hh:121
X
#define X
Definition: icosphere.cpp:20
Action_axpby::~Action_axpby
~Action_axpby(void)
Definition: action_axpby.hh:61
Action_axpby::X_ref
Interface::gene_vector X_ref
Definition: action_axpby.hh:115
Action_axpby::Action_axpby
Action_axpby(const Action_axpby &)
Definition: action_axpby.hh:54
name
static char name[]
Definition: rgamma.c:72
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
init_function.hh
Action_axpby
Definition: action_axpby.hh:31
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_axpby::nb_op_base
double nb_op_base(void)
Definition: action_axpby.hh:78
Action_axpby::Action_axpby
Action_axpby(int size)
Definition: action_axpby.hh:36
Action_axpby::resu_stl
Interface::stl_vector resu_stl
Definition: action_axpby.hh:113
init_vector.hh
init_matrix.hh
STL_interface::axpby
static void axpby(real a, const gene_vector &X, real b, gene_vector &Y, int N)
Definition: STL_interface.hh:187
Action_axpby::Y
Interface::gene_vector Y
Definition: action_axpby.hh:119
Action_axpby::X_stl
Interface::stl_vector X_stl
Definition: action_axpby.hh:111
Action_axpby::_beta
Interface::real_type _beta
Definition: action_axpby.hh:122
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
Action_axpby::Y_ref
Interface::gene_vector Y_ref
Definition: action_axpby.hh:116
STL_interface::norm_diff
static real norm_diff(const stl_vector &A, const stl_vector &B)
Definition: STL_interface.hh:203
Action_axpby::initialize
void initialize(void)
Definition: action_axpby.hh:82
Action_axpby::Y_stl
Interface::stl_vector Y_stl
Definition: action_axpby.hh:112
Action_axpby::X
Interface::gene_vector X
Definition: action_axpby.hh:118
Action_axpby::check_result
void check_result(void)
Definition: action_axpby.hh:93
Action_axpby::calculate
void calculate(void)
Definition: action_axpby.hh:87
Action_axpby::_size
int _size
Definition: action_axpby.hh:124


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