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 // using namespace blaze;
24 
25 #include <vector>
26 
27 template<class real>
29 
30 public :
31 
32  typedef real real_type ;
33 
34  typedef std::vector<real> stl_vector;
35  typedef std::vector<stl_vector > stl_matrix;
36 
37  typedef blaze::DynamicMatrix<real,blaze::columnMajor> gene_matrix;
38  typedef blaze::DynamicVector<real> gene_vector;
39 
40  static inline std::string name() { return "blaze"; }
41 
42  static void free_matrix(gene_matrix & A, int N){
43  return ;
44  }
45 
46  static void free_vector(gene_vector & B){
47  return ;
48  }
49 
50  static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
51  A.resize(A_stl[0].size(), A_stl.size());
52 
53  for (int j=0; j<A_stl.size() ; j++){
54  for (int i=0; i<A_stl[j].size() ; i++){
55  A(i,j) = A_stl[j][i];
56  }
57  }
58  }
59 
60  static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
61  B.resize(B_stl.size());
62  for (int i=0; i<B_stl.size() ; i++){
63  B[i] = B_stl[i];
64  }
65  }
66 
67  static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
68  for (int i=0; i<B_stl.size() ; i++){
69  B_stl[i] = B[i];
70  }
71  }
72 
73  static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
74  int N=A_stl.size();
75  for (int j=0;j<N;j++){
76  A_stl[j].resize(N);
77  for (int i=0;i<N;i++){
78  A_stl[j][i] = A(i,j);
79  }
80  }
81  }
82 
83  static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
84  X = (A*B);
85  }
86 
87  static inline void transposed_matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
88  X = (trans(A)*trans(B));
89  }
90 
91  static inline void ata_product(const gene_matrix & A, gene_matrix & X, int N){
92  X = (trans(A)*A);
93  }
94 
95  static inline void aat_product(const gene_matrix & A, gene_matrix & X, int N){
96  X = (A*trans(A));
97  }
98 
99  static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
100  X = (A*B);
101  }
102 
103  static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
104  X = (trans(A)*B);
105  }
106 
107  static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
108  Y += coef * X;
109  }
110 
111  static inline void axpby(real a, const gene_vector & X, real b, gene_vector & Y, int N){
112  Y = a*X + b*Y;
113  }
114 
115 // static inline void cholesky(const gene_matrix & X, gene_matrix & C, int N){
116 // C = X;
117 // recursive_cholesky(C);
118 // }
119 
120 // static inline void lu_decomp(const gene_matrix & X, gene_matrix & R, int N){
121 // R = X;
122 // std::vector<int> ipvt(N);
123 // lu_factor(R, ipvt);
124 // }
125 
126 // static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
127 // X = lower_trisolve(L, B);
128 // }
129 
130  static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
131  cible = source;
132  }
133 
134  static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
135  cible = source;
136  }
137 
138 };
139 
140 #endif
float real
Definition: datatypes.h:10
Scalar * b
Definition: benchVecAdd.cpp:17
static void free_vector(gene_vector &B)
static std::string name()
static void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
static void axpby(real a, const gene_vector &X, real b, gene_vector &Y, int N)
static void aat_product(const gene_matrix &A, gene_matrix &X, int N)
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
static void transposed_matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
#define N
Definition: gksort.c:12
if n return
Array33i a
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
static void matrix_to_stl(gene_matrix &A, stl_matrix &A_stl)
static void ata_product(const gene_matrix &A, gene_matrix &X, int N)
blaze::DynamicMatrix< real, blaze::columnMajor > gene_matrix
static void atv_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
std::vector< stl_vector > stl_matrix
static void copy_matrix(const gene_matrix &source, gene_matrix &cible, int N)
static void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
blaze::DynamicVector< real > gene_vector
#define X
Definition: icosphere.cpp:20
static void copy_vector(const gene_vector &source, gene_vector &cible, int N)
std::ptrdiff_t j
static void axpy(const real coef, const gene_vector &X, gene_vector &Y, int N)
static void free_matrix(gene_matrix &A, int N)


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