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 = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
66 class MatrixFactory2 {
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);
95 if (oldTCrsOp != Teuchos::null) {
96 RCP<TpetraCrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
98 if (setFixedBlockSize)
99 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
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;
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:
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();
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
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
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));
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
255 //! Constructor providing a local Kokkos::CrsMatrix together with a row and column map
261 XPETRA_MONITOR("MatrixFactory::Build");
262 return rcp(new CrsMatrixWrap(rowMap, colMap, lclMatrix, params));
263 }
264
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
289 const RCP<ParameterList>& paramList = Teuchos::null) {
290 return rcp(new CrsMatrixWrap(graph, values, paramList));
291 }
292
294 static RCP<Matrix> Build(const RCP<const Vector>& diagonal) {
295
296 RCP<const BlockedVector> bdiagonal = Teuchos::rcp_dynamic_cast<const BlockedVector>(diagonal);
297 Teuchos::RCP<Matrix> mtx = Teuchos::null;
298
299 if(bdiagonal == Teuchos::null)
300 {
301 Teuchos::ArrayRCP<const Scalar> vals = diagonal->getData(0);
302 LocalOrdinal numMyElements = diagonal->getMap()->getLocalNumElements();
303 Teuchos::ArrayView<const GlobalOrdinal> myGlobalElements = diagonal->getMap()->getLocalElementList();
304
305 mtx = Teuchos::rcp(new CrsMatrixWrap(diagonal->getMap(), 1));
306
307 for (LocalOrdinal i = 0; i < numMyElements; ++i) {
308 mtx->insertGlobalValues(myGlobalElements[i],
309 Teuchos::tuple<GlobalOrdinal>(myGlobalElements[i]),
310 Teuchos::tuple<Scalar>(vals[i]));
311 }
312 mtx->fillComplete();
313 }
314 else
315 {
316 RCP<BlockedCrsMatrix> bop = Teuchos::rcp(new BlockedCrsMatrix(bdiagonal->getBlockedMap(), bdiagonal->getBlockedMap(), 1));
317
318 for (size_t r = 0; r < bdiagonal->getBlockedMap()->getNumMaps(); ++r) {
319 if (!bdiagonal->getMultiVector(r).is_null()) {
320 const RCP<MultiVector> subvec = bdiagonal->getMultiVector(r);
321 bop->setMatrix(r, r, Build(subvec->getVector(0)));
322 }
323 }
324 bop->fillComplete();
325 mtx = BuildCopy(bop);
326 }
327
328 return mtx;
329 }
330
332 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) {
333 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
334 if (crsOp == Teuchos::null)
335 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
336
337 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
338 RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, importer, domainMap, rangeMap, params);
339 if (newCrs->hasMatrix())
340 return rcp(new CrsMatrixWrap(newCrs));
341 else
342 return Teuchos::null;
343 }
344
346 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) {
347 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
348 if (crsOp == Teuchos::null)
349 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
350
351 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
352 return rcp(new CrsMatrixWrap(CrsMatrixFactory::Build(originalCrs, exporter, domainMap, rangeMap, params)));
353 }
354
356 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) {
357 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
358 if (crsOp == Teuchos::null)
359 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
360
361 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
362 RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, RowImporter, Teuchos::rcpFromRef(DomainImporter), domainMap, rangeMap, params);
363 if (newCrs->hasMatrix())
364 return rcp(new CrsMatrixWrap(newCrs));
365 else
366 return Teuchos::null;
367 }
368
370 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) {
371 RCP<const CrsMatrixWrap> crsOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(sourceMatrix);
372 if (crsOp == Teuchos::null)
373 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
374
375 RCP<CrsMatrix> originalCrs = crsOp->getCrsMatrix();
376 RCP<CrsMatrix> newCrs = CrsMatrixFactory::Build(originalCrs, RowExporter, Teuchos::rcpFromRef(DomainExporter), domainMap, rangeMap, params);
377 if (newCrs->hasMatrix())
378 return rcp(new CrsMatrixWrap(newCrs));
379 else
380 return Teuchos::null;
381 }
382
383
387 RCP<const BlockedCrsMatrix> input = Teuchos::rcp_dynamic_cast<const BlockedCrsMatrix>(A);
388 if(input == Teuchos::null)
389 return Xpetra::MatrixFactory2<Scalar,LocalOrdinal,GlobalOrdinal,Node>::BuildCopy(A,setFixedBlockSize);
390
391 // deep copy of MapExtractors (and underlying maps)
392 RCP<const MapExtractor> rgMapExt = Teuchos::rcp(new MapExtractor(*(input->getRangeMapExtractor())));
393 RCP<const MapExtractor> doMapExt = Teuchos::rcp(new MapExtractor(*(input->getDomainMapExtractor())));
394
395 // create new BlockedCrsMatrix object
396 RCP<BlockedCrsMatrix> bop = Teuchos::rcp(new BlockedCrsMatrix(rgMapExt, doMapExt, input->getLocalMaxNumRowEntries()));
397
398 for (size_t r = 0; r < input->Rows(); ++r) {
399 for (size_t c = 0; c < input->Cols(); ++c)
400 if(input->getMatrix(r,c) != Teuchos::null) {
401 // make a deep copy of the matrix
402 // This is a recursive call to this function
403 RCP<Matrix> mat =
405 bop->setMatrix(r,c,mat);
406 }
407 }
408
409 if(input->isFillComplete())
410 bop->fillComplete();
411 return bop;
412 }
413 };
414#define XPETRA_MATRIXFACTORY_SHORT
415
416}
417
418#define XPETRA_MATRIXFACTORY_SHORT
419#define XPETRA_MATRIXFACTORY2_SHORT
420#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 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 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
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)