gmm_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 GMM_INTERFACE_HH
19 #define GMM_INTERFACE_HH
20 
21 #include <gmm/gmm.h>
22 #include <vector>
23 
24 using namespace gmm;
25 
26 template<class real>
28 
29 public :
30 
31  typedef real real_type ;
32 
33  typedef std::vector<real> stl_vector;
34  typedef std::vector<stl_vector > stl_matrix;
35 
36  typedef gmm::dense_matrix<real> gene_matrix;
38 
39  static inline std::string name( void )
40  {
41  return "gmm";
42  }
43 
44  static void free_matrix(gene_matrix & A, int N){
45  return ;
46  }
47 
48  static void free_vector(gene_vector & B){
49  return ;
50  }
51 
52  static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
53  A.resize(A_stl[0].size(),A_stl.size());
54 
55  for (int j=0; j<A_stl.size() ; j++){
56  for (int i=0; i<A_stl[j].size() ; i++){
57  A(i,j) = A_stl[j][i];
58  }
59  }
60  }
61 
62  static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
63  B = B_stl;
64  }
65 
66  static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
67  B_stl = B;
68  }
69 
70  static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
71  int N=A_stl.size();
72 
73  for (int j=0;j<N;j++){
74  A_stl[j].resize(N);
75  for (int i=0;i<N;i++){
76  A_stl[j][i] = A(i,j);
77  }
78  }
79  }
80 
81  static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
82  gmm::mult(A,B, X);
83  }
84 
85  static inline void transposed_matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
86  gmm::mult(gmm::transposed(A),gmm::transposed(B), X);
87  }
88 
89  static inline void ata_product(const gene_matrix & A, gene_matrix & X, int N){
90  gmm::mult(gmm::transposed(A),A, X);
91  }
92 
93  static inline void aat_product(const gene_matrix & A, gene_matrix & X, int N){
94  gmm::mult(A,gmm::transposed(A), X);
95  }
96 
97  static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
98  gmm::mult(A,B,X);
99  }
100 
101  static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
102  gmm::mult(gmm::transposed(A),B,X);
103  }
104 
105  static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
106  gmm::add(gmm::scaled(X,coef), Y);
107  }
108 
109  static inline void axpby(real a, const gene_vector & X, real b, gene_vector & Y, int N){
110  gmm::add(gmm::scaled(X,a), gmm::scaled(Y,b), Y);
111  }
112 
113  static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
114  gmm::copy(source,cible);
115  }
116 
117  static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
118  gmm::copy(source,cible);
119  }
120 
121  static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
122  gmm::copy(B,X);
123  gmm::lower_tri_solve(L, X, false);
124  }
125 
126  static inline void partial_lu_decomp(const gene_matrix & X, gene_matrix & R, int N){
127  gmm::copy(X,R);
128  std::vector<int> ipvt(N);
129  gmm::lu_factor(R, ipvt);
130  }
131 
132  static inline void hessenberg(const gene_matrix & X, gene_matrix & R, int N){
133  gmm::copy(X,R);
134  gmm::Hessenberg_reduction(R,X,false);
135  }
136 
137  static inline void tridiagonalization(const gene_matrix & X, gene_matrix & R, int N){
138  gmm::copy(X,R);
139  gmm::Householder_tridiagonalization(R,X,false);
140  }
141 
142 };
143 
144 #endif
gmm_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: gmm_interface.hh:85
b
Scalar * b
Definition: benchVecAdd.cpp:17
gmm_interface::vector_from_stl
static void vector_from_stl(gene_vector &B, stl_vector &B_stl)
Definition: gmm_interface.hh:62
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
gmm_interface
Definition: gmm_interface.hh:27
copy
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:29
E1::B
@ B
gmm_interface::partial_lu_decomp
static void partial_lu_decomp(const gene_matrix &X, gene_matrix &R, int N)
Definition: gmm_interface.hh:126
gmm_interface::matrix_matrix_product
static void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: gmm_interface.hh:81
X
#define X
Definition: icosphere.cpp:20
gmm_interface::vector_to_stl
static void vector_to_stl(gene_vector &B, stl_vector &B_stl)
Definition: gmm_interface.hh:66
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
gmm_interface::real_type
real real_type
Definition: gmm_interface.hh:31
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
add
graph add(PriorFactor< Pose2 >(1, priorMean, priorNoise))
gmm_interface::axpy
static void axpy(const real coef, const gene_vector &X, gene_vector &Y, int N)
Definition: gmm_interface.hh:105
L
MatrixXd L
Definition: LLT_example.cpp:6
gmm_interface::copy_matrix
static void copy_matrix(const gene_matrix &source, gene_matrix &cible, int N)
Definition: gmm_interface.hh:113
gmm_interface::hessenberg
static void hessenberg(const gene_matrix &X, gene_matrix &R, int N)
Definition: gmm_interface.hh:132
gmm_interface::atv_product
static void atv_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: gmm_interface.hh:101
gmm_interface::gene_vector
stl_vector gene_vector
Definition: gmm_interface.hh:37
E1::A
@ A
gmm_interface::matrix_vector_product
static void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: gmm_interface.hh:97
gmm_interface::aat_product
static void aat_product(const gene_matrix &A, gene_matrix &X, int N)
Definition: gmm_interface.hh:93
gmm_interface::matrix_from_stl
static void matrix_from_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: gmm_interface.hh:52
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gmm_interface::free_matrix
static void free_matrix(gene_matrix &A, int N)
Definition: gmm_interface.hh:44
gmm_interface::gene_matrix
gmm::dense_matrix< real > gene_matrix
Definition: gmm_interface.hh:36
gmm_interface::copy_vector
static void copy_vector(const gene_vector &source, gene_vector &cible, int N)
Definition: gmm_interface.hh:117
gmm_interface::matrix_to_stl
static void matrix_to_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: gmm_interface.hh:70
return
if n return
Definition: level1_cplx_impl.h:33
gmm_interface::stl_vector
std::vector< real > stl_vector
Definition: gmm_interface.hh:33
gmm_interface::tridiagonalization
static void tridiagonalization(const gene_matrix &X, gene_matrix &R, int N)
Definition: gmm_interface.hh:137
gmm_interface::stl_matrix
std::vector< stl_vector > stl_matrix
Definition: gmm_interface.hh:34
N
#define N
Definition: igam.h:9
real
Definition: main.h:100
gmm_interface::ata_product
static void ata_product(const gene_matrix &A, gene_matrix &X, int N)
Definition: gmm_interface.hh:89
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
R
Rot2 R(Rot2::fromAngle(0.1))
gmm_interface::axpby
static void axpby(real a, const gene_vector &X, real b, gene_vector &Y, int N)
Definition: gmm_interface.hh:109
gmm_interface::free_vector
static void free_vector(gene_vector &B)
Definition: gmm_interface.hh:48
gmm_interface::trisolve_lower
static void trisolve_lower(const gene_matrix &L, const gene_vector &B, gene_vector &X, int N)
Definition: gmm_interface.hh:121
gmm_interface::name
static std::string name(void)
Definition: gmm_interface.hh:39


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:23