PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
SuperLUGrid_impl.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 Authors: 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_SUPERLUGRID_IMPL_HPP_
47 #define _PEXSI_SUPERLUGRID_IMPL_HPP_
48 
49 namespace PEXSI{
50 
51 
52 
53 
54 
55 
56 inline SuperLUGrid<Real>::SuperLUGrid ( MPI_Comm comm, Int nprow, Int npcol )
57 {
58  ptrData = new RealGridData;
59  if( ptrData == NULL ){
60  ErrorHandling( "SuperLUGrid cannot be allocated." );
61  }
62  ptrData->GridInit(comm, nprow, npcol);
63 
64 
65  return ;
66 } // ----- end of method SuperLUGrid::SuperLUGrid -----
67 
68 inline SuperLUGrid<Real>::~SuperLUGrid ( )
69 {
70  // NOTE (07/21/2013): Since superlu_gridinit gets a copy of the
71  // communicator, it is legal to call superlu_gridexit even if
72  // grid->comm is a copy of MPI_COMM_WORLD.
73 
74  ptrData->GridExit();
75 
76  delete ptrData;
77 
78  return ;
79 } // ----- end of method SuperLUGrid::~SuperLUGrid -----
80 
81 
82 
83 
84 
85 
86 inline SuperLUGrid<Real>::SuperLUGrid(const SuperLUGrid<Real> & g)
87 {
88 
89  if(g.ptrData == NULL){
90  ErrorHandling( "Original SuperLUGrid not allocated." );
91  }
92 
93  ptrData = new RealGridData(*g.ptrData);
94  if( ptrData == NULL ){
95  ErrorHandling( "SuperLUGrid cannot be allocated." );
96  }
97 
98 
99  return ;
100 } // ----- end of method SuperLUGrid::SuperLUGrid -----
101 
102 inline SuperLUGrid<Real> & SuperLUGrid<Real>::operator = (const SuperLUGrid<Real> & g){
103 
104  if(&g!=this){
105  if(this->ptrData!=NULL){
106  ptrData->GridExit();
107  delete ptrData;
108  }
109 
110  if(g.ptrData == NULL){
111  ErrorHandling( "Original SuperLUGrid not allocated." );
112  }
113  else{
114  ptrData = new RealGridData(*g.ptrData);
115  if( ptrData == NULL ){
116  ErrorHandling( "SuperLUGrid cannot be allocated." );
117  }
118  }
119  }
120 
121  return *this;
122 }
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 inline SuperLUGrid<Complex>::SuperLUGrid ( MPI_Comm comm, Int nprow, Int npcol )
135 {
136  ptrData = new ComplexGridData;
137  if( ptrData == NULL ){
138  ErrorHandling( "SuperLUGrid cannot be allocated." );
139  }
140  ptrData->GridInit(comm, nprow, npcol);
141 
142 
143  return ;
144 } // ----- end of method SuperLUGrid::SuperLUGrid -----
145 
146 
147 inline SuperLUGrid<Complex>::~SuperLUGrid ( )
148 {
149  // NOTE (07/21/2013): Since superlu_gridinit gets a copy of the
150  // communicator, it is legal to call superlu_gridexit even if
151  // grid->comm is a copy of MPI_COMM_WORLD.
152 
153  ptrData->GridExit();
154 
155  delete ptrData;
156 
157  return ;
158 } // ----- end of method SuperLUGrid::~SuperLUGrid -----
159 
160 
161 inline SuperLUGrid<Complex>::SuperLUGrid(const SuperLUGrid<Complex> & g)
162 {
163 
164  if(g.ptrData == NULL){
165  ErrorHandling( "Original SuperLUGrid not allocated." );
166  }
167 
168  ptrData = new ComplexGridData(*g.ptrData);
169  if( ptrData == NULL ){
170  ErrorHandling( "SuperLUGrid cannot be allocated." );
171  }
172 
173 
174  return ;
175 } // ----- end of method SuperLUGrid::SuperLUGrid -----
176 
177 inline SuperLUGrid<Complex> & SuperLUGrid<Complex>::operator = (const SuperLUGrid<Complex> & g){
178 
179  if(&g!=this){
180  if(this->ptrData!=NULL){
181  ptrData->GridExit();
182  delete ptrData;
183  }
184 
185  if(g.ptrData == NULL){
186  ErrorHandling( "Original SuperLUGrid not allocated." );
187  }
188  else{
189  ptrData = new ComplexGridData(*g.ptrData);
190  if( ptrData == NULL ){
191  ErrorHandling( "SuperLUGrid cannot be allocated." );
192  }
193  }
194  }
195 
196  return *this;
197 }
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 }
210 
211 
212 #endif //_PEXSI_SUPERLUGRID_IMPL_HPP_
void * ptrData
SuperLUMatrix can have access to the grid information.
Definition: SuperLUGrid.hpp:101