Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MatrixFactory.hpp
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 
47 // WARNING: This code is experimental. Backwards compatibility should not be expected.
48 
49 #ifndef XPETRA_MATRIXFACTORY_HPP
50 #define XPETRA_MATRIXFACTORY_HPP
51 
52 #include "Xpetra_ConfigDefs.hpp"
54 #include "Xpetra_Matrix.hpp"
55 #include "Xpetra_CrsMatrixWrap.hpp"
57 #include "Xpetra_Map.hpp"
58 #include "Xpetra_BlockedMap.hpp"
59 #include "Xpetra_Vector.hpp"
60 #include "Xpetra_BlockedVector.hpp"
61 #include "Xpetra_Exceptions.hpp"
62 
63 namespace Xpetra {
64 
65 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
66 class MatrixFactory2 {
67 #undef XPETRA_MATRIXFACTORY2_SHORT
68 #include "Xpetra_UseShortNames.hpp"
69 
70  public:
71  static RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > BuildCopy(const RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A, bool setFixedBlockSize = true) {
72  RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
73  if (oldOp == Teuchos::null)
74  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
75 
76  RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
77 
78  UnderlyingLib lib = A->getRowMap()->lib();
79 
80  TEUCHOS_TEST_FOR_EXCEPTION(lib != UseEpetra && lib != UseTpetra, Exceptions::RuntimeError,
81  "Not Epetra or Tpetra matrix");
82 
83 #ifdef HAVE_XPETRA_EPETRA
84  if (lib == UseEpetra) {
85  // NOTE: The proper Epetra conversion in Xpetra_MatrixFactory.cpp
86  throw Exceptions::RuntimeError("Xpetra::BuildCopy(): matrix templates are incompatible with Epetra");
87  }
88 #endif
89 
90 #ifdef HAVE_XPETRA_TPETRA
91  if (lib == UseTpetra) {
92  // Underlying matrix is Tpetra
93  RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
94 
95  if (oldTCrsOp != Teuchos::null) {
96  RCP<TpetraCrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
97  RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(Teuchos::as<RCP<CrsMatrix> >(newTCrsOp)));
98  if (setFixedBlockSize)
99  newOp->SetFixedBlockSize(A->GetFixedBlockSize());
100 
101  return newOp;
102  } else {
103  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::TpetraCrsMatrix failed");
104  }
105  }
106 #endif
107 
108  return Teuchos::null;
109  }
110 };
111 #define XPETRA_MATRIXFACTORY2_SHORT
112 
113 // template<>
114 // class MatrixFactory2<double,int,int,typename Xpetra::Matrix<double, int, int>::node_type> {
115 template <class Node>
116 class MatrixFactory2<double, int, int, Node> {
117  typedef double Scalar;
118  typedef int LocalOrdinal;
119  typedef int GlobalOrdinal;
120  // typedef Matrix<double, int, GlobalOrdinal>::node_type Node;
121 #undef XPETRA_MATRIXFACTORY2_SHORT
122 #include "Xpetra_UseShortNames.hpp"
123  public:
124  static RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > BuildCopy(const RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A, bool setFixedBlockSize = true) {
125  RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
126  if (oldOp == Teuchos::null)
127  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
128 
129  RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
130 
131 #ifdef HAVE_XPETRA_EPETRA
132 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
133  RCP<const EpetraCrsMatrixT<GlobalOrdinal, Node> > oldECrsOp = Teuchos::rcp_dynamic_cast<const EpetraCrsMatrixT<GlobalOrdinal, Node> >(oldCrsOp);
134  if (oldECrsOp != Teuchos::null) {
135  // Underlying matrix is Epetra
136  RCP<CrsMatrix> newECrsOp(new EpetraCrsMatrixT<GlobalOrdinal, Node>(*oldECrsOp));
137  RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(newECrsOp));
138  if (setFixedBlockSize)
139  newOp->SetFixedBlockSize(A->GetFixedBlockSize());
140  return newOp;
141  }
142 #endif
143 #endif
144 
145 #ifdef HAVE_XPETRA_TPETRA
146  // Underlying matrix is Tpetra
147  RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
148  if (oldTCrsOp != Teuchos::null) {
149  RCP<CrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
150  RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(newTCrsOp));
151  if (setFixedBlockSize)
152  newOp->SetFixedBlockSize(A->GetFixedBlockSize());
153  return newOp;
154  }
155  return Teuchos::null;
156 #else
157  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
158  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null); // make compiler happy
159 #endif
160 
161  } // BuildCopy
162 };
163 
164 #define XPETRA_MATRIXFACTORY2_SHORT
165 
166 #ifdef HAVE_XPETRA_INT_LONG_LONG
167 // template<>
168 // class MatrixFactory2<double,int,long long,typename Xpetra::Matrix<double, int, long long>::node_type> {
169 template <class Node>
170 class MatrixFactory2<double, int, long long, Node> {
171  typedef double Scalar;
172  typedef int LocalOrdinal;
173  typedef long long GlobalOrdinal;
174  // typedef Matrix<double, int, GlobalOrdinal>::node_type Node;
175 #undef XPETRA_MATRIXFACTORY2_SHORT
176 #include "Xpetra_UseShortNames.hpp"
177  public:
178  static RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > BuildCopy(const RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A, bool setFixedBlockSize = true) {
179  RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
180  if (oldOp == Teuchos::null)
181  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
182 
183  RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
184 
185 #ifdef HAVE_XPETRA_EPETRA
186 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
187  RCP<const EpetraCrsMatrixT<GlobalOrdinal, Node> > oldECrsOp = Teuchos::rcp_dynamic_cast<const EpetraCrsMatrixT<GlobalOrdinal, Node> >(oldCrsOp);
188  if (oldECrsOp != Teuchos::null) {
189  // Underlying matrix is Epetra
190  RCP<CrsMatrix> newECrsOp(new EpetraCrsMatrixT<GlobalOrdinal, Node>(*oldECrsOp));
191  RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(newECrsOp));
192  if (setFixedBlockSize)
193  newOp->SetFixedBlockSize(A->GetFixedBlockSize());
194  return newOp;
195  }
196 #endif
197 #endif
198 
199 #ifdef HAVE_XPETRA_TPETRA
200  // Underlying matrix is Tpetra
201  RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
202  if (oldTCrsOp != Teuchos::null) {
203  RCP<CrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
204  RCP<CrsMatrixWrap> newOp(new CrsMatrixWrap(newTCrsOp));
205  if (setFixedBlockSize)
206  newOp->SetFixedBlockSize(A->GetFixedBlockSize());
207  return newOp;
208  }
209 #else
210  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
211 #endif
212 
213  return Teuchos::null; // make compiler happy
214  }
215 };
216 #endif // HAVE_XPETRA_INT_LONG_LONG
217 
218 #define XPETRA_MATRIXFACTORY2_SHORT
219 
220 template <class Scalar,
221  class LocalOrdinal,
222  class GlobalOrdinal,
223  class Node>
224 class MatrixFactory {
225 #undef XPETRA_MATRIXFACTORY_SHORT
226 #include "Xpetra_UseShortNames.hpp"
227 
228  private:
231 
232  public:
235  static RCP<Matrix> Build(const RCP<const Map>& rowMap) {
236  return rcp(new CrsMatrixWrap(rowMap));
237  }
238 
240  static RCP<Matrix> Build(const RCP<const Map>& rowMap, size_t maxNumEntriesPerRow) {
241  return rcp(new CrsMatrixWrap(rowMap, maxNumEntriesPerRow));
242  }
243 
245  static RCP<Matrix> Build(const RCP<const Map>& rowMap, const RCP<const Map>& colMap, size_t maxNumEntriesPerRow) {
246  return rcp(new CrsMatrixWrap(rowMap, colMap, maxNumEntriesPerRow));
247  }
248 
250  static RCP<Matrix> Build(const RCP<const Map>& rowMap, const RCP<const Map>& colMap, const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc) {
251  return rcp(new CrsMatrixWrap(rowMap, colMap, NumEntriesPerRowToAlloc));
252  }
253 
255  static RCP<Matrix> Build(
256  const Teuchos::RCP<const Map>& rowMap,
257  const Teuchos::RCP<const Map>& colMap,
259  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
260  XPETRA_MONITOR("MatrixFactory::Build");
261  return rcp(new CrsMatrixWrap(rowMap, colMap, lclMatrix, params));
262  }
264  static RCP<Matrix> Build(
266  const Teuchos::RCP<const Map>& rowMap,
267  const Teuchos::RCP<const Map>& colMap,
268  const Teuchos::RCP<const Map>& domainMap = Teuchos::null,
269  const Teuchos::RCP<const Map>& rangeMap = Teuchos::null,
270  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
271  XPETRA_MONITOR("MatrixFactory::Build");
272  return rcp(new CrsMatrixWrap(lclMatrix, rowMap, colMap, domainMap, rangeMap, params));
273  }
274 
276  static RCP<Matrix> Build(const RCP<const Map>& rowMap, const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc) {
277  return rcp(new CrsMatrixWrap(rowMap, NumEntriesPerRowToAlloc));
278  }
279 
281  static RCP<Matrix> Build(const RCP<const CrsGraph>& graph, const RCP<ParameterList>& paramList = Teuchos::null) {
282  return rcp(new CrsMatrixWrap(graph, paramList));
283  }
284 
286  static RCP<Matrix> Build(const RCP<const CrsGraph>& graph,
288  const RCP<ParameterList>& paramList = Teuchos::null) {
289  return rcp(new CrsMatrixWrap(graph, values, paramList));
290  }
291 
293  static RCP<Matrix> Build(const RCP<const Vector>& diagonal) {
294  RCP<const BlockedVector> bdiagonal = Teuchos::rcp_dynamic_cast<const BlockedVector>(diagonal);
295  Teuchos::RCP<Matrix> mtx = Teuchos::null;
296 
297  if (bdiagonal == Teuchos::null) {
298  Teuchos::ArrayRCP<const Scalar> vals = diagonal->getData(0);
299  LocalOrdinal numMyElements = diagonal->getMap()->getLocalNumElements();
300  Teuchos::ArrayView<const GlobalOrdinal> myGlobalElements = diagonal->getMap()->getLocalElementList();
301 
302  mtx = Teuchos::rcp(new CrsMatrixWrap(diagonal->getMap(), 1));
303 
304  for (LocalOrdinal i = 0; i < numMyElements; ++i) {
305  mtx->insertGlobalValues(myGlobalElements[i],
306  Teuchos::tuple<GlobalOrdinal>(myGlobalElements[i]),
307  Teuchos::tuple<Scalar>(vals[i]));
308  }
309  mtx->fillComplete();
310  } else {
311  RCP<BlockedCrsMatrix> bop = Teuchos::rcp(new BlockedCrsMatrix(bdiagonal->getBlockedMap(), bdiagonal->getBlockedMap(), 1));
312 
313  for (size_t r = 0; r < bdiagonal->getBlockedMap()->getNumMaps(); ++r) {
314  if (!bdiagonal->getMultiVector(r).is_null()) {
315  const RCP<MultiVector> subvec = bdiagonal->getMultiVector(r);
316  bop->setMatrix(r, r, Build(subvec->getVector(0)));
317  }
318  }
319  bop->fillComplete();
320  mtx = BuildCopy(bop);
321  }
322 
323  return mtx;
324  }
325 
327  static RCP<Matrix> Build(const RCP<const Matrix>& sourceMatrix, const Import& importer, const RCP<const Map>& domainMap = Teuchos::null, const RCP<const Map>& rangeMap = Teuchos::null, const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
328  RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
329  if (crsOp == Teuchos::null)
330  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
331 
332  RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
333  RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, importer, domainMap, rangeMap, params);
334  if (newCrs->hasMatrix())
335  return rcp(new CrsMatrixWrap(newCrs));
336  else
337  return Teuchos::null;
338  }
339 
341  static RCP<Matrix> Build(const RCP<const Matrix>& sourceMatrix, const Export& exporter, const RCP<const Map>& domainMap, const RCP<const Map>& rangeMap, const Teuchos::RCP<Teuchos::ParameterList>& params) {
342  RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
343  if (crsOp == Teuchos::null)
344  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
345 
346  RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
347  return rcp(new CrsMatrixWrap(CrsMatrixFactory::Build(originalCrs, exporter, domainMap, rangeMap, params)));
348  }
349 
351  static RCP<Matrix> Build(const RCP<const Matrix>& sourceMatrix, const Import& RowImporter, const Import& DomainImporter, const RCP<const Map>& domainMap, const RCP<const Map>& rangeMap, const Teuchos::RCP<Teuchos::ParameterList>& params) {
352  RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
353  if (crsOp == Teuchos::null)
354  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
355 
356  RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
357  RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, RowImporter, Teuchos::rcpFromRef(DomainImporter), domainMap, rangeMap, params);
358  if (newCrs->hasMatrix())
359  return rcp(new CrsMatrixWrap(newCrs));
360  else
361  return Teuchos::null;
362  }
363 
365  static RCP<Matrix> Build(const RCP<const Matrix>& sourceMatrix, const Export& RowExporter, const Export& DomainExporter, const RCP<const Map>& domainMap = Teuchos::null, const RCP<const Map>& rangeMap = Teuchos::null, const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
366  RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
367  if (crsOp == Teuchos::null)
368  throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
369 
370  RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
371  RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, RowExporter, Teuchos::rcpFromRef(DomainExporter), domainMap, rangeMap, params);
372  if (newCrs->hasMatrix())
373  return rcp(new CrsMatrixWrap(newCrs));
374  else
375  return Teuchos::null;
376  }
377 
380  static RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > BuildCopy(const RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A, bool setFixedBlockSize = true) {
381  RCP<const BlockedCrsMatrix> input = Teuchos::rcp_dynamic_cast<const BlockedCrsMatrix>(A);
382  if (input == Teuchos::null)
384 
385  // deep copy of MapExtractors (and underlying maps)
386  RCP<const MapExtractor> rgMapExt = Teuchos::rcp(new MapExtractor(*(input->getRangeMapExtractor())));
387  RCP<const MapExtractor> doMapExt = Teuchos::rcp(new MapExtractor(*(input->getDomainMapExtractor())));
388 
389  // create new BlockedCrsMatrix object
390  RCP<BlockedCrsMatrix> bop = Teuchos::rcp(new BlockedCrsMatrix(rgMapExt, doMapExt, input->getLocalMaxNumRowEntries()));
391 
392  for (size_t r = 0; r < input->Rows(); ++r) {
393  for (size_t c = 0; c < input->Cols(); ++c)
394  if (input->getMatrix(r, c) != Teuchos::null) {
395  // make a deep copy of the matrix
396  // This is a recursive call to this function
397  RCP<Matrix> mat =
398  Xpetra::MatrixFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::BuildCopy(input->getMatrix(r, c), setFixedBlockSize);
399  bop->setMatrix(r, c, mat);
400  }
401  }
402 
403  if (input->isFillComplete())
404  bop->fillComplete();
405  return bop;
406  }
407 };
408 #define XPETRA_MATRIXFACTORY_SHORT
409 
410 } // namespace Xpetra
411 
412 #define XPETRA_MATRIXFACTORY_SHORT
413 #define XPETRA_MATRIXFACTORY2_SHORT
414 #endif
static RCP< Matrix > Build(const RCP< const Vector > &diagonal)
Constructor for creating a diagonal Xpetra::Matrix using the entries of a given vector for the diagon...
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
static RCP< Matrix > Build(const RCP< const CrsGraph > &graph, typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type::values_type &values, const RCP< ParameterList > &paramList=Teuchos::null)
Constructor specifying graph and values array.
static RCP< Matrix > Build(const RCP< const Matrix > &sourceMatrix, const Import &importer, const RCP< const Map > &domainMap=Teuchos::null, const RCP< const Map > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor to create a Matrix using a fusedImport-style construction. The originalMatrix must be a X...
static RCP< Matrix > Build(const RCP< const CrsGraph > &graph, const RCP< ParameterList > &paramList=Teuchos::null)
Constructor specifying graph.
static RCP< Matrix > Build(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, size_t maxNumEntriesPerRow)
Constructor specifying the max number of non-zeros per row and providing column map.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &rowMap)
Constructor for empty matrix (intended use is an import/export target - can&#39;t insert entries directly...
static RCP< Matrix > Build(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow)
Constructor specifying the number of non-zeros for all rows.
static RCP< Matrix > Build(const RCP< const Map > &rowMap)
Exception throws to report errors in the internal logical of the program.
Exception indicating invalid cast attempted.
static RCP< Matrix > Build(const RCP< const Map > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc)
Constructor specifying (possibly different) number of entries in each row.
static RCP< Matrix > Build(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc)
Constructor specifying the (possibly different) number of entries per row and providing column map...
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
static RCP< Matrix > Build(const typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type &lclMatrix, const Teuchos::RCP< const Map > &rowMap, const Teuchos::RCP< const Map > &colMap, const Teuchos::RCP< const Map > &domainMap=Teuchos::null, const Teuchos::RCP< const Map > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
Constructor providing a local Kokkos::CrsMatrix together with all maps.
static RCP< Matrix > Build(const RCP< const Matrix > &sourceMatrix, const Export &exporter, const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor to create a Matrix using a fusedExport-style construction. The originalMatrix must be a X...
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this vector.
Concrete implementation of Xpetra::Matrix.
#define XPETRA_MONITOR(funcName)
static RCP< Matrix > Build(const RCP< const Matrix > &sourceMatrix, const Export &RowExporter, const Export &DomainExporter, const RCP< const Map > &domainMap=Teuchos::null, const RCP< const Map > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor to create a Matrix using a fusedExport-style construction. The originalMatrix must be a X...
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, execution_space, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
Xpetra-specific matrix class.
static RCP< Matrix > Build(const Teuchos::RCP< const Map > &rowMap, const Teuchos::RCP< const Map > &colMap, const typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
Constructor providing a local Kokkos::CrsMatrix together with a row and column map.
MatrixFactory()
Private constructor. This is a static class.
static RCP< Matrix > Build(const RCP< const Matrix > &sourceMatrix, const Import &RowImporter, const Import &DomainImporter, const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor to create a Matrix using a fusedImport-style construction. The originalMatrix must be a X...