PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
SuperLUMatrix.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012 The Regents of the University of California,
3  through Lawrence Berkeley National Laboratory.
4 
5  Author: Mathias Jacquelin and Lin Lin
6 
7  This file is part of PEXSI. All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12  (1) Redistributions of source code must retain the above copyright notice, this
13  list of conditions and the following disclaimer.
14  (2) Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17  (3) Neither the name of the University of California, Lawrence Berkeley
18  National Laboratory, U.S. Dept. of Energy nor the names of its contributors may
19  be used to endorse or promote products derived from this software without
20  specific prior written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  You are under no obligation whatsoever to provide any bug fixes, patches, or
34  upgrades to the features, functionality or performance of the source code
35  ("Enhancements") to anyone; however, if you choose to make your Enhancements
36  available either publicly, or directly to Lawrence Berkeley National
37  Laboratory, without imposing a separate written license agreement for such
38  Enhancements, then you hereby grant the following license: a non-exclusive,
39  royalty-free perpetual license to install, use, modify, prepare derivative
40  works, incorporate into other computer software, distribute, and sublicense
41  such enhancements or derivative works thereof, in binary and source code form.
42  */
46 #ifndef _PEXSI_SUPERLUMATRIX_HPP_
47 #define _PEXSI_SUPERLUMATRIX_HPP_
48 
49 // Interface with PSelInv
50 #include "pselinv.hpp"
51 
52 // Interface with sparse matrix (CSC format)
53 #include "sparse_matrix.hpp"
54 
55 // Interface with LAPACK
56 #include "lapack.hpp"
57 
58 
60 #include "SuperLUGrid.hpp"
61 //#include "SuperLUData.hpp"
62 
63 namespace PEXSI{
64 
65 
66  struct SuperNodeType;
67  template<typename T> class PMatrix;
68 
69 
70 // class RealSuperLUData_internal;
71 //
72 //class RealSuperLUData{
73 // protected:
74 // RealSuperLUData_internal * ptrData;
75 // public:
76 // RealSuperLUData( const SuperLUGrid<Real>& g, const SuperLUOptions& opt );
77 // ~RealSuperLUData();
78 //
79 // Int m() const;
80 // Int n() const;
81 // void DistSparseMatrixToSuperMatrixNRloc( DistSparseMatrix<Real>& sparseA );
82 // void DestroyAOnly();
83 // void SymbolicFactorize();
84 // void Distribute();
85 // void NumericalFactorize();
86 // void ConvertNRlocToNC ( RealSuperLUData * aptrData );
87 // void MultiplyGlobalMultiVector( NumMat<Real>& xGlobal, NumMat<Real>& bGlobal );
88 // void DistributeGlobalMultiVector( NumMat<Real>& xGlobal, NumMat<Real>& xLocal );
89 // void GatherDistributedMultiVector ( NumMat<Real>& xGlobal, NumMat<Real>& xLocal );
90 // void SolveDistMultiVector( NumMat<Real>& bLocal, DblNumVec& berr );
91 // void CheckErrorDistMultiVector( NumMat<Real>& xLocal, NumMat<Real>& xTrueLocal );
92 // void LUstructToPMatrix( PMatrix<Real>& PMloc );
93 // void SymbolicToSuperNode( SuperNodeType& super );
94 //};
95 
96 
97 
98 
99 
100 
101 
102 
103 
108  template<typename T> class SuperLUMatrix{
109  private:
118  void * ptrData;
119  public:
120 
121  SuperLUMatrix( const SuperLUGrid<T>& g, const SuperLUOptions& opt = SuperLUOptions() ){ }
122  ~SuperLUMatrix(){ }
123 
124  Int m() const {return -1;}
125 
126  Int n() const { return -1;}
127 
147 
157  void DestroyAOnly(){ }
158 
169 
175  void Distribute(){ }
176 
184 
189  void ConvertNRlocToNC( SuperLUMatrix<T>& AGlobal ){ }
190 
197  void MultiplyGlobalMultiVector( NumMat<T>& xGlobal, NumMat<T>& bGlobal ){ }
198 
204  void DistributeGlobalMultiVector( NumMat<T>& xGlobal, NumMat<T>& xLocal ){ }
205 
206  void GatherDistributedMultiVector ( NumMat<T>& xGlobal, NumMat<T>& xLocal ){ }
207 
213  void SolveDistMultiVector( NumMat<T>& bLocal, DblNumVec& berr ){ }
214 
215 
221  void CheckErrorDistMultiVector( NumMat<T>& xLocal, NumMat<T>& xTrueLocal ){
222  }
226  void LUstructToPMatrix( PMatrix<T>& PMloc ){ }
227 
233  };
234 
235  template< > class SuperLUMatrix<Real>{
236  private:
245  RealSuperLUData* ptrData;
246  public:
247 
248  SuperLUMatrix();
249  SuperLUMatrix( const SuperLUGrid<Real>& g, const SuperLUOptions& opt = SuperLUOptions() );
250  ~SuperLUMatrix();
251 
252  void Setup( const SuperLUGrid<Real>& g, const SuperLUOptions& opt = SuperLUOptions() );
253 
254  Int m() const;
255  Int n() const;
256 
276 
286  void DestroyAOnly();
287 
297  void SymbolicFactorize();
298 
304  void Distribute();
305 
312  void NumericalFactorize();
313 
318  void ConvertNRlocToNC( SuperLUMatrix<Real>& AGlobal );
319 
326  void MultiplyGlobalMultiVector( NumMat<Real>& xGlobal, NumMat<Real>& bGlobal );
327 
333  void DistributeGlobalMultiVector( NumMat<Real>& xGlobal, NumMat<Real>& xLocal );
334 
335  void GatherDistributedMultiVector ( NumMat<Real>& xGlobal, NumMat<Real>& xLocal );
336 
342  void SolveDistMultiVector( NumMat<Real>& bLocal, DblNumVec& berr );
343 
349  void CheckErrorDistMultiVector( NumMat<Real>& xLocal, NumMat<Real>& xTrueLocal );
350 
354  void LUstructToPMatrix( PMatrix<Real>& PMloc );
355 
360  void SymbolicToSuperNode( SuperNodeType& super );
361  };
362 
363  template< > class SuperLUMatrix<Complex>{
364  private:
373  ComplexSuperLUData* ptrData;
374  public:
375 
376  SuperLUMatrix();
378  ~SuperLUMatrix();
379 
380  void Setup( const SuperLUGrid<Complex>& g, const SuperLUOptions& opt = SuperLUOptions() );
381 
382  Int m() const;
383  Int n() const;
384 
404 
414  void DestroyAOnly();
415 
425  void SymbolicFactorize();
426 
432  void Distribute();
433 
440  void NumericalFactorize();
441 
446  void ConvertNRlocToNC( SuperLUMatrix<Complex>& AGlobal );
447 
454  void MultiplyGlobalMultiVector( NumMat<Complex>& xGlobal, NumMat<Complex>& bGlobal );
455 
462 
463  void GatherDistributedMultiVector ( NumMat<Complex>& xGlobal, NumMat<Complex>& xLocal );
464 
470  void SolveDistMultiVector( NumMat<Complex>& bLocal, DblNumVec& berr );
471 
472 
478  void CheckErrorDistMultiVector( NumMat<Complex>& xLocal, NumMat<Complex>& xTrueLocal );
479 
483  void LUstructToPMatrix( PMatrix<Complex>& PMloc );
484 
489  void SymbolicToSuperNode( SuperNodeType& super );
490  };
491 
492  } // namespace PEXSI
493 
494 #include "SuperLUMatrix_impl.hpp"
495 
496 #endif // _PEXSI_SUPERLUMATRIX_HPP_
497 
void CheckErrorDistMultiVector(NumMat< T > &xLocal, NumMat< T > &xTrueLocal)
Prints out the error by direct comparison with the true solution in distributed format.
Definition: SuperLUMatrix.hpp:221
void SymbolicToSuperNode(SuperNodeType &super)
SymbolicToSuperNode converts the symbolic information to SuperNode structure in SelInv.
Definition: SuperLUMatrix.hpp:232
A thin interface for passing parameters to set the SuperLU options.
Definition: superlu_dist_internal.hpp:62
SuperNodeType describes mapping between supernode and column, the permutation information, and potentially the elimination tree (not implemented here).
Definition: pselinv.hpp:122
Internal structures for interfacing with SuperLU_Dist (version 3.0 and later)
Thin interface to LAPACK.
Definition: superlu_dist_internal.hpp:125
void DistributeGlobalMultiVector(NumMat< T > &xGlobal, NumMat< T > &xLocal)
DistributeGlobalMultiVector distributes a global multivector into a local multivector according to th...
Definition: SuperLUMatrix.hpp:204
void NumericalFactorize()
Performs LU factorization numerically.
Definition: SuperLUMatrix.hpp:183
void SymbolicFactorize()
Factorizes the superlu matrix symbolically.
Definition: SuperLUMatrix.hpp:168
void SolveDistMultiVector(NumMat< T > &bLocal, DblNumVec &berr)
Solve A x = b with b overwritten by x for distributed multivector.
Definition: SuperLUMatrix.hpp:213
Main file for parallel selected inversion.
An thin interface to keep the main code insulated from the source code of SuperLU.
Definition: SuperLUMatrix.hpp:108
SuperLU processor grid.
Definition: SuperLUMatrix.hpp:235
Definition: SuperLUMatrix.hpp:363
Sparse matrix and Distributed sparse matrix in compressed column format.
void DestroyAOnly()
Releases the data in A but keeps other data, such as LUstruct.
Definition: SuperLUMatrix.hpp:157
void ConvertNRlocToNC(SuperLUMatrix< T > &AGlobal)
ConvertNRlocToNC converts a distributed compressed sparse row matrix to a global compressed sparse co...
Definition: SuperLUMatrix.hpp:189
Definition: superlu_dist_internal.hpp:100
void DistSparseMatrixToSuperMatrixNRloc(DistSparseMatrix< T > &sparseA)
Convert a distributed sparse matrix in compressed sparse column format into the SuperLU compressed ro...
Definition: SuperLUMatrix.hpp:146
PMatrix contains the main data structure and the computational routine for the parallel selected inve...
Definition: pselinv.hpp:482
Definition: SuperLUGrid.hpp:112
void Distribute()
Distribute redistrbutes the SuperMatrix in parallel so that it is ready for the numerical factorizati...
Definition: SuperLUMatrix.hpp:175
A thin interface for the gridinfo_t structure in SuperLU.
Definition: SuperLUGrid.hpp:92
Definition: SuperLUGrid.hpp:102
void LUstructToPMatrix(PMatrix< T > &PMloc)
LUstructToPMatrix converts the data in LUstruct to PMatrix.
Definition: SuperLUMatrix.hpp:226
Implementation of the wrapper class for SuperLU internal data structures.
void MultiplyGlobalMultiVector(NumMat< T > &xGlobal, NumMat< T > &bGlobal)
MultiplyGlobalMultiVector computes b = A * x.
Definition: SuperLUMatrix.hpp:197
DistSparseMatrix describes a Sparse matrix in the compressed sparse column format (CSC) and distribut...
Definition: sparse_matrix.hpp:91