mtl4_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 MTL4_INTERFACE_HH
19 #define MTL4_INTERFACE_HH
20 
21 #include <boost/numeric/mtl/mtl.hpp>
22 #include <boost/numeric/mtl/utility/range_generator.hpp>
23 // #include <boost/numeric/mtl/operation/cholesky.hpp>
24 #include <vector>
25 
26 using namespace mtl;
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 mtl::dense2D<real, mtl::matrix::parameters<mtl::tag::col_major> > gene_matrix;
39  typedef mtl::dense_vector<real> gene_vector;
40 
41  static inline std::string name() { return "mtl4"; }
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.change_dim(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.change_dim(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 inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
85  X = (A*B);
86 // morton_dense<double, doppled_64_row_mask> C(N,N);
87 // C = B;
88 // X = (A*C);
89  }
90 
91  static inline void transposed_matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
92  X = (trans(A)*trans(B));
93  }
94 
95 // static inline void ata_product(const gene_matrix & A, gene_matrix & X, int N){
96 // X = (trans(A)*A);
97 // }
98 
99  static inline void aat_product(const gene_matrix & A, gene_matrix & X, int N){
100  X = (A*trans(A));
101  }
102 
103  static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
104  X = (A*B);
105  }
106 
107  static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
108  X = (trans(A)*B);
109  }
110 
111  static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
112  Y += coef * X;
113  }
114 
115  static inline void axpby(real a, const gene_vector & X, real b, gene_vector & Y, int N){
116  Y = a*X + b*Y;
117  }
118 
119 // static inline void cholesky(const gene_matrix & X, gene_matrix & C, int N){
120 // C = X;
121 // recursive_cholesky(C);
122 // }
123 
124 // static inline void lu_decomp(const gene_matrix & X, gene_matrix & R, int N){
125 // R = X;
126 // std::vector<int> ipvt(N);
127 // lu_factor(R, ipvt);
128 // }
129 
130  static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
131  X = lower_trisolve(L, B);
132  }
133 
134  static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
135  cible = source;
136  }
137 
138  static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
139  cible = source;
140  }
141 
142 };
143 
144 #endif
mtl4_interface::transposed_matrix_matrix_product
static void transposed_matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: mtl4_interface.hh:91
mtl4_interface
Definition: mtl4_interface.hh:29
mtl4_interface::name
static std::string name()
Definition: mtl4_interface.hh:41
mtl4_interface::free_matrix
static void free_matrix(gene_matrix &A, int N)
Definition: mtl4_interface.hh:43
mtl4_interface::matrix_to_stl
static void matrix_to_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: mtl4_interface.hh:74
b
Scalar * b
Definition: benchVecAdd.cpp:17
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
mtl4_interface::gene_vector
mtl::dense_vector< real > gene_vector
Definition: mtl4_interface.hh:39
mtl4_interface::real_type
real real_type
Definition: mtl4_interface.hh:33
trans
static char trans
Definition: blas_interface.hh:58
E1::B
@ B
X
#define X
Definition: icosphere.cpp:20
mtl4_interface::copy_matrix
static void copy_matrix(const gene_matrix &source, gene_matrix &cible, int N)
Definition: mtl4_interface.hh:134
mtl4_interface::axpby
static void axpby(real a, const gene_vector &X, real b, gene_vector &Y, int N)
Definition: mtl4_interface.hh:115
mtl4_interface::matrix_from_stl
static void matrix_from_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: mtl4_interface.hh:51
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
mtl4_interface::vector_from_stl
static void vector_from_stl(gene_vector &B, stl_vector &B_stl)
Definition: mtl4_interface.hh:61
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
mtl4_interface::axpy
static void axpy(const real coef, const gene_vector &X, gene_vector &Y, int N)
Definition: mtl4_interface.hh:111
L
MatrixXd L
Definition: LLT_example.cpp:6
E1::A
@ A
mtl4_interface::free_vector
static void free_vector(gene_vector &B)
Definition: mtl4_interface.hh:47
mtl4_interface::vector_to_stl
static void vector_to_stl(gene_vector &B, stl_vector &B_stl)
Definition: mtl4_interface.hh:68
mtl4_interface::atv_product
static void atv_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: mtl4_interface.hh:107
mtl4_interface::gene_matrix
mtl::dense2D< real, mtl::matrix::parameters< mtl::tag::col_major > > gene_matrix
Definition: mtl4_interface.hh:38
mtl4_interface::trisolve_lower
static void trisolve_lower(const gene_matrix &L, const gene_vector &B, gene_vector &X, int N)
Definition: mtl4_interface.hh:130
mtl4_interface::copy_vector
static void copy_vector(const gene_vector &source, gene_vector &cible, int N)
Definition: mtl4_interface.hh:138
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
mtl4_interface::aat_product
static void aat_product(const gene_matrix &A, gene_matrix &X, int N)
Definition: mtl4_interface.hh:99
return
if n return
Definition: level1_cplx_impl.h:33
mtl4_interface::stl_vector
std::vector< real > stl_vector
Definition: mtl4_interface.hh:35
mtl4_interface::matrix_vector_product
static void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: mtl4_interface.hh:103
N
#define N
Definition: igam.h:9
mtl4_interface::matrix_matrix_product
static void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: mtl4_interface.hh:84
real
Definition: main.h:100
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
mtl4_interface::stl_matrix
std::vector< stl_vector > stl_matrix
Definition: mtl4_interface.hh:36


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:33:49