computation/interfaces/direct/Pastix.hxx

00001 // Copyright (C) 2001-2010 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 #ifndef SELDON_FILE_PASTIX_HXX
00020 
00021 // including Pastix headers
00022 extern "C"
00023 {
00024 #define _COMPLEX_H
00025 
00026 #include "pastix.h"
00027 }
00028 
00029 namespace Seldon
00030 {
00031 
00032   template<class T>
00033   class MatrixPastix
00034   {
00035   protected :
00037     pastix_data_t* pastix_data;
00039     pastix_int_t iparm[64];
00041     double dparm[64];
00043     pastix_int_t n;
00045     MPI_Comm comm_facto;
00047     Vector<pastix_int_t> perm, invp;
00049     Vector<pastix_int_t> col_num;
00051     bool distributed;
00053     int print_level;
00055     bool refine_solution;
00056 
00057   public :
00058 
00059     MatrixPastix();
00060     ~MatrixPastix();
00061 
00062     void CreateCommunicator();
00063     void Clear();
00064 
00065     void CallPastix(const MPI_Comm&, pastix_int_t* colptr, pastix_int_t* row,
00066                     T* val, T* b, pastix_int_t nrhs);
00067 
00068     void HideMessages();
00069     void ShowMessages();
00070 
00071     void RefineSolution();
00072     void DoNotRefineSolution();
00073 
00074     template<class T0, class Prop, class Storage, class Allocator, class Tint>
00075     void FindOrdering(Matrix<T0, Prop, Storage, Allocator> & mat,
00076                       Vector<Tint>& numbers, bool keep_matrix = false);
00077 
00078     template<class Storage, class Allocator>
00079     void FactorizeMatrix(Matrix<T, General, Storage, Allocator> & mat,
00080                          bool keep_matrix = false);
00081 
00082     template<class Storage, class Allocator>
00083     void FactorizeMatrix(Matrix<T, Symmetric, Storage, Allocator> & mat,
00084                          bool keep_matrix = false);
00085 
00086     template<class Allocator2>
00087     void Solve(Vector<T, VectFull, Allocator2>& x);
00088 
00089     template<class Allocator2, class Transpose_status>
00090     void Solve(const Transpose_status& TransA,
00091                Vector<T, VectFull, Allocator2>& x);
00092 
00093 #ifdef SELDON_WITH_MPI
00094 
00095     void SetNbThreadPerNode(int);
00096 
00097     template<class Alloc1, class Alloc2, class Alloc3, class Tint>
00098     void FactorizeDistributedMatrix(Vector<pastix_int_t, VectFull, Alloc1>&,
00099                                     Vector<pastix_int_t, VectFull, Alloc2>&,
00100                                     Vector<T, VectFull, Alloc3>&,
00101                                     const Vector<Tint>& glob_number,
00102                                     bool sym, bool keep_matrix = false);
00103 
00104     template<class Allocator2, class Tint>
00105     void SolveDistributed(Vector<T, Vect_Full, Allocator2>& x,
00106                           const Vector<Tint>& glob_num);
00107 
00108     template<class Allocator2, class Transpose_status, class Tint>
00109     void SolveDistributed(const Transpose_status& TransA,
00110                           Vector<T, Vect_Full, Allocator2>& x,
00111                           const Vector<Tint>& glob_num);
00112 #endif
00113 
00114   };
00115 
00116 }
00117 
00118 #define SELDON_FILE_PASTIX_HXX
00119 #endif
00120