gmm_interface.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
00003 //=====================================================
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 #ifndef GMM_INTERFACE_HH
00019 #define GMM_INTERFACE_HH
00020 
00021 #include <gmm/gmm.h>
00022 #include <vector>
00023 
00024 using namespace gmm;
00025 
00026 template<class real>
00027 class gmm_interface {
00028 
00029 public :
00030 
00031   typedef real real_type ;
00032 
00033   typedef std::vector<real>  stl_vector;
00034   typedef std::vector<stl_vector > stl_matrix;
00035 
00036   typedef gmm::dense_matrix<real> gene_matrix;
00037   typedef stl_vector gene_vector;
00038 
00039   static inline std::string name( void )
00040   {
00041     return "gmm";
00042   }
00043 
00044   static void free_matrix(gene_matrix & A, int N){
00045     return ;
00046   }
00047 
00048   static void free_vector(gene_vector & B){
00049     return ;
00050   }
00051 
00052   static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
00053     A.resize(A_stl[0].size(),A_stl.size());
00054 
00055     for (int j=0; j<A_stl.size() ; j++){
00056       for (int i=0; i<A_stl[j].size() ; i++){
00057         A(i,j) = A_stl[j][i];
00058       }
00059     }
00060   }
00061 
00062   static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
00063     B = B_stl;
00064   }
00065 
00066   static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
00067     B_stl = B;
00068   }
00069 
00070   static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
00071     int N=A_stl.size();
00072 
00073     for (int j=0;j<N;j++){
00074       A_stl[j].resize(N);
00075       for (int i=0;i<N;i++){
00076         A_stl[j][i] = A(i,j);
00077       }
00078     }
00079   }
00080 
00081   static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
00082     gmm::mult(A,B, X);
00083   }
00084 
00085   static inline void transposed_matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
00086     gmm::mult(gmm::transposed(A),gmm::transposed(B), X);
00087   }
00088 
00089   static inline void ata_product(const gene_matrix & A, gene_matrix & X, int N){
00090     gmm::mult(gmm::transposed(A),A, X);
00091   }
00092 
00093   static inline void aat_product(const gene_matrix & A, gene_matrix & X, int N){
00094     gmm::mult(A,gmm::transposed(A), X);
00095   }
00096 
00097   static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
00098     gmm::mult(A,B,X);
00099   }
00100 
00101   static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
00102     gmm::mult(gmm::transposed(A),B,X);
00103   }
00104 
00105   static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
00106     gmm::add(gmm::scaled(X,coef), Y);
00107   }
00108 
00109   static inline void axpby(real a, const gene_vector & X, real b, gene_vector & Y, int N){
00110     gmm::add(gmm::scaled(X,a), gmm::scaled(Y,b), Y);
00111   }
00112 
00113   static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
00114     gmm::copy(source,cible);
00115   }
00116 
00117   static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
00118     gmm::copy(source,cible);
00119   }
00120 
00121   static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
00122     gmm::copy(B,X);
00123     gmm::lower_tri_solve(L, X, false);
00124   }
00125 
00126   static inline void lu_decomp(const gene_matrix & X, gene_matrix & R, int N){
00127     gmm::copy(X,R);
00128     std::vector<int> ipvt(N);
00129     gmm::lu_factor(R, ipvt);
00130   }
00131 
00132   static inline void hessenberg(const gene_matrix & X, gene_matrix & R, int N){
00133     gmm::copy(X,R);
00134     gmm::Hessenberg_reduction(R,X,false);
00135   }
00136 
00137   static inline void tridiagonalization(const gene_matrix & X, gene_matrix & R, int N){
00138     gmm::copy(X,R);
00139     gmm::Householder_tridiagonalization(R,X,false);
00140   }
00141 
00142 };
00143 
00144 #endif


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:44