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     Vector<pastix_int_t> perm, invp;
00047     Vector<pastix_int_t> col_num;
00049     bool distributed;
00051     int print_level;
00053     bool refine_solution;
00054 
00055   public :
00056 
00057     MatrixPastix();
00058     ~MatrixPastix();
00059 
00060     void Clear();
00061 
00062     void CallPastix(const MPI_Comm&, pastix_int_t* colptr, pastix_int_t* row,
00063                     T* val, T* b, pastix_int_t nrhs);
00064 
00065     void HideMessages();
00066     void ShowMessages();
00067     void ShowFullHistory();
00068 
00069     void SelectOrdering(int type);
00070     void SetPermutation(const IVect& permut);
00071 
00072     void RefineSolution();
00073     void DoNotRefineSolution();
00074 
00075     template<class T0, class Prop, class Storage, class Allocator, class Tint>
00076     void FindOrdering(Matrix<T0, Prop, Storage, Allocator> & mat,
00077                       Vector<Tint>& numbers, bool keep_matrix = false);
00078 
00079     template<class Storage, class Allocator>
00080     void FactorizeMatrix(Matrix<T, General, Storage, Allocator> & mat,
00081                          bool keep_matrix = false);
00082 
00083     template<class Storage, class Allocator>
00084     void FactorizeMatrix(Matrix<T, Symmetric, Storage, Allocator> & mat,
00085                          bool keep_matrix = false);
00086 
00087     template<class Allocator2>
00088     void Solve(Vector<T, VectFull, Allocator2>& x);
00089 
00090     template<class Allocator2, class Transpose_status>
00091     void Solve(const Transpose_status& TransA,
00092                Vector<T, VectFull, Allocator2>& x);
00093 
00094     void SetNumberThreadPerNode(int num_thread);
00095 
00096     template<class Alloc1, class Alloc2, class Alloc3, class Tint>
00097     void FactorizeDistributedMatrix(MPI::Comm& comm_facto,
00098                                     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(MPI::Comm& comm_facto,
00106                           Vector<T, Vect_Full, Allocator2>& x,
00107                           const Vector<Tint>& glob_num);
00108 
00109     template<class Allocator2, class Transpose_status, class Tint>
00110     void SolveDistributed(MPI::Comm& comm_facto,
00111                           const Transpose_status& TransA,
00112                           Vector<T, Vect_Full, Allocator2>& x,
00113                           const Vector<Tint>& glob_num);
00114 
00115   };
00116 
00117 }
00118 
00119 #define SELDON_FILE_PASTIX_HXX
00120 #endif
00121