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 TINY_BLITZ_INTERFACE_HH
00021 #define TINY_BLITZ_INTERFACE_HH
00022
00023 #include "blitz/array.h"
00024 #include "blitz/tiny.h"
00025 #include "blitz/tinymat.h"
00026 #include "blitz/tinyvec.h"
00027 #include <blitz/tinyvec-et.h>
00028
00029 #include <vector>
00030
00031 BZ_USING_NAMESPACE(blitz)
00032
00033 template<class real, int SIZE>
00034 class tiny_blitz_interface
00035 {
00036
00037 public :
00038
00039 typedef real real_type ;
00040
00041 typedef std::vector<real> stl_vector;
00042 typedef std::vector<stl_vector > stl_matrix;
00043
00044 typedef TinyVector<real,SIZE> gene_vector;
00045 typedef TinyMatrix<real,SIZE,SIZE> gene_matrix;
00046
00047 static inline std::string name() { return "tiny_blitz"; }
00048
00049 static void free_matrix(gene_matrix & A, int N){}
00050
00051 static void free_vector(gene_vector & B){}
00052
00053 static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
00054 for (int j=0; j<A_stl.size() ; j++)
00055 for (int i=0; i<A_stl[j].size() ; i++)
00056 A(i,j)=A_stl[j][i];
00057 }
00058
00059 static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
00060 for (int i=0; i<B_stl.size() ; i++)
00061 B(i) = B_stl[i];
00062 }
00063
00064 static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
00065 for (int i=0; i<B_stl.size() ; i++)
00066 B_stl[i] = B(i);
00067 }
00068
00069 static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
00070 int N = A_stl.size();
00071 for (int j=0;j<N;j++)
00072 {
00073 A_stl[j].resize(N);
00074 for (int i=0;i<N;i++)
00075 A_stl[j][i] = A(i,j);
00076 }
00077 }
00078
00079 static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
00080 for (int j=0;j<N;j++)
00081 for (int i=0;i<N;i++)
00082 cible(i,j) = source(i,j);
00083 }
00084
00085 static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
00086 for (int i=0;i<N;i++){
00087 cible(i) = source(i);
00088 }
00089 }
00090
00091 static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
00092 X = product(A,B);
00093 }
00094
00095 static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
00096 X = product(A,B);
00097 }
00098
00099 static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
00100 Y += coef * X;
00101 }
00102
00103 };
00104
00105
00106 #endif