computation/interfaces/direct/UmfPack.hxx

00001 // Copyright (C) 2003-2009 Marc Duruflé
00002 //
00003 // This file is part of the linear-algebra library Seldon,
00004 // http://seldon.sourceforge.net/.
00005 //
00006 // Seldon is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU Lesser General Public License as published by the Free
00008 // Software Foundation; either version 2.1 of the License, or (at your option)
00009 // any later version.
00010 //
00011 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
00014 // more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public License
00017 // along with Seldon. If not, see http://www.gnu.org/licenses/.
00018 
00019 
00020 #ifndef SELDON_FILE_UMFPACK_HXX
00021 
00022 extern "C"
00023 {
00024 #include "umfpack.h"
00025 }
00026 
00027 namespace Seldon
00028 {
00030   template<class T>
00031   class MatrixUmfPack_Base
00032   {
00033   public :
00034     Vector<double> Control, Info; 
00035     void *Symbolic, *Numeric ; 
00036     int n; 
00037     bool display_info; 
00038     bool transpose; 
00039 
00040   public :
00041     MatrixUmfPack_Base();
00042 
00043     void HideMessages();
00044     void ShowMessages();
00045 
00046   };
00047 
00049   template<class T>
00050   class MatrixUmfPack : public MatrixUmfPack_Base<T>
00051   {
00052   };
00053 
00055   template<>
00056   class MatrixUmfPack<double> : public MatrixUmfPack_Base<double>
00057   {
00058 
00059   protected :
00061     int* ind_, *ptr_;
00063     double* data_;
00064 
00065   public :
00066 
00067     MatrixUmfPack();
00068     ~MatrixUmfPack();
00069 
00070     void Clear();
00071 
00072     template<class Prop, class Storage, class Allocator>
00073     void FactorizeMatrix(Matrix<double, Prop, Storage, Allocator> & mat,
00074                          bool keep_matrix = false);
00075 
00076     template<class Prop, class Allocator>
00077     void PerformAnalysis(Matrix<double, Prop, RowSparse, Allocator> & mat);
00078 
00079     template<class Prop, class Allocator>
00080     void
00081     PerformFactorization(Matrix<double, Prop, RowSparse, Allocator> & mat);
00082 
00083     template<class Allocator2>
00084     void Solve(Vector<double, VectFull, Allocator2>& x);
00085 
00086   };
00087 
00088 
00090   template<>
00091   class MatrixUmfPack<complex<double> >
00092     : public MatrixUmfPack_Base<complex<double> >
00093   {
00094 
00095   protected:
00097     int* ptr_, *ind_;
00099     double* data_real_, *data_imag_;
00100 
00101   public :
00102 
00103     MatrixUmfPack();
00104     ~MatrixUmfPack();
00105 
00106     void Clear();
00107 
00108     template<class Prop, class Storage, class Allocator>
00109     void
00110     FactorizeMatrix(Matrix<complex<double>, Prop, Storage, Allocator> & mat,
00111                     bool keep_matrix = false);
00112 
00113     template<class Allocator2>
00114     void Solve(Vector<complex<double>, VectFull, Allocator2>& x);
00115 
00116   };
00117 
00118 }
00119 
00120 #define SELDON_FILE_UMFPACK_HXX
00121 #endif