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 
84  static EIGEN_DONT_INLINE void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
85  X = (A*B);
86  }
87 
88  static EIGEN_DONT_INLINE void transposed_matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
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 
100  static EIGEN_DONT_INLINE void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
101  X = (A*B);
102  }
103 
104  static EIGEN_DONT_INLINE void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
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
const char Y
Scalar * b
Definition: benchVecAdd.cpp:17
static EIGEN_DONT_INLINE void transposed_matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
static void free_vector(gene_vector &B)
static std::string name()
static void matrix_from_stl(gene_matrix &A, stl_matrix &A_stl)
static void vector_from_stl(gene_vector &B, stl_vector &B_stl)
static void vector_to_stl(gene_vector &B, stl_vector &B_stl)
std::vector< real > stl_vector
static char trans
#define N
Definition: gksort.c:12
if n return
#define EIGEN_DONT_INLINE
Definition: Macros.h:940
static EIGEN_DONT_INLINE void atv_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
static void matrix_to_stl(gene_matrix &A, stl_matrix &A_stl)
static EIGEN_DONT_INLINE void aat_product(const gene_matrix &A, gene_matrix &X, int N)
static EIGEN_DONT_INLINE void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
blaze::DynamicMatrix< real, blaze::columnMajor > gene_matrix
Definition: main.h:100
std::vector< stl_vector > stl_matrix
static void copy_matrix(const gene_matrix &source, gene_matrix &cible, int N)
static EIGEN_DONT_INLINE void axpby(real a, const gene_vector &X, real b, gene_vector &Y, int N)
static EIGEN_DONT_INLINE void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
blaze::DynamicVector< real > gene_vector
static EIGEN_DONT_INLINE void axpy(const real coef, const gene_vector &X, gene_vector &Y, int N)
#define X
Definition: icosphere.cpp:20
static void copy_vector(const gene_vector &source, gene_vector &cible, int N)
std::ptrdiff_t j
static EIGEN_DONT_INLINE void ata_product(const gene_matrix &A, gene_matrix &X, int N)
static void free_matrix(gene_matrix &A, int N)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:33:59