matrix.h

Go to the documentation of this file.
00001 /* ./math/matrix.h 
00002 **********************************
00003 Copyright INRIA and CEA 
00004 
00005 author : Guillaume ANCIAUX (anciaux@labri.fr, g.anciaux@laposte.net)
00006 
00007 The LibMultiScale is a C++ parallel framework for the multiscale
00008 coupling methods dedicated to material simulations. This framework
00009 provides an API which makes it possible to program coupled simulations
00010 and integration of already existing codes.
00011 
00012 This Project is done in a collaboration between INRIA Futurs Bordeaux
00013 within ScAlApplix team and CEA/DPTA Ile de France. 
00014 
00015 This software is governed by the CeCILL-C license under French law and
00016 abiding by the rules of distribution of free software.  You can  use, 
00017 modify and/ or redistribute the software under the terms of the CeCILL-C
00018 license as circulated by CEA, CNRS and INRIA at the following URL
00019 "http://www.cecill.info". 
00020 
00021 As a counterpart to the access to the source code and  rights to copy,
00022 modify and redistribute granted by the license, users are provided only
00023 with a limited warranty  and the software's author,  the holder of the
00024 economic rights,  and the successive licensors  have only  limited
00025 liability. 
00026 
00027 In this respect, the user's attention is drawn to the risks associated
00028 with loading,  using,  modifying and/or developing or reproducing the
00029 software by the user in light of its specific status of free software,
00030 that may mean  that it is complicated to manipulate,  and  that  also
00031 therefore means  that it is reserved for developers  and  experienced
00032 professionals having in-depth computer knowledge. Users are therefore
00033 encouraged to load and test the software's suitability as regards their
00034 requirements in conditions enabling the security of their systems and/or 
00035 data to be ensured and,  more generally, to use and operate it in the 
00036 same conditions as regards security. 
00037 
00038 The fact that you are presently reading this means that you have had
00039 knowledge of the CeCILL-C license and that you accept its terms.
00040 ***********************************/
00041 
00042 #ifndef MATRIX
00043 #define MATRIX
00044 
00045 #include <stdio.h>
00046 #include "vector.h"
00047 
00050 template <class T>
00051 class MyMatrix
00052 {
00053  public:
00054   
00055   MyMatrix(int t,int u){_m = t;_n = u;};
00056   ~MyMatrix(){};
00057 
00059   T & myMat(){return static_cast<T&>(*this);}
00060 
00062   double& operator()(int i, int j){
00063     return myMat()(i,j);
00064   }
00065   
00067   int FactoLU(){
00068     return myMat().FactoLU();
00069   }
00070   
00072   int Solve(Vector * residu){
00073     return myMat().Solve(residu);
00074   }
00075 
00077   void print(){
00078     PrintToFile(stdout);
00079   };
00080 
00082   void PrintToFile(char * f){
00083     FILE * file = fopen(f,"wb+");
00084     PrintToFile(file);
00085     fclose(file);
00086   };
00087 
00089   void PrintToFile(FILE *file){
00090     for (int i=0;i< _m;++i)
00091       for (int j=0;j< _n;++j)
00092         {
00093           //      LOG(i+1 << "\t" << j+1 << "\n" << myMat()(i,j),0);
00094           if (myMat()(i,j) != 0)
00095             fprintf(file,"%d\t%d\t%.15e\n",i+1,j+1,myMat()(i,j));
00096         }
00097   };
00098 
00100   const int m(){
00101     return _m;
00102   }
00103 
00105   const int n(){
00106     return _n;
00107   }
00108   
00109  protected:
00110   
00112   int _m,_n;
00114   int * pivot;
00116   double * matrix;
00117 };
00118 
00119 #include "full_matrix.h"
00120 #include "band_matrix.h"
00121 #include "diag_matrix.h"
00122 
00123 #endif

Generated on Fri Sep 7 13:12:34 2007 for LibMultiScale by  doxygen 1.5.2