49 #ifndef XPETRA_MATRIXFACTORY_HPP
50 #define XPETRA_MATRIXFACTORY_HPP
61 template <class Scalar, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType, class LocalMatOps = typename Kokkos::DefaultKernels<Scalar,LocalOrdinal,Node>::SparseOps>
63 #undef XPETRA_MATRIXFACTORY_SHORT
94 return rcp(
new CrsMatrixWrap(rowMap, colMap, NumEntriesPerRowToAlloc, pftype));
106 LocalOrdinal NumMyElements = diagonal->getMap()->getNodeNumElements();
108 for (LocalOrdinal i = 0; i < NumMyElements; ++i) {
109 mtx->insertGlobalValues(MyGlobalElements[i],
110 Teuchos::tuple<GlobalOrdinal>(MyGlobalElements[i]),
111 Teuchos::tuple<Scalar>(vals[i]) );
122 if (crsOp == Teuchos::null)
126 if(newCrs->hasMatrix())
129 return Teuchos::null;
136 if (crsOp == Teuchos::null)
143 #ifdef HAVE_XPETRA_EXPERIMENTAL
146 if (oldOp == Teuchos::null)
151 #ifdef HAVE_XPETRA_EPETRA
153 if (oldECrsOp != Teuchos::null) {
163 #ifdef HAVE_XPETRA_TPETRA
165 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<
const TpetraCrsMatrix>(oldCrsOp);
166 RCP<TpetraCrsMatrix> newTCrsOp(
new TpetraCrsMatrix(*oldTCrsOp));
167 RCP<CrsMatrixWrap> newOp(
new CrsMatrixWrap(newTCrsOp));
171 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
172 return Teuchos::null;
175 #endif // ifdef HAVE_XPETRA_EXPERIMENTAL
181 #define XPETRA_MATRIXFACTORY_SHORT
static RCP< Matrix > Build(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying the max number of non-zeros per row and providing column map.
Exception indicating invalid cast attempted.
static RCP< Matrix > Build(const RCP< const Matrix > &sourceMatrix, const Export &exporter, const RCP< const Map > &domainMap=Teuchos::null, const RCP< const Map > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor to create a Matrix using a fusedExport-style construction. The originalMatrix must be a X...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< Matrix > Build(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying the number of non-zeros for all rows.
MatrixFactory()
Private constructor. This is a static class.
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 > ¶ms=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 Vector > &diagonal)
Constructor for creating a diagonal Xpetra::Matrix using the entries of a given vector for the diagon...
static RCP< Matrix > Build(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying the (possibly different) number of entries per row and providing column map...
Concrete implementation of Xpetra::Matrix.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
static RCP< Matrix > Build(const RCP< const Map > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying (possibly different) number of entries in each row.