Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef XPETRA_MATRIXFACTORY_CPP
00048 #define XPETRA_MATRIXFACTORY_CPP
00049
00050 #include "Xpetra_MatrixFactory.hpp"
00051
00052 namespace Xpetra {
00053
00054 Teuchos::RCP<Xpetra::Matrix<double,int,int> > MatrixFactory2<double,int,int>::BuildCopy(const Teuchos::RCP<const Matrix> A) {
00055 RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
00056 if (oldOp == Teuchos::null)
00057 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
00058
00059 RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
00060
00061 #ifdef HAVE_XPETRA_EPETRA
00062 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
00063 RCP<const EpetraCrsMatrixT<GlobalOrdinal> > oldECrsOp = Teuchos::rcp_dynamic_cast<const EpetraCrsMatrixT<GlobalOrdinal> >(oldCrsOp);
00064 if (oldECrsOp != Teuchos::null) {
00065
00066 RCP<CrsMatrix> newECrsOp(new EpetraCrsMatrixT<GlobalOrdinal>(*oldECrsOp));
00067 RCP<CrsMatrixWrap> newOp (new CrsMatrixWrap (newECrsOp));
00068
00069 return newOp;
00070 }
00071 #endif
00072 #endif
00073
00074 #ifdef HAVE_XPETRA_TPETRA
00075
00076 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
00077 if (oldTCrsOp != Teuchos::null) {
00078 RCP<CrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
00079 RCP<CrsMatrixWrap> newOp (new CrsMatrixWrap(newTCrsOp));
00080
00081 return newOp;
00082 }
00083 #else
00084 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
00085 #endif
00086
00087 return Teuchos::null;
00088 }
00089
00090 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
00091 Teuchos::RCP<Xpetra::Matrix<double,int,long long> > MatrixFactory2<double,int,long long>::BuildCopy(const Teuchos::RCP<const Matrix> A) {
00092 RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<const CrsMatrixWrap>(A);
00093 if (oldOp == Teuchos::null)
00094 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
00095
00096 RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
00097
00098 #ifdef HAVE_XPETRA_EPETRA
00099 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
00100 RCP<const EpetraCrsMatrixT<GlobalOrdinal> > oldECrsOp = Teuchos::rcp_dynamic_cast<const EpetraCrsMatrixT<GlobalOrdinal> >(oldCrsOp);
00101 if (oldECrsOp != Teuchos::null) {
00102
00103 RCP<CrsMatrix> newECrsOp(new EpetraCrsMatrixT<GlobalOrdinal>(*oldECrsOp));
00104 RCP<CrsMatrixWrap> newOp (new CrsMatrixWrap (newECrsOp));
00105
00106 return newOp;
00107 }
00108 #endif
00109 #endif
00110
00111 #ifdef HAVE_XPETRA_TPETRA
00112
00113 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<const TpetraCrsMatrix>(oldCrsOp);
00114 if (oldTCrsOp != Teuchos::null) {
00115 RCP<CrsMatrix> newTCrsOp(new TpetraCrsMatrix(*oldTCrsOp));
00116 RCP<CrsMatrixWrap> newOp (new CrsMatrixWrap(newTCrsOp));
00117
00118 return newOp;
00119 }
00120 #else
00121 throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
00122 #endif
00123
00124 return Teuchos::null;
00125 }
00126
00127 #endif // HAVE_TEUCHOS_LONG_LONG_INT
00128
00129 }
00130
00131 #endif