44 #ifndef TPETRA_EPETRAROWMATRIX_HPP 45 #define TPETRA_EPETRAROWMATRIX_HPP 47 #include <Tpetra_ConfigDefs.hpp> 49 #if defined(HAVE_TPETRA_EPETRA) 51 #include <Epetra_Comm.h> 52 #include <Epetra_BasicRowMatrix.h> 53 #include <Tpetra_CrsMatrix.hpp> 59 template<
class TpetraMatrixType>
60 class EpetraRowMatrix :
public Epetra_BasicRowMatrix {
62 EpetraRowMatrix(
const Teuchos::RCP<TpetraMatrixType> &mat,
const Epetra_Comm &comm);
63 virtual ~EpetraRowMatrix();
65 int ExtractMyRowCopy(
int MyRow,
int Length,
int & NumEntries,
double *Values,
int * Indices)
const;
68 int ExtractMyEntryView(
int CurEntry,
double * & Value,
int & RowIndex,
int & ColIndex);
71 int ExtractMyEntryView(
int CurEntry,
double const * & Value,
int & RowIndex,
int & ColIndex)
const;
73 int NumMyRowEntries(
int MyRow,
int & NumEntries)
const;
76 Teuchos::RCP<TpetraMatrixType> tpetra_matrix_;
79 template<
class TpetraMatrixType>
80 EpetraRowMatrix<TpetraMatrixType>::EpetraRowMatrix(
81 const Teuchos::RCP<TpetraMatrixType> &mat,
const Epetra_Comm &comm
83 : Epetra_BasicRowMatrix(comm),
86 typedef typename TpetraMatrixType::global_ordinal_type GO;
87 GO globalNumRows = tpetra_matrix_->getRowMap()->getGlobalNumElements();
88 GO globalNumCols = tpetra_matrix_->getColMap()->getGlobalNumElements();
89 Teuchos::ArrayView<const GO> row_elem_list = tpetra_matrix_->getRowMap()->getNodeElementList();
90 Teuchos::ArrayView<const GO> col_elem_list = tpetra_matrix_->getColMap()->getNodeElementList();
91 Epetra_Map rowmap(globalNumRows, row_elem_list.size(), row_elem_list.getRawPtr(), 0, comm);
92 Epetra_Map colmap(globalNumCols, col_elem_list.size(), col_elem_list.getRawPtr(), 0, comm);
93 SetMaps(rowmap, colmap);
96 template<
class TpetraMatrixType>
97 EpetraRowMatrix<TpetraMatrixType>::~EpetraRowMatrix()
101 template<
class TpetraMatrixType>
102 int EpetraRowMatrix<TpetraMatrixType>::ExtractMyRowCopy(
int MyRow,
int Length,
int & NumEntries,
double *Values,
int * Indices)
const 104 Teuchos::ArrayView<int> inds(Indices, Length);
105 Teuchos::ArrayView<double> vals(Values, Length);
106 size_t num_entries = NumEntries;
107 tpetra_matrix_->getLocalRowCopy(MyRow, inds, vals, num_entries);
108 NumEntries = num_entries;
112 template<
class TpetraMatrixType>
113 int EpetraRowMatrix<TpetraMatrixType>::ExtractMyEntryView(
int CurEntry,
double * & Value,
int & RowIndex,
int & ColIndex)
119 template<
class TpetraMatrixType>
120 int EpetraRowMatrix<TpetraMatrixType>::ExtractMyEntryView(
int CurEntry,
double const * & Value,
int & RowIndex,
int & ColIndex)
const 126 template<
class TpetraMatrixType>
127 int EpetraRowMatrix<TpetraMatrixType>::NumMyRowEntries(
int MyRow,
int & NumEntries)
const 129 NumEntries = tpetra_matrix_->getNumEntriesInLocalRow(MyRow);
135 #endif // defined(HAVE_TPETRA_EPETRA) Namespace Tpetra contains the class and methods constituting the Tpetra library.