Xpetra Version of the Day
Loading...
Searching...
No Matches
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
63namespace Xpetra {
64
65 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node = KokkosClassic::DefaultNode::DefaultNodeType>
67#undef XPETRA_MATRIXFACTORY2_SHORT
69
70 public:
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
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));
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
123 public:
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
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
221 template <class Scalar,
222 class LocalOrdinal,
223 class GlobalOrdinal,
224 class Node>
226#undef XPETRA_MATRIXFACTORY_SHORT
228
229 private:
232
233 public:
236 static RCP<Matrix> Build(const RCP<const Map>& rowMap) {
237 return rcp(new CrsMatrixWrap(rowMap));
238 }
239
241 static RCP<Matrix> Build(const RCP<const Map>& rowMap, size_t maxNumEntriesPerRow) {
242 return rcp(new CrsMatrixWrap(rowMap, maxNumEntriesPerRow));
243 }
244
246 static RCP<Matrix> Build(const RCP<const Map>& rowMap, const RCP<const Map>& colMap, size_t maxNumEntriesPerRow) {
247 return rcp(new CrsMatrixWrap(rowMap, colMap, maxNumEntriesPerRow));
248 }
249
251 static RCP<Matrix> Build(const RCP<const Map>& rowMap, const RCP<const Map>& colMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc) {
252 return rcp(new CrsMatrixWrap(rowMap, colMap, NumEntriesPerRowToAlloc));
253 }
254
257 const Teuchos::RCP<const Map>& rowMap,
258 const Teuchos::RCP<const Map>& colMap,
260 const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
261 XPETRA_MONITOR("MatrixFactory::Build");
262 return rcp(new CrsMatrixWrap(rowMap, colMap, lclMatrix, params));
263 }
267 const Teuchos::RCP<const Map>& rowMap,
268 const Teuchos::RCP<const Map>& colMap,
269 const Teuchos::RCP<const Map>& domainMap = Teuchos::null,
270 const Teuchos::RCP<const Map>& rangeMap = Teuchos::null,
271 const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
272 XPETRA_MONITOR("MatrixFactory::Build");
273 return rcp(new CrsMatrixWrap(lclMatrix, rowMap, colMap, domainMap, rangeMap, params));
274 }
275
277 static RCP<Matrix> Build(const RCP<const Map> &rowMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc) {
278 return rcp( new CrsMatrixWrap(rowMap, NumEntriesPerRowToAlloc) );
279 }
280
282 static RCP<Matrix> Build(const RCP<const CrsGraph>& graph, const RCP<ParameterList>& paramList = Teuchos::null) {
283 return rcp(new CrsMatrixWrap(graph, paramList));
284 }
285
287 static RCP<Matrix> Build(const RCP<const Vector>& diagonal) {
288
289 RCP<const BlockedVector> bdiagonal = Teuchos::rcp_dynamic_cast<const BlockedVector>(diagonal);
290 Teuchos::RCP<Matrix> mtx = Teuchos::null;
291
292 if(bdiagonal == Teuchos::null)
293 {
294 Teuchos::ArrayRCP<const Scalar> vals = diagonal->getData(0);
295 LocalOrdinal numMyElements = diagonal->getMap()->getLocalNumElements();
296 Teuchos::ArrayView<const GlobalOrdinal> myGlobalElements = diagonal->getMap()->getLocalElementList();
297
298 mtx = Teuchos::rcp(new CrsMatrixWrap(diagonal->getMap(), 1));
299
300 for (LocalOrdinal i = 0; i < numMyElements; ++i) {
301 mtx->insertGlobalValues(myGlobalElements[i],
302 Teuchos::tuple<GlobalOrdinal>(myGlobalElements[i]),
303 Teuchos::tuple<Scalar>(vals[i]));
304 }
305 mtx->fillComplete();
306 }
307 else
308 {
309 RCP<BlockedCrsMatrix> bop = Teuchos::rcp(new BlockedCrsMatrix(bdiagonal->getBlockedMap(), bdiagonal->getBlockedMap(), 1));
310
311 for (size_t r = 0; r < bdiagonal->getBlockedMap()->getNumMaps(); ++r) {
312 if (!bdiagonal->getMultiVector(r).is_null()) {
313 const RCP<MultiVector> subvec = bdiagonal->getMultiVector(r);
314 bop->setMatrix(r, r, Build(subvec->getVector(0)));
315 }
316 }
317 bop->fillComplete();
318 mtx = BuildCopy(bop);
319 }
320
321 return mtx;
322 }
323
325 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) {
326 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
327 if (crsOp == Teuchos::null)
328 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
329
330 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
331 RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, importer, domainMap, rangeMap, params);
332 if (newCrs->hasMatrix())
333 return rcp(new CrsMatrixWrap(newCrs));
334 else
335 return Teuchos::null;
336 }
337
339 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) {
340 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
341 if (crsOp == Teuchos::null)
342 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
343
344 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
345 return rcp(new CrsMatrixWrap(CrsMatrixFactory::Build(originalCrs, exporter, domainMap, rangeMap, params)));
346 }
347
349 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) {
350 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
351 if (crsOp == Teuchos::null)
352 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
353
354 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
355 RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, RowImporter, Teuchos::rcpFromRef(DomainImporter), domainMap, rangeMap, params);
356 if (newCrs->hasMatrix())
357 return rcp(new CrsMatrixWrap(newCrs));
358 else
359 return Teuchos::null;
360 }
361
363 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) {
364 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
365 if (crsOp == Teuchos::null)
366 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
367
368 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
369 RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, RowExporter, Teuchos::rcpFromRef(DomainExporter), domainMap, rangeMap, params);
370 if (newCrs->hasMatrix())
371 return rcp(new CrsMatrixWrap(newCrs));
372 else
373 return Teuchos::null;
374 }
375
376
380 RCP<const BlockedCrsMatrix> input = Teuchos::rcp_dynamic_cast<const BlockedCrsMatrix>(A);
381 if(input == Teuchos::null)
383
384 // deep copy of MapExtractors (and underlying maps)
385 RCP<const MapExtractor> rgMapExt = Teuchos::rcp(new MapExtractor(*(input->getRangeMapExtractor())));
386 RCP<const MapExtractor> doMapExt = Teuchos::rcp(new MapExtractor(*(input->getDomainMapExtractor())));
387
388 // create new BlockedCrsMatrix object
389 RCP<BlockedCrsMatrix> bop = Teuchos::rcp(new BlockedCrsMatrix(rgMapExt, doMapExt, input->getLocalMaxNumRowEntries()));
390
391 for (size_t r = 0; r < input->Rows(); ++r) {
392 for (size_t c = 0; c < input->Cols(); ++c)
393 if(input->getMatrix(r,c) != Teuchos::null) {
394 // make a deep copy of the matrix
395 // This is a recursive call to this function
396 RCP<Matrix> mat =
398 bop->setMatrix(r,c,mat);
399 }
400 }
401
402 if(input->isFillComplete())
403 bop->fillComplete();
404 return bop;
405 }
406 };
407#define XPETRA_MATRIXFACTORY_SHORT
408
409}
410
411#define XPETRA_MATRIXFACTORY_SHORT
412#define XPETRA_MATRIXFACTORY2_SHORT
413#endif
#define XPETRA_MONITOR(funcName)
bool is_null() const
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't insert entries directly...
Concrete implementation of Xpetra::Matrix.
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...
Exception indicating invalid cast attempted.
Exception throws to report errors in the internal logical of the program.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
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 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...
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 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 CrsGraph > &graph, const RCP< ParameterList > &paramList=Teuchos::null)
Constructor specifying graph.
static RCP< Matrix > Build(const RCP< const Map > &rowMap)
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 Map > &rowMap, size_t maxNumEntriesPerRow)
Constructor specifying the number of non-zeros for all rows.
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.
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.
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...
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< 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...
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 Vector > &diagonal)
Constructor for creating a diagonal Xpetra::Matrix using the entries of a given vector for the diagon...
Xpetra-specific matrix class.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TypeTo as(const TypeFrom &t)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Xpetra namespace