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     int print_level;
00038     bool transpose; 
00039     int status_facto;
00040 
00041   public :
00042     MatrixUmfPack_Base();
00043 
00044     void HideMessages();
00045     void ShowMessages();
00046     void ShowFullHistory();
00047 
00048     int GetInfoFactorization() const;
00049 
00050     void SelectOrdering(int type);
00051     void SetPermutation(const IVect&);
00052   };
00053 
00055   template<class T>
00056   class MatrixUmfPack : public MatrixUmfPack_Base<T>
00057   {
00058   };
00059 
00061   template<>
00062   class MatrixUmfPack<double> : public MatrixUmfPack_Base<double>
00063   {
00064 
00065   protected :
00067     int* ind_, *ptr_;
00069     double* data_;
00070 
00071   public :
00072 
00073     MatrixUmfPack();
00074     ~MatrixUmfPack();
00075 
00076     void Clear();
00077 
00078     template<class Prop, class Storage, class Allocator>
00079     void FactorizeMatrix(Matrix<double, Prop, Storage, Allocator> & mat,
00080                          bool keep_matrix = false);
00081 
00082     template<class Prop, class Allocator>
00083     void PerformAnalysis(Matrix<double, Prop, RowSparse, Allocator> & mat);
00084 
00085     template<class Prop, class Allocator>
00086     void
00087     PerformFactorization(Matrix<double, Prop, RowSparse, Allocator> & mat);
00088 
00089     template<class Allocator2>
00090     void Solve(Vector<double, VectFull, Allocator2>& x);
00091 
00092     template<class StatusTrans, class Allocator2>
00093     void Solve(const StatusTrans&, Vector<double, VectFull, Allocator2>& x);
00094 
00095   };
00096 
00097 
00099   template<>
00100   class MatrixUmfPack<complex<double> >
00101     : public MatrixUmfPack_Base<complex<double> >
00102   {
00103 
00104   protected:
00106     int* ptr_, *ind_;
00108     double* data_real_, *data_imag_;
00109 
00110   public :
00111 
00112     MatrixUmfPack();
00113     ~MatrixUmfPack();
00114 
00115     void Clear();
00116 
00117     template<class Prop, class Storage, class Allocator>
00118     void
00119     FactorizeMatrix(Matrix<complex<double>, Prop, Storage, Allocator> & mat,
00120                     bool keep_matrix = false);
00121 
00122     template<class Allocator2>
00123     void Solve(Vector<complex<double>, VectFull, Allocator2>& x);
00124 
00125     template<class StatusTrans, class Allocator2>
00126     void Solve(const StatusTrans&, Vector<complex<double>, VectFull, Allocator2>& x);
00127 
00128   };
00129 
00130 }
00131 
00132 #define SELDON_FILE_UMFPACK_HXX
00133 #endif