Xpetra_EpetraCrsMatrix.cpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #include <Teuchos_Array.hpp>
48 
49 namespace Xpetra {
50 
51 #if 0
52  template<class EpetraGlobalOrdinal, class Node>
53  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype, const Teuchos::RCP< Teuchos::ParameterList > &plist)
54  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<EpetraGlobalOrdinal,Node>(rowMap), maxNumEntriesPerRow, toEpetra(pftype)))), isFillResumed_(false)
55 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
56  , isInitializedLocalMatrix_(false)
57 #endif
58  { }
59 #endif
60 
61 #if 0
62  template<class EpetraGlobalOrdinal, class Node>
63  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype, const Teuchos::RCP< Teuchos::ParameterList > &plist)
64  : isFillResumed_(false)
65 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
66  , isInitializedLocalMatrix_(false)
67 #endif
68  {
69  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
70  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<EpetraGlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(pftype)));
71  }
72 #endif
73 
74 #if 0
75  template<class EpetraGlobalOrdinal, class Node>
76  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype, const Teuchos::RCP< Teuchos::ParameterList > &plist)
77  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<EpetraGlobalOrdinal,Node>(rowMap), toEpetra<EpetraGlobalOrdinal,Node>(colMap), maxNumEntriesPerRow, toEpetra(pftype)))), isFillResumed_(false)
78 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
79  , isInitializedLocalMatrix_(false)
80 #endif
81  { }
82 #endif
83 
84 #if 0
85  template<class EpetraGlobalOrdinal, class Node>
86  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype, const Teuchos::RCP< Teuchos::ParameterList > &plist)
87  : isFillResumed_(false)
88 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
89  , isInitializedLocalMatrix_(false)
90 #endif
91  {
92  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
93  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<EpetraGlobalOrdinal,Node>(rowMap), toEpetra<EpetraGlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(pftype)));
94  }
95 #endif
96 
97 #if 0
98  template<class EpetraGlobalOrdinal, class Node>
99  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist)
100  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<EpetraGlobalOrdinal,Node>(graph)))), isFillResumed_(false)
101 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
102  , isInitializedLocalMatrix_(false)
103 #endif
104  { }
105 #endif
106 
107 #if 0
108  template<class EpetraGlobalOrdinal, class Node>
109  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const EpetraCrsMatrixT& matrix)
110  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
111 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
112  , isInitializedLocalMatrix_(false)
113 #endif
114  { }
115 #endif
116 
117 #if 0
118  template<class EpetraGlobalOrdinal, class Node>
119  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const Teuchos::RCP<const CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& sourceMatrix,
120  const Import<LocalOrdinal,GlobalOrdinal,Node> &importer,
121  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& domainMap,
122  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rangeMap,
124  isFillResumed_(false)
125 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
126  , isInitializedLocalMatrix_(false)
127 #endif
128  {
129  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
130  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
131 
132  const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<EpetraGlobalOrdinal,Node>(domainMap): 0;
133  const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<EpetraGlobalOrdinal,Node>(rangeMap) : 0;
134 
135  // Follows the Tpetra parameters
136  bool restrictComm=false;
137  if(!params.is_null()) restrictComm = params->get("Restrict Communicator",restrictComm);
138  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
139  if(restrictComm && mtx_->NumMyRows()==0)
140  mtx_=Teuchos::null;
141  }
142 #endif
143 
144 #if 0
145  template<class EpetraGlobalOrdinal, class Node>
146  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT(const Teuchos::RCP<const Xpetra::CrsMatrix<Scalar,LocalOrdinal,EpetraGlobalOrdinal,Node> >& sourceMatrix,
147  const Export<LocalOrdinal,EpetraGlobalOrdinal,Node> &exporter,
148  const Teuchos::RCP<const Map<LocalOrdinal,EpetraGlobalOrdinal,Node> >& domainMap,
149  const Teuchos::RCP<const Map<LocalOrdinal,EpetraGlobalOrdinal,Node> >& rangeMap,
151  isFillResumed_(false)
152 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
153  , isInitializedLocalMatrix_(false)
154 #endif
155  {
156  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
157  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
158 
159  const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<EpetraGlobalOrdinal,Node>(domainMap): 0;
160  const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<EpetraGlobalOrdinal,Node>(rangeMap) : 0;
161 
162  // Follows the Tpetra parameters
163  bool restrictComm=false;
164  if(!params.is_null()) restrictComm = params->get("Restrict Communicator",restrictComm);
165 
166  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
167  }
168 #endif
169 
170 #if 0
171 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
172  template<class EpetraGlobalOrdinal, class Node>
173  EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::EpetraCrsMatrixT (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& rowMap,
174  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
175  const local_matrix_type& lclMatrix,
176  const Teuchos::RCP<Teuchos::ParameterList>& params) {
177  // local typedefs from local_matrix_type
178  typedef typename local_matrix_type::size_type size_type;
179  typedef typename local_matrix_type::value_type value_type;
180  typedef typename local_matrix_type::ordinal_type ordinal_type;
181 
182  // The number of rows in the sparse matrix.
183  ordinal_type lclNumRows = lclMatrix.numRows ();
184  ordinal_type lclNumCols = lclMatrix.numCols (); // do we need this?
185 
186  // plausibility checks
187  TEUCHOS_TEST_FOR_EXCEPTION(lclNumRows != Teuchos::as<ordinal_type>(rowMap->getNodeNumElements()), Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
188  TEUCHOS_TEST_FOR_EXCEPTION(lclNumCols != Teuchos::as<ordinal_type>(colMap->getNodeNumElements()), Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
189 
190  std::vector<GlobalOrdinal> domainMapGids; // vector for collecting domain map GIDs
191 
192  Teuchos::ArrayRCP< size_t > NumEntriesPerRowToAlloc(lclNumRows);
193  for (ordinal_type r = 0; r < lclNumRows; ++r) {
194  // extract data from current row r
195  Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
196  NumEntriesPerRowToAlloc[r] = rowview.length;
197  }
198 
199  // setup matrix
200  isFillResumed_ = false;
201  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
202  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<EpetraGlobalOrdinal,Node>(rowMap), toEpetra<EpetraGlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(DynamicProfile)));
203 
204  // loop over all rows and colums of local matrix and fill matrix
205  for (ordinal_type r = 0; r < lclNumRows; ++r) {
206  // extract data from current row r
207  Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
208 
209  // arrays for current row data
212 
213  for(ordinal_type c = 0; c < rowview.length; c++) {
214  value_type value = rowview.value (c);
215  ordinal_type colidx = rowview.colidx (c);
216 
217  TEUCHOS_TEST_FOR_EXCEPTION(colMap->isNodeLocalElement(colidx) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
218 
219  indout [c] = colidx;
220  valout [c] = value;
221 
222  // collect GIDs for domain map
223  GlobalOrdinal gcid = colMap->getGlobalElement(c);
224  if(rowMap->isNodeGlobalElement(gcid)) domainMapGids.push_back(gcid);
225  }
226  insertLocalValues(r, indout.view(0,indout.size()), valout.view(0,valout.size()));
227  }
228 
229  // sort entries in domainMapGids and remove duplicates
230  const GlobalOrdinal INVALID = Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid();
231  std::sort(domainMapGids.begin(), domainMapGids.end());
232  domainMapGids.erase(std::unique(domainMapGids.begin(), domainMapGids.end()), domainMapGids.end());
233  Teuchos::ArrayView<GlobalOrdinal> domainMapGidsView(&domainMapGids[0], domainMapGids.size());
235  Xpetra::MapFactory<LocalOrdinal,GlobalOrdinal,Node>::Build(colMap->lib(), INVALID, domainMapGidsView, colMap->getIndexBase(), colMap->getComm());
236 
237  // call fill complete
238  this->fillComplete(domainMap, rowMap, params);
239 
240  // AP (2015/10/22): Could probably be optimized using provided lclMatrix, but lets not worry about that
241  isInitializedLocalMatrix_ = false;
242  }
243 #endif
244 #endif
245 
246 #if 0
247  template<class EpetraGlobalOrdinal, class Node>
248  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::insertGlobalValues(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
249  XPETRA_MONITOR("EpetraCrsMatrixT::insertGlobalValues");
250  XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
251  }
252 #endif
253 
254 #if 0
255  template<class EpetraGlobalOrdinal, class Node>
256  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::insertLocalValues(LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
257  XPETRA_MONITOR("EpetraCrsMatrixT::insertLocalValues");
258  XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
259  }
260 #endif
261 
262 #if 0
263  template<class EpetraGlobalOrdinal, class Node>
264  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values) {
265  XPETRA_MONITOR("EpetraCrsMatrixT::replaceGlobalValues");
266 
267  {
268  const std::string tfecfFuncName("replaceGlobalValues");
269  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(! isFillActive(), std::runtime_error,
270  ": Fill must be active in order to call this method. If you have already "
271  "called fillComplete(), you need to call resumeFill() before you can "
272  "replace values.");
273 
274  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
275  std::runtime_error, ": values.size() must equal indices.size().");
276  }
277 
278  XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
279 
280  }
281 #endif
282 
283 #if 0
284  template<class EpetraGlobalOrdinal, class Node>
285  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values) {
286  XPETRA_MONITOR("EpetraCrsMatrixT::replaceLocalValues");
287 
288  {
289  const std::string tfecfFuncName("replaceLocalValues");
290  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(! isFillActive(), std::runtime_error,
291  ": Fill must be active in order to call this method. If you have already "
292  "called fillComplete(), you need to call resumeFill() before you can "
293  "replace values.");
294 
295  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
296  std::runtime_error, ": values.size() must equal indices.size().");
297  }
298 
299  XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
300 
301  }
302 #endif
303 
304 #if 0
305  template<class EpetraGlobalOrdinal, class Node>
306  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::allocateAllValues(size_t numNonZeros, ArrayRCP<size_t>& rowptr, ArrayRCP<LocalOrdinal>& colind, ArrayRCP<Scalar>& values) {
307  XPETRA_MONITOR("EpetraCrsMatrixT::allocateAllValues");
308 
309  // Row offsets
310  // Unfortunately, we cannot do this in the same manner as column indices
311  // and values (see below). The problem is that Tpetra insists on using
312  // size_t, and Epetra uses int internally. So we only resize here, and
313  // will need to copy in setAllValues
314  rowptr.resize(getNodeNumRows()+1);
315 
316  int lowerOffset = 0;
317  bool ownMemory = false;
318 
319  // Column indices
320  // Extract, resize, set colind
321  Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
322  myColind.Resize(numNonZeros);
323  colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
324 
325  // Values
326  // Extract, reallocate, set values
327  double *& myValues = mtx_->ExpertExtractValues();
328  delete [] myValues;
329  myValues = new double[numNonZeros];
330  values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
331  }
332 #endif
333 
334 #if 0
335  template<class EpetraGlobalOrdinal, class Node>
336  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::setAllValues(const ArrayRCP<size_t>& rowptr, const ArrayRCP<LocalOrdinal>& colind, const ArrayRCP<Scalar>& values) {
337  XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");
338 
339  // Check sizes
340  TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(rowptr.size()) != getNodeNumRows()+1, Xpetra::Exceptions::RuntimeError,
341  "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
342  TEUCHOS_TEST_FOR_EXCEPTION(values.size() != colind.size(), Xpetra::Exceptions::RuntimeError,
343  "An exception is thrown to let you know that you mismatched your pointers.");
344 
345  // Check pointers
346  if (values.size() > 0) {
347  TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
348  "An exception is thrown to let you know that you mismatched your pointers.");
349  TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
350  "An exception is thrown to let you know that you mismatched your pointers.");
351  }
352 
353  // We have to make a copy here, it is unavoidable
354  // See comments in allocateAllValues
355  const size_t N = getNodeNumRows();
356 
357  Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
358  myRowptr.Resize(N+1);
359  for (size_t i = 0; i < N+1; i++)
360  myRowptr[i] = Teuchos::as<int>(rowptr[i]);
361  }
362 #endif
363 #if 0
364  template<class EpetraGlobalOrdinal, class Node>
365  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::getAllValues(ArrayRCP<const size_t>& rowptr, ArrayRCP<const LocalOrdinal>& colind, ArrayRCP<const Scalar>& values) const {
366  XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
367 
368  int lowerOffset = 0;
369  bool ownMemory = false;
370 
371  const size_t n = getNodeNumRows();
372  const size_t nnz = getNodeNumEntries();
373 
374  // Row offsets
375  // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
376  Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
377  rowptr.resize(n+1);
378  for (size_t i = 0; i < n+1; i++)
379  (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
380 
381  // Column indices
382  colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
383 
384  // Values
385  values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
386  }
387 #endif
388 #if 0
389  template<class EpetraGlobalOrdinal, class Node>
390  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::resumeFill(const RCP< ParameterList > &params) {
391  XPETRA_MONITOR("EpetraCrsMatrixT::resumeFill");
392 
393  // According to Tpetra documentation, resumeFill() may be called repeatedly.
394  isFillResumed_ = true;
395  }
396 #endif
397 #if 0
398  template<class EpetraGlobalOrdinal, class Node>
399  bool EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::isFillComplete() const { XPETRA_MONITOR("EpetraCrsMatrixT::isFillComplete"); if (isFillResumed_) return false; else return mtx_->Filled(); }
400 #endif
401 #if 0
402  template<class EpetraGlobalOrdinal, class Node>
403  bool EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::isFillActive() const { XPETRA_MONITOR("EpetraCrsMatrixT::isFillActive"); return !isFillComplete(); }
404 #endif
405 #if 0
406  template<class EpetraGlobalOrdinal, class Node>
407  bool EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::supportsRowViews() const { XPETRA_MONITOR("EpetraCrsMatrixT::supportsRowViews"); return true; }
408 #endif
409 
410 #if 0
411  //TODO: throw same exception as Tpetra
412  template<class EpetraGlobalOrdinal, class Node>
413  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView<LocalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
414  XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowCopy");
415 
416  int numEntries = -1;
417  XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
418  NumEntries = numEntries;
419  }
420 #endif
421 #if 0
422  template<class EpetraGlobalOrdinal, class Node>
423  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView<GlobalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
424  XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowCopy");
425 
426  int numEntries = -1;
427  XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
428  NumEntries = numEntries;
429  }
430 #endif
431 #if 0
432  template<class EpetraGlobalOrdinal, class Node>
433  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values) const {
434  XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowView");
435 
436  int numEntries;
437  double * eValues;
438  GlobalOrdinal * eIndices;
439 
440  XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
441  if (numEntries == 0) { eValues = NULL; eIndices = NULL; } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
442 
443  indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
444  values = ArrayView<const double>(eValues, numEntries);
445  }
446 #endif
447 #if 0
448  template<class EpetraGlobalOrdinal, class Node>
449  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values) const {
450  XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowView");
451 
452  int numEntries;
453  double * eValues;
454  int * eIndices;
455 
456  XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
457  if (numEntries == 0) { eValues = NULL; eIndices = NULL; } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
458 
459  indices = ArrayView<const int>(eIndices, numEntries);
460  values = ArrayView<const double>(eValues, numEntries);
461  }
462 #endif
463 #if 0
464  template<class EpetraGlobalOrdinal, class Node>
465  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta) const {
466  XPETRA_MONITOR("EpetraCrsMatrixT::apply");
467 
468  //TEUCHOS_TEST_FOR_EXCEPTION((alpha != 1) || (beta != 0), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.multiply() only accept alpha==1 and beta==0");
469 
470  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, X, eX, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
471  XPETRA_DYNAMIC_CAST( EpetraMultiVectorT<GlobalOrdinal COMMA Node>, Y, eY, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
472 
473  TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
474  bool eTrans = toEpetra(mode);
475 
476  // /!\ UseTranspose value
477  TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(), Xpetra::Exceptions::NotImplemented, "An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
478 
479  RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
480 
481  // helper vector: tmp = A*x
482  RCP<Epetra_MultiVector> tmp = Teuchos::rcp(new Epetra_MultiVector(*epY));
483  tmp->PutScalar(0.0);
484  XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
485 
486  // calculate alpha * A * x + beta * y
487  XPETRA_ERR_CHECK(eY.getEpetra_MultiVector()->Update(alpha,*tmp,beta));
488  }
489 #endif
490 #if 0
491  template<class EpetraGlobalOrdinal, class Node>
492  std::string EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::description() const {
493  XPETRA_MONITOR("EpetraCrsMatrixT::description");
494 
495  // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
496  std::ostringstream oss;
497  //TODO: oss << DistObject<char, LocalOrdinal,GlobalOrdinal>::description();
498  if (isFillComplete()) {
499  oss << "{status = fill complete"
500  << ", global rows = " << getGlobalNumRows()
501  << ", global cols = " << getGlobalNumCols()
502  << ", global num entries = " << getGlobalNumEntries()
503  << "}";
504  }
505  else {
506  oss << "{status = fill not complete"
507  << ", global rows = " << getGlobalNumRows()
508  << "}";
509  }
510  return oss.str();
511 
512  }
513 #endif
514 #if 0
515  template<class EpetraGlobalOrdinal, class Node>
516  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const {
517  XPETRA_MONITOR("EpetraCrsMatrixT::describe");
518 
519  // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
520  using std::endl;
521  using std::setw;
522  using Teuchos::VERB_DEFAULT;
523  using Teuchos::VERB_NONE;
524  using Teuchos::VERB_LOW;
525  using Teuchos::VERB_MEDIUM;
526  using Teuchos::VERB_HIGH;
527  using Teuchos::VERB_EXTREME;
528  Teuchos::EVerbosityLevel vl = verbLevel;
529  if (vl == VERB_DEFAULT) vl = VERB_LOW;
530  RCP<const Comm<int> > comm = this->getComm();
531  const int myImageID = comm->getRank(),
532  numImages = comm->getSize();
533  size_t width = 1;
534  for (size_t dec=10; dec<getGlobalNumRows(); dec *= 10) {
535  ++width;
536  }
537  width = std::max<size_t>(width,11) + 2;
538  Teuchos::OSTab tab(out);
539  // none: print nothing
540  // low: print O(1) info from node 0
541  // medium: print O(P) info, num entries per node
542  // high: print O(N) info, num entries per row
543  // extreme: print O(NNZ) info: print indices and values
544  //
545  // for medium and higher, print constituent objects at specified verbLevel
546  if (vl != VERB_NONE) {
547  if (myImageID == 0) out << this->description() << std::endl;
548  // O(1) globals, minus what was already printed by description()
549  if (isFillComplete() && myImageID == 0) {
550  out << "Global number of diagonals = " << getGlobalNumDiags() << std::endl;
551  out << "Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
552  }
553  // constituent objects
554  if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
555  if (myImageID == 0) out << "\nRow map: " << std::endl;
556  getRowMap()->describe(out,vl);
557  //
558  if (getColMap() != null) {
559  if (getColMap() == getRowMap()) {
560  if (myImageID == 0) out << "\nColumn map is row map.";
561  }
562  else {
563  if (myImageID == 0) out << "\nColumn map: " << std::endl;
564  getColMap()->describe(out,vl);
565  }
566  }
567  if (getDomainMap() != null) {
568  if (getDomainMap() == getRowMap()) {
569  if (myImageID == 0) out << "\nDomain map is row map.";
570  }
571  else if (getDomainMap() == getColMap()) {
572  if (myImageID == 0) out << "\nDomain map is row map.";
573  }
574  else {
575  if (myImageID == 0) out << "\nDomain map: " << std::endl;
576  getDomainMap()->describe(out,vl);
577  }
578  }
579  if (getRangeMap() != null) {
580  if (getRangeMap() == getDomainMap()) {
581  if (myImageID == 0) out << "\nRange map is domain map." << std::endl;
582  }
583  else if (getRangeMap() == getRowMap()) {
584  if (myImageID == 0) out << "\nRange map is row map." << std::endl;
585  }
586  else {
587  if (myImageID == 0) out << "\nRange map: " << std::endl;
588  getRangeMap()->describe(out,vl);
589  }
590  }
591  if (myImageID == 0) out << std::endl;
592  }
593  // O(P) data
594  if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
595  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
596  if (myImageID == imageCtr) {
597  out << "Node ID = " << imageCtr << std::endl;
598  // TODO: need a graph
599  // if (staticGraph_->indicesAreAllocated() == false) {
600  // out << "Node not allocated" << std::endl;
601  // }
602  // else {
603  // out << "Node number of allocated entries = " << staticGraph_->getNodeAllocationSize() << std::endl;
604  // }
605 
606  // TMP:
607  // const Epetra_CrsGraph & staticGraph_ = mtx_->Graph();
608  // End of TMP
609 
610  out << "Node number of entries = " << getNodeNumEntries() << std::endl;
611  if (isFillComplete()) {
612  out << "Node number of diagonals = " << getNodeNumDiags() << std::endl;
613  }
614  out << "Node max number of entries = " << getNodeMaxNumRowEntries() << std::endl;
615  }
616  comm->barrier();
617  comm->barrier();
618  comm->barrier();
619  }
620  }
621  // O(N) and O(NNZ) data
622  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
623  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
624  if (myImageID == imageCtr) {
625  out << std::setw(width) << "Node ID"
626  << std::setw(width) << "Global Row"
627  << std::setw(width) << "Num Entries";
628  if (vl == VERB_EXTREME) {
629  out << std::setw(width) << "(Index,Value)";
630  }
631  out << std::endl;
632  for (size_t r=0; r < getNodeNumRows(); ++r) {
633  const size_t nE = getNumEntriesInLocalRow(r);
634  GlobalOrdinal gid = getRowMap()->getGlobalElement(r);
635  out << std::setw(width) << myImageID
636  << std::setw(width) << gid
637  << std::setw(width) << nE;
638  if (vl == VERB_EXTREME) {
639  if (isGloballyIndexed()) {
640  ArrayView<const GlobalOrdinal> rowinds;
641  ArrayView<const Scalar> rowvals;
642  getGlobalRowView(gid,rowinds,rowvals);
643  for (size_t j=0; j < nE; ++j) {
644  out << " (" << rowinds[j]
645  << ", " << rowvals[j]
646  << ") ";
647  }
648  }
649  else if (isLocallyIndexed()) {
650  ArrayView<const LocalOrdinal> rowinds;
651  ArrayView<const Scalar> rowvals;
652  getLocalRowView(r,rowinds,rowvals);
653  for (size_t j=0; j < nE; ++j) {
654  out << " (" << getColMap()->getGlobalElement(rowinds[j])
655  << ", " << rowvals[j]
656  << ") ";
657  }
658  }
659  }
660  out << std::endl;
661  }
662  }
663  comm->barrier();
664  comm->barrier();
665  comm->barrier();
666  }
667  }
668  }
669 
670  }
671 #endif
672 #if 0
673  // TODO: use toEpetra()
674  template<class EpetraGlobalOrdinal, class Node>
675  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::doImport(const DistObject<char, LocalOrdinal, GlobalOrdinal, Node> &source,
676  const Import<LocalOrdinal, GlobalOrdinal, Node> &importer, CombineMode CM) {
677  XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
678 
679  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
680  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
681 
682  RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
683  int err = mtx_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
684  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
685  }
686 #endif
687 #if 0
688  template<class EpetraGlobalOrdinal, class Node>
689  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::doExport(const DistObject<char, LocalOrdinal, GlobalOrdinal, Node> &dest,
690  const Import<LocalOrdinal, GlobalOrdinal, Node>& importer, CombineMode CM) {
691  XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
692 
693  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
694  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
695 
696  RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
697  int err = mtx_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
698  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
699  }
700 #endif
701 #if 0
702  template<class EpetraGlobalOrdinal, class Node>
703  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::doImport(const DistObject<char, LocalOrdinal, GlobalOrdinal, Node> &source,
704  const Export<LocalOrdinal, GlobalOrdinal, Node>& exporter, CombineMode CM) {
705  XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
706 
707  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
708  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
709 
710  RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
711  int err = mtx_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
712  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
713 
714  }
715 #endif
716 #if 0
717  template<class EpetraGlobalOrdinal, class Node>
718  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::doExport(const DistObject<char, LocalOrdinal, GlobalOrdinal, Node> &dest,
719  const Export<LocalOrdinal, GlobalOrdinal, Node>& exporter, CombineMode CM) {
720  XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
721 
722  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
723  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
724 
725  RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
726  int err = mtx_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
727  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
728  }
729 #endif
730 #if 0
731  template<class EpetraGlobalOrdinal, class Node>
732  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap,
733  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap,
734  const RCP< ParameterList > &params) {
735  XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
736 
737  // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
738  if (isFillResumed_ == true) { isFillResumed_ = false; return; }
739 
740  bool doOptimizeStorage = true;
741  if (params != null && params->get("Optimize Storage",true) == false) doOptimizeStorage = false;
742  mtx_->FillComplete(toEpetra<EpetraGlobalOrdinal,Node>(domainMap), toEpetra<EpetraGlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
743  }
744 #endif
745 #if 0
746  template<class EpetraGlobalOrdinal, class Node>
747  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::fillComplete(const RCP< ParameterList > &params) {
748  XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
749 
750  // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
751  if (isFillResumed_ == true) { isFillResumed_ = false; return; }
752 
753  bool doOptimizeStorage = true;
754  if (params != null && params->get("Optimize Storage",true) == false) doOptimizeStorage = false;
755  mtx_->FillComplete(doOptimizeStorage);
756  }
757 #endif
758 #if 0
759  template<class EpetraGlobalOrdinal, class Node>
760  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >& newDomainMap, Teuchos::RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > & newImporter) {
761  XPETRA_MONITOR("EpetraCrsMatrixT::replaceDomainMapAndImporter");
762  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, *newImporter, eImporter, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter only accepts Xpetra::EpetraImportT.");
763 
764  const RCP<const Epetra_Import> & myImport = eImporter.getEpetra_Import();
765  int rv=0;
766  if(myImport==Teuchos::null)
767  rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<EpetraGlobalOrdinal,Node>(newDomainMap),0);
768  else
769  rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<EpetraGlobalOrdinal,Node>(newDomainMap),&*myImport);
770  TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
771  }
772 #endif
773 #if 0
774  template<class EpetraGlobalOrdinal, class Node>
775  void EpetraCrsMatrixT<EpetraGlobalOrdinal, Node>::expertStaticFillComplete(const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap,
776  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
777  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > &importer,
778  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > &exporter,
779  const RCP<ParameterList> & params) {
780  XPETRA_MONITOR("EpetraCrsMatrixT::expertStaticFillComplete");
781  int rv=0;
782  const Epetra_Import * myimport =0;
783  const Epetra_Export * myexport =0;
784 
785  if(!importer.is_null()) {
786  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, *importer, eImporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
787  myimport = eImporter.getEpetra_Import().getRawPtr();
788  }
789  if(!exporter.is_null()) {
790  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, *exporter, eExporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
791  myexport = eExporter.getEpetra_Export().getRawPtr();
792  }
793 
794  rv=mtx_->ExpertStaticFillComplete(toEpetra<EpetraGlobalOrdinal,Node>(domainMap), toEpetra<EpetraGlobalOrdinal,Node>(rangeMap), myimport, myexport);
795 
796  TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
797  }
798 #endif
799 
800 
801 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
802 #ifdef HAVE_XPETRA_TPETRA
803 #ifdef HAVE_XPETRA_SERIAL
804 template class EpetraCrsMatrixT<int, Kokkos::Compat::KokkosSerialWrapperNode >;
805 #endif
806 #ifdef HAVE_XPETRA_PTHREAD
807 template class EpetraCrsMatrixT<int, Kokkos::Compat::KokkosThreadsWrapperNode>;
808 #endif
809 #ifdef HAVE_XPETRA_OPENMP
810 template class EpetraCrsMatrixT<int, Kokkos::Compat::KokkosOpenMPWrapperNode >;
811 #endif
812 #ifdef HAVE_XPETRA_CUDA
813 typedef Kokkos::Compat::KokkosCudaWrapperNode default_node_type;
814 template class EpetraCrsMatrixT<int, default_node_type >;
815 #endif
816 #else
817 // Tpetra is disabled and Kokkos not available: use dummy node type
818 typedef Kokkos::Compat::KokkosSerialWrapperNode default_node_type;
819 template class EpetraCrsMatrixT<int, default_node_type >;
820 #endif // HAVE_XPETRA_TPETRA
821 #endif
822 
823 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
824 #ifdef HAVE_XPETRA_TPETRA
825 #ifdef HAVE_XPETRA_SERIAL
826 template class EpetraCrsMatrixT<long long, Kokkos::Compat::KokkosSerialWrapperNode >;
827 #endif
828 #ifdef HAVE_XPETRA_PTHREAD
829 template class EpetraCrsMatrixT<long long, Kokkos::Compat::KokkosThreadsWrapperNode>;
830 #endif
831 #ifdef HAVE_XPETRA_OPENMP
832 template class EpetraCrsMatrixT<long long, Kokkos::Compat::KokkosOpenMPWrapperNode >;
833 #endif
834 #ifdef HAVE_XPETRA_CUDA
835 typedef Kokkos::Compat::KokkosCudaWrapperNode default_node_type;
836 template class EpetraCrsMatrixT<long long, default_node_type >;
837 #endif
838 #else
839 // Tpetra is disabled and Kokkos not available: use dummy node type
840 typedef Kokkos::Compat::KokkosSerialWrapperNode default_node_type;
841 template class EpetraCrsMatrixT<long long, default_node_type >;
842 #endif // HAVE_XPETRA_TPETRA
843 #endif
844 
845 }
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=Xpetra::GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Xpetra namespace
Exception throws to report errors in the internal logical of the program.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define XPETRA_ERR_CHECK(arg)
void resize(size_type new_size, const value_type &x=value_type())
Exception throws when you call an unimplemented method of Xpetra.
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
Copy
CombineMode
Xpetra::Combine Mode enumerable type.
#define XPETRA_MONITOR(funcName)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
bool is_null() const