blaze_interface.hh
Go to the documentation of this file.
1 //=====================================================
2 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
3 //=====================================================
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 #ifndef BLAZE_INTERFACE_HH
19 #define BLAZE_INTERFACE_HH
20 
21 #include <blaze/Math.h>
22 #include <blaze/Blaze.h>
23 #include <Eigen/Core>
24 // using namespace blaze;
25 
26 #include <vector>
27 
28 template<class real>
30 
31 public :
32 
33  typedef real real_type ;
34 
35  typedef std::vector<real> stl_vector;
36  typedef std::vector<stl_vector > stl_matrix;
37 
38  typedef blaze::DynamicMatrix<real,blaze::columnMajor> gene_matrix;
39  typedef blaze::DynamicVector<real> gene_vector;
40 
41  static inline std::string name() { return "blaze"; }
42 
43  static void free_matrix(gene_matrix & A, int N){
44  return ;
45  }
46 
47  static void free_vector(gene_vector & B){
48  return ;
49  }
50 
51  static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
52  A.resize(A_stl[0].size(), A_stl.size());
53 
54  for (int j=0; j<A_stl.size() ; j++){
55  for (int i=0; i<A_stl[j].size() ; i++){
56  A(i,j) = A_stl[j][i];
57  }
58  }
59  }
60 
61  static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
62  B.resize(B_stl.size());
63  for (int i=0; i<B_stl.size() ; i++){
64  B[i] = B_stl[i];
65  }
66  }
67 
68  static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
69  for (int i=0; i<B_stl.size() ; i++){
70  B_stl[i] = B[i];
71  }
72  }
73 
74  static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
75  int N=A_stl.size();
76  for (int j=0;j<N;j++){
77  A_stl[j].resize(N);
78  for (int i=0;i<N;i++){
79  A_stl[j][i] = A(i,j);
80  }
81  }
82  }
83 
85  X = (A*B);
86  }
87 
89  X = (trans(A)*trans(B));
90  }
91 
92  static EIGEN_DONT_INLINE void ata_product(const gene_matrix & A, gene_matrix & X, int N){
93  X = (trans(A)*A);
94  }
95 
96  static EIGEN_DONT_INLINE void aat_product(const gene_matrix & A, gene_matrix & X, int N){
97  X = (A*trans(A));
98  }
99 
101  X = (A*B);
102  }
103 
105  X = (trans(A)*B);
106  }
107 
108  static EIGEN_DONT_INLINE void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
109  Y += coef * X;
110  }
111 
112  static EIGEN_DONT_INLINE void axpby(real a, const gene_vector & X, real b, gene_vector & Y, int N){
113  Y = a*X + b*Y;
114  }
115 
116 // static inline void cholesky(const gene_matrix & X, gene_matrix & C, int N){
117 // C = X;
118 // recursive_cholesky(C);
119 // }
120 
121 // static inline void lu_decomp(const gene_matrix & X, gene_matrix & R, int N){
122 // R = X;
123 // std::vector<int> ipvt(N);
124 // lu_factor(R, ipvt);
125 // }
126 
127 // static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
128 // X = lower_trisolve(L, B);
129 // }
130 
131  static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
132  cible = source;
133  }
134 
135  static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
136  cible = source;
137  }
138 
139 };
140 
141 #endif
blaze_interface::matrix_from_stl
static void matrix_from_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: blaze_interface.hh:51
blaze_interface::name
static std::string name()
Definition: blaze_interface.hh:41
blaze_interface::axpy
static EIGEN_DONT_INLINE void axpy(const real coef, const gene_vector &X, gene_vector &Y, int N)
Definition: blaze_interface.hh:108
b
Scalar * b
Definition: benchVecAdd.cpp:17
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
blaze_interface::copy_vector
static void copy_vector(const gene_vector &source, gene_vector &cible, int N)
Definition: blaze_interface.hh:135
trans
static char trans
Definition: blas_interface.hh:58
blaze_interface::real_type
real real_type
Definition: blaze_interface.hh:33
B
Definition: test_numpy_dtypes.cpp:299
blaze_interface::vector_from_stl
static void vector_from_stl(gene_vector &B, stl_vector &B_stl)
Definition: blaze_interface.hh:61
E1::B
@ B
blaze_interface::stl_vector
std::vector< real > stl_vector
Definition: blaze_interface.hh:35
X
#define X
Definition: icosphere.cpp:20
blaze_interface::atv_product
static EIGEN_DONT_INLINE void atv_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: blaze_interface.hh:104
blaze_interface::matrix_vector_product
static EIGEN_DONT_INLINE void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: blaze_interface.hh:100
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
blaze_interface::free_vector
static void free_vector(gene_vector &B)
Definition: blaze_interface.hh:47
blaze_interface::vector_to_stl
static void vector_to_stl(gene_vector &B, stl_vector &B_stl)
Definition: blaze_interface.hh:68
blaze_interface::aat_product
static EIGEN_DONT_INLINE void aat_product(const gene_matrix &A, gene_matrix &X, int N)
Definition: blaze_interface.hh:96
blaze_interface::stl_matrix
std::vector< stl_vector > stl_matrix
Definition: blaze_interface.hh:36
A
Definition: test_numpy_dtypes.cpp:298
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
blaze_interface::matrix_to_stl
static void matrix_to_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: blaze_interface.hh:74
blaze_interface::gene_matrix
blaze::DynamicMatrix< real, blaze::columnMajor > gene_matrix
Definition: blaze_interface.hh:38
blaze_interface::axpby
static EIGEN_DONT_INLINE void axpby(real a, const gene_vector &X, real b, gene_vector &Y, int N)
Definition: blaze_interface.hh:112
E1::A
@ A
blaze_interface::gene_vector
blaze::DynamicVector< real > gene_vector
Definition: blaze_interface.hh:39
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
blaze_interface::matrix_matrix_product
static EIGEN_DONT_INLINE void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: blaze_interface.hh:84
return
if n return
Definition: level1_cplx_impl.h:33
blaze_interface::copy_matrix
static void copy_matrix(const gene_matrix &source, gene_matrix &cible, int N)
Definition: blaze_interface.hh:131
blaze_interface::ata_product
static EIGEN_DONT_INLINE void ata_product(const gene_matrix &A, gene_matrix &X, int N)
Definition: blaze_interface.hh:92
blaze_interface::transposed_matrix_matrix_product
static EIGEN_DONT_INLINE void transposed_matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: blaze_interface.hh:88
N
#define N
Definition: igam.h:9
blaze_interface::free_matrix
static void free_matrix(gene_matrix &A, int N)
Definition: blaze_interface.hh:43
blaze_interface
Definition: blaze_interface.hh:29
real
Definition: main.h:100
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
EIGEN_DONT_INLINE
#define EIGEN_DONT_INLINE
Definition: Macros.h:940


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