tiny_blitz_interface.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  tiny_blitz_interface.hh
00003 // Author :  L. Plagne <laurent.plagne@edf.fr)>
00004 // Copyright (C) EDF R&D,  lun sep 30 14:23:30 CEST 2002
00005 //=====================================================
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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


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