49 #ifndef XPETRA_MATRIXFACTORY_HPP 50 #define XPETRA_MATRIXFACTORY_HPP 69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 class MatrixFactory2 {
71 #undef XPETRA_MATRIXFACTORY2_SHORT 77 if (oldOp == Teuchos::null)
85 "Not Epetra or Tpetra matrix");
87 #ifdef HAVE_XPETRA_EPETRA 94 #ifdef HAVE_XPETRA_TPETRA 99 if (oldTCrsOp != Teuchos::null) {
110 return Teuchos::null;
113 #define XPETRA_MATRIXFACTORY2_SHORT 123 #undef XPETRA_MATRIXFACTORY2_SHORT 128 if (oldOp == Teuchos::null)
133 #ifdef HAVE_XPETRA_EPETRA 134 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES 136 if (oldECrsOp != Teuchos::null) {
146 #ifdef HAVE_XPETRA_TPETRA 149 if (oldTCrsOp != Teuchos::null) {
156 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
159 return Teuchos::null;
163 #define XPETRA_MATRIXFACTORY2_SHORT 165 #ifdef HAVE_XPETRA_INT_LONG_LONG 174 #undef XPETRA_MATRIXFACTORY2_SHORT 179 if (oldOp == Teuchos::null)
184 #ifdef HAVE_XPETRA_EPETRA 185 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES 187 if (oldECrsOp != Teuchos::null) {
197 #ifdef HAVE_XPETRA_TPETRA 200 if (oldTCrsOp != Teuchos::null) {
207 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
210 return Teuchos::null;
213 #endif // HAVE_XPETRA_INT_LONG_LONG 215 #define XPETRA_MATRIXFACTORY2_SHORT 218 template <class Scalar = Matrix<>::scalar_type,
225 #undef XPETRA_MATRIXFACTORY_SHORT 246 return rcp(
new CrsMatrixWrap(rowMap, colMap, NumEntriesPerRowToAlloc, pftype));
249 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 274 LocalOrdinal NumMyElements = diagonal->getMap()->getNodeNumElements();
279 for (LocalOrdinal i = 0; i < NumMyElements; ++i) {
280 mtx->insertGlobalValues(MyGlobalElements[i],
281 Teuchos::tuple<GlobalOrdinal>(MyGlobalElements[i]),
282 Teuchos::tuple<Scalar>(vals[i]) );
291 if (crsOp == Teuchos::null)
296 if (newCrs->hasMatrix())
299 return Teuchos::null;
305 if (crsOp == Teuchos::null)
315 if (crsOp == Teuchos::null)
320 if (newCrs->hasMatrix())
323 return Teuchos::null;
329 if (crsOp == Teuchos::null)
334 if (newCrs->hasMatrix())
337 return Teuchos::null;
345 if(input == Teuchos::null)
355 for (
size_t r = 0; r < input->Rows(); ++r) {
356 for (
size_t c = 0; c < input->Cols(); ++c)
357 if(input->getMatrix(r,c) != Teuchos::null) {
362 bop->setMatrix(r,c,mat);
366 if(input->isFillComplete())
371 #define XPETRA_MATRIXFACTORY_SHORT 375 #define XPETRA_MATRIXFACTORY_SHORT 376 #define XPETRA_MATRIXFACTORY2_SHORT
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 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 CrsGraph > &graph, const RCP< ParameterList > ¶mList=Teuchos::null)
Constructor specifying graph.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > 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.
LocalOrdinal local_ordinal_type
Exception throws to report errors in the internal logical of the program.
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...
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.
Exception indicating invalid cast attempted.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A)
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.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A)
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A)
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 > ¶ms)
Constructor to create a Matrix using a fusedExport-style construction. The originalMatrix must be a X...
TypeTo as(const TypeFrom &t)
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 > ¶ms=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 Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying the number of non-zeros for all rows.
Xpetra-specific matrix class.
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 > ¶ms)
Constructor to create a Matrix using a fusedImport-style construction. The originalMatrix must be a X...
GlobalOrdinal global_ordinal_type