43 #include "Ifpack_ConfigDefs.h"
44 #include "Ifpack_DropFilter.h"
45 #include "Epetra_ConfigDefs.h"
46 #include "Epetra_RowMatrix.h"
47 #include "Epetra_Comm.h"
48 #include "Epetra_Map.h"
49 #include "Epetra_MultiVector.h"
50 #include "Epetra_Vector.h"
65 if (A_->Comm().NumProc() != 1) {
66 cerr <<
"Ifpack_DropFilter can be used with Comm().NumProc() == 1" << endl;
67 cerr <<
"only. This class is a tool for Ifpack_AdditiveSchwarz," << endl;
68 cerr <<
"and it is not meant to be used otherwise." << endl;
72 if ((A_->NumMyRows() != A_->NumGlobalRows64()) ||
73 (A_->NumMyRows() != A_->NumMyCols()))
76 NumRows_ = A_->NumMyRows();
77 MaxNumEntriesA_ = A_->MaxNumEntries();
79 NumEntries_.resize(NumRows_);
80 Indices_.resize(MaxNumEntriesA_);
81 Values_.resize(MaxNumEntriesA_);
83 std::vector<int> Ind(MaxNumEntriesA_);
84 std::vector<double> Val(MaxNumEntriesA_);
86 for (
int i = 0 ; i < NumRows_ ; ++i) {
87 NumEntries_[i] = MaxNumEntriesA_;
89 IFPACK_CHK_ERRV(ExtractMyRowCopy(i,MaxNumEntriesA_,Nnz,
94 if (Nnz > MaxNumEntries_)
101 int Ifpack_DropFilter::
102 ExtractMyRowCopy(
int MyRow,
int Length,
int & NumEntries,
103 double *Values,
int * Indices)
const
105 if (Length < NumEntries_[MyRow])
110 IFPACK_CHK_ERR(A_->ExtractMyRowCopy(MyRow,MaxNumEntriesA_,Nnz,
111 &Values_[0],&Indices_[0]));
117 for (
int i = 0 ; i < Nnz ; ++i) {
122 if ((Indices_[i] == MyRow) || (IFPACK_ABS(Values_[i]) >= DropTol_)) {
125 Values[count] = Values_[i];
126 Indices[count] = Indices_[i];
136 int Ifpack_DropFilter::
139 IFPACK_CHK_ERR(A_->ExtractDiagonalCopy(Diagonal));
144 int Ifpack_DropFilter::
150 int NumVectors = X.NumVectors();
151 if (NumVectors != Y.NumVectors())
156 std::vector<int> Indices(MaxNumEntries_);
157 std::vector<double> Values(MaxNumEntries_);
159 for (
int i = 0 ; i < NumRows_ ; ++i) {
162 ExtractMyRowCopy(i,MaxNumEntries_,Nnz,
163 &Values[0], &Indices[0]);
166 for (
int j = 0 ; j < NumVectors ; ++j) {
167 for (
int k = 0 ; k < Nnz ; ++k) {
168 Y[j][i] += Values[k] * X[j][Indices[k]];
174 for (
int j = 0 ; j < NumVectors ; ++j) {
175 for (
int k = 0 ; k < Nnz ; ++k) {
176 Y[j][Indices[k]] += Values[k] * X[j][i];
186 int Ifpack_DropFilter::
187 Solve(
bool ,
bool ,
bool ,
194 int Ifpack_DropFilter::
197 int ierr = Multiply(UseTranspose(),X,Y);
202 int Ifpack_DropFilter::
Ifpack_DropFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix, double DropTol)
Constructor.