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 "pexsi/pselinv.hpp"
51 
52 // Interface with sparse matrix (CSC format)
53 #include "pexsi/sparse_matrix.hpp"
54 
55 // Interface with LAPACK
56 #include "pexsi/lapack.hpp"
57 
58 
60 #include "pexsi/SuperLUGrid.hpp"
61 //#include "pexsi/SuperLUData.hpp"
62 
63 namespace PEXSI{
64 
65 
66  struct SuperNodeType;
67  template<typename T> class PMatrix;
68 
69 
70 
75  template<typename T> class SuperLUMatrix{
76  private:
85  void * ptrData;
86 
87 
88  public:
89 
90  SuperLUMatrix( const SuperLUGrid<T>& g, const SuperLUOptions& opt = SuperLUOptions() ){ }
91  ~SuperLUMatrix(){ }
92  SuperLUMatrix(const SuperLUMatrix & g){};
93  SuperLUMatrix & operator = (const SuperLUMatrix & g){};
94 
95  Int m() const {return -1;}
96 
97  Int n() const { return -1;}
98 
118 
128  void DestroyAOnly(){ }
129 
140 
146  void Distribute(){ }
147 
155 
160  void ConvertNRlocToNC( SuperLUMatrix<T>& AGlobal ){ }
161 
168  void MultiplyGlobalMultiVector( NumMat<T>& xGlobal, NumMat<T>& bGlobal ){ }
169 
175  void DistributeGlobalMultiVector( NumMat<T>& xGlobal, NumMat<T>& xLocal ){ }
176 
177  void GatherDistributedMultiVector ( NumMat<T>& xGlobal, NumMat<T>& xLocal ){ }
178 
184  void SolveDistMultiVector( NumMat<T>& bLocal, DblNumVec& berr ){ }
185 
186 
192  void CheckErrorDistMultiVector( NumMat<T>& xLocal, NumMat<T>& xTrueLocal ){
193  }
197  void LUstructToPMatrix( PMatrix<T>& PMloc ){ }
198 
204  };
205 
206  template< > class SuperLUMatrix<Real>{
207  private:
216  RealSuperLUData* ptrData;
217 
218  public:
219 
220  SuperLUMatrix();
221  SuperLUMatrix( const SuperLUGrid<Real>& g, const SuperLUOptions& opt = SuperLUOptions() );
222  ~SuperLUMatrix();
223  SuperLUMatrix(const SuperLUMatrix & g);
224  SuperLUMatrix & operator = (const SuperLUMatrix & g);
225 
226  void Setup( const SuperLUGrid<Real>& g, const SuperLUOptions& opt = SuperLUOptions() );
227 
228  Int m() const;
229  Int n() const;
230 
250 
260  void DestroyAOnly();
261 
271  void SymbolicFactorize();
272 
278  void Distribute();
279 
286  void NumericalFactorize();
287 
292  void ConvertNRlocToNC( SuperLUMatrix<Real>& AGlobal );
293 
300  void MultiplyGlobalMultiVector( NumMat<Real>& xGlobal, NumMat<Real>& bGlobal );
301 
307  void DistributeGlobalMultiVector( NumMat<Real>& xGlobal, NumMat<Real>& xLocal );
308 
309  void GatherDistributedMultiVector ( NumMat<Real>& xGlobal, NumMat<Real>& xLocal );
310 
316  void SolveDistMultiVector( NumMat<Real>& bLocal, DblNumVec& berr );
317 
323  void CheckErrorDistMultiVector( NumMat<Real>& xLocal, NumMat<Real>& xTrueLocal );
324 
328  void LUstructToPMatrix( PMatrix<Real>& PMloc );
329 
334  void SymbolicToSuperNode( SuperNodeType& super );
335  };
336 
337  template< > class SuperLUMatrix<Complex>{
338  private:
347  ComplexSuperLUData* ptrData;
348 
349 
350  public:
351 
352  SuperLUMatrix();
354  ~SuperLUMatrix();
355  SuperLUMatrix(const SuperLUMatrix & g);
356  SuperLUMatrix & operator = (const SuperLUMatrix & g);
357 
358  void Setup( const SuperLUGrid<Complex>& g, const SuperLUOptions& opt = SuperLUOptions() );
359 
360  Int m() const;
361  Int n() const;
362 
382 
392  void DestroyAOnly();
393 
403  void SymbolicFactorize();
404 
410  void Distribute();
411 
418  void NumericalFactorize();
419 
424  void ConvertNRlocToNC( SuperLUMatrix<Complex>& AGlobal );
425 
432  void MultiplyGlobalMultiVector( NumMat<Complex>& xGlobal, NumMat<Complex>& bGlobal );
433 
440 
441  void GatherDistributedMultiVector ( NumMat<Complex>& xGlobal, NumMat<Complex>& xLocal );
442 
448  void SolveDistMultiVector( NumMat<Complex>& bLocal, DblNumVec& berr );
449 
450 
456  void CheckErrorDistMultiVector( NumMat<Complex>& xLocal, NumMat<Complex>& xTrueLocal );
457 
461  void LUstructToPMatrix( PMatrix<Complex>& PMloc );
462 
467  void SymbolicToSuperNode( SuperNodeType& super );
468  };
469 
470  } // namespace PEXSI
471 
473 
474 #endif // _PEXSI_SUPERLUMATRIX_HPP_
475 
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:192
void SymbolicToSuperNode(SuperNodeType &super)
SymbolicToSuperNode converts the symbolic information to SuperNode structure in SelInv.
Definition: SuperLUMatrix.hpp:203
A thin interface for passing parameters to set the SuperLU options.
Definition: superlu_dist_internal.hpp:62
void DistSparseMatrixToSuperMatrixNRloc(DistSparseMatrix< T > &sparseA, const SuperLUOptions &options)
Convert a distributed sparse matrix in compressed sparse column format into the SuperLU compressed ro...
Definition: SuperLUMatrix.hpp:117
SuperNodeType describes mapping between supernode and column, the permutation information, and potentially the elimination tree (not implemented here).
Definition: pselinv.hpp:143
Internal structures for interfacing with SuperLU_Dist (version 3.0 and later)
Thin interface to LAPACK.
Definition: superlu_dist_internal.hpp:129
void DistributeGlobalMultiVector(NumMat< T > &xGlobal, NumMat< T > &xLocal)
DistributeGlobalMultiVector distributes a global multivector into a local multivector according to th...
Definition: SuperLUMatrix.hpp:175
void NumericalFactorize()
Performs LU factorization numerically.
Definition: SuperLUMatrix.hpp:154
void SymbolicFactorize()
Factorizes the superlu matrix symbolically.
Definition: SuperLUMatrix.hpp:139
void SolveDistMultiVector(NumMat< T > &bLocal, DblNumVec &berr)
Solve A x = b with b overwritten by x for distributed multivector.
Definition: SuperLUMatrix.hpp:184
Main file for parallel selected inversion.
An thin interface to keep the main code insulated from the source code of SuperLU.
Definition: SuperLUMatrix.hpp:75
SuperLU processor grid.
Definition: SuperLUMatrix.hpp:206
Definition: SuperLUMatrix.hpp:337
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:128
void ConvertNRlocToNC(SuperLUMatrix< T > &AGlobal)
ConvertNRlocToNC converts a distributed compressed sparse row matrix to a global compressed sparse co...
Definition: SuperLUMatrix.hpp:160
Definition: superlu_dist_internal.hpp:102
PMatrix contains the main data structure and the computational routine for the parallel selected inve...
Definition: ngchol_interf.hpp:57
Definition: SuperLUGrid.hpp:124
void Distribute()
Distribute redistrbutes the SuperMatrix in parallel so that it is ready for the numerical factorizati...
Definition: SuperLUMatrix.hpp:146
A thin interface for the gridinfo_t structure in SuperLU.
Definition: SuperLUGrid.hpp:98
Definition: SuperLUGrid.hpp:111
void LUstructToPMatrix(PMatrix< T > &PMloc)
LUstructToPMatrix converts the data in LUstruct to PMatrix.
Definition: SuperLUMatrix.hpp:197
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:168
DistSparseMatrix describes a Sparse matrix in the compressed sparse column format (CSC) and distribut...
Definition: sparse_matrix.hpp:91