C_interface.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  C_interface.hh
00003 // Author :  L. Plagne <laurent.plagne@edf.fr)>
00004 // Copyright (C) EDF R&D,  lun sep 30 14:23:23 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 C_INTERFACE_HH
00021 #define C_INTERFACE_HH
00022 
00023 #include "f77_interface.hh"
00024 
00025 template<class real>
00026 class C_interface : public f77_interface_base<real> {
00027 
00028 public :
00029 
00030   typedef typename f77_interface_base<real>::gene_matrix gene_matrix;
00031   typedef typename f77_interface_base<real>::gene_vector gene_vector;
00032 
00033   static inline std::string name() { return "C"; }
00034 
00035   static inline void matrix_vector_product(const gene_matrix & A, const gene_vector & B, gene_vector & X, int N)
00036   {
00037 //     for (int i=0;i<N;i++)
00038 //     {
00039 //       real somme = 0.0;
00040 //       for (int j=0;j<N;j++)
00041 //         somme += A[j*N+i] * B[j];
00042 //       X[i] = somme;
00043 //     }
00044     for (int i=0;i<N;i++)
00045       X[i] = 0;
00046     for (int i=0;i<N;i++)
00047     {
00048       real tmp = B[i];
00049       int iN = i*N;
00050       for (int j=0;j<N;j++)
00051         X[j] += tmp * A[j+iN];
00052     }
00053   }
00054 
00055   static inline void atv_product(const gene_matrix & A, const gene_vector & B, gene_vector & X, int N)
00056   {
00057     for (int i=0;i<N;i++)
00058     {
00059       int iN = i*N;
00060       real somme = 0.0;
00061       for (int j=0;j<N;j++)
00062         somme += A[iN+j] * B[j];
00063       X[i] = somme;
00064     }
00065   }
00066 
00067   static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N)
00068   {
00069     real somme;
00070     for (int i=0;i<N;i++){
00071       for (int j=0;j<N;j++){
00072         somme=0.0;
00073         for (int k=0;k<N;k++){
00074           somme += A[i+k*N] * B[k+j*N];
00075         }
00076         X[i+j*N] = somme;
00077       }
00078     }
00079   }
00080 
00081   static inline void ata_product(const gene_matrix & A, gene_matrix & X, int N)
00082   {
00083 
00084     real somme;
00085     for (int i=0;i<N;i++){
00086       for (int j=0;j<N;j++){
00087         somme=0.0;
00088         for (int k=0;k<N;k++){
00089           somme+=A[k+i*N]*A[k+j*N];
00090         }
00091         X[i+j*N]=somme;
00092       }
00093     }
00094   }
00095 
00096   static inline void aat_product(const gene_matrix & A, gene_matrix & X, int N){
00097     real somme;
00098     for (int i=0;i<N;i++){
00099       for (int j=0;j<N;j++){
00100         somme=0.0;
00101         for (int k=0;k<N;k++){
00102           somme+=A[i+k*N]*A[j+k*N];
00103         }
00104         X[i+j*N] = somme;
00105       }
00106     }
00107   }
00108 
00109   static inline void axpy(real coef, const gene_vector & X, gene_vector & Y, int N){
00110     for (int i=0;i<N;i++)
00111       Y[i]+=coef*X[i];
00112   }
00113 
00114 
00115 };
00116 
00117 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:48