Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TVMET_INTERFACE_HH
00021 #define TVMET_INTERFACE_HH
00022
00023 #include <tvmet/tvmet.h>
00024 #include <tvmet/Vector.h>
00025 #include <tvmet/Matrix.h>
00026
00027 #include <vector>
00028
00029 using namespace tvmet;
00030
00031 template<class real, int SIZE>
00032 class tvmet_interface{
00033
00034 public :
00035
00036 typedef real real_type ;
00037
00038 typedef std::vector<real> stl_vector;
00039 typedef std::vector<stl_vector > stl_matrix;
00040
00041 typedef Vector<real,SIZE> gene_vector;
00042 typedef Matrix<real,SIZE,SIZE> gene_matrix;
00043
00044 static inline std::string name() { return "tiny_tvmet"; }
00045
00046 static void free_matrix(gene_matrix & A, int N){}
00047
00048 static void free_vector(gene_vector & B){}
00049
00050 static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
00051 for (int j=0; j<A_stl.size() ; j++)
00052 for (int i=0; i<A_stl[j].size() ; i++)
00053 A(i,j) = A_stl[j][i];
00054 }
00055
00056 static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
00057 for (int i=0; i<B_stl.size() ; i++)
00058 B[i]=B_stl[i];
00059 }
00060
00061 static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
00062 for (int i=0; i<B_stl.size() ; i++){
00063 B_stl[i]=B[i];
00064 }
00065 }
00066
00067 static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
00068 int N = A_stl.size();
00069 for (int j=0;j<N;j++){
00070 A_stl[j].resize(N);
00071 for (int i=0;i<N;i++)
00072 A_stl[j][i] = A(i,j);
00073 }
00074 }
00075
00076
00077 static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
00078 cible = source;
00079 }
00080
00081 static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
00082 cible = source;
00083 }
00084
00085 static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
00086 X = prod(A,B);
00087 }
00088
00089 static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
00090 X = prod(A,B);
00091 }
00092
00093 static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
00094 X = prod(trans(A),B);
00095 }
00096
00097 static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
00098 Y+=coef*X;
00099 }
00100
00101 };
00102
00103
00104 #endif