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" 62 if (A_->Comm().NumProc() != 1) {
63 cerr <<
"Ifpack_DropFilter can be used with Comm().NumProc() == 1" << endl;
64 cerr <<
"only. This class is a tool for Ifpack_AdditiveSchwarz," << endl;
65 cerr <<
"and it is not meant to be used otherwise." << endl;
69 if ((A_->NumMyRows() != A_->NumGlobalRows()) ||
70 (A_->NumMyRows() != A_->NumMyCols()))
73 NumRows_ = A_->NumMyRows();
74 MaxNumEntriesA_ = A_->MaxNumEntries();
76 NumEntries_.resize(NumRows_);
77 Indices_.resize(MaxNumEntriesA_);
78 Values_.resize(MaxNumEntriesA_);
80 vector<int> Ind(MaxNumEntriesA_);
81 vector<double> Val(MaxNumEntriesA_);
83 for (
int i = 0 ; i < NumRows_ ; ++i) {
84 NumEntries_[i] = MaxNumEntriesA_;
86 IFPACK_CHK_ERRV(ExtractMyRowCopy(i,MaxNumEntriesA_,Nnz,
91 if (Nnz > MaxNumEntries_)
98 int Ifpack_DropFilter::
99 ExtractMyRowCopy(
int MyRow,
int Length,
int & NumEntries,
100 double *Values,
int * Indices)
const 102 if (Length < NumEntries_[MyRow])
107 IFPACK_CHK_ERR(A_->ExtractMyRowCopy(MyRow,MaxNumEntriesA_,Nnz,
108 &Values_[0],&Indices_[0]));
114 for (
int i = 0 ; i < Nnz ; ++i) {
119 if ((Indices_[i] == MyRow) || (IFPACK_ABS(Values_[i]) >= DropTol_)) {
122 Values[count] = Values_[i];
123 Indices[count] = Indices_[i];
133 int Ifpack_DropFilter::
134 ExtractDiagonalCopy(Epetra_Vector & Diagonal)
const 136 IFPACK_CHK_ERR(A_->ExtractDiagonalCopy(Diagonal));
141 int Ifpack_DropFilter::
142 Multiply(
bool TransA,
const Epetra_MultiVector& X,
143 Epetra_MultiVector& Y)
const 147 int NumVectors = X.NumVectors();
148 if (NumVectors != Y.NumVectors())
153 vector<int> Indices(MaxNumEntries_);
154 vector<double> Values(MaxNumEntries_);
156 for (
int i = 0 ; i < NumRows_ ; ++i) {
159 ExtractMyRowCopy(i,MaxNumEntries_,Nnz,
160 &Values[0], &Indices[0]);
163 for (
int j = 0 ; j < NumVectors ; ++j) {
164 for (
int k = 0 ; k < Nnz ; ++k) {
165 Y[j][i] += Values[k] * X[j][Indices[k]];
171 for (
int j = 0 ; j < NumVectors ; ++j) {
172 for (
int k = 0 ; k < Nnz ; ++k) {
173 Y[j][Indices[k]] += Values[k] * X[j][i];
183 int Ifpack_DropFilter::
184 Solve(
bool Upper,
bool Trans,
bool UnitDiagonal,
185 const Epetra_MultiVector& X, Epetra_MultiVector& Y)
const 191 int Ifpack_DropFilter::
192 Apply(
const Epetra_MultiVector& X, Epetra_MultiVector& Y)
const 194 IFPACK_RETURN(Multiply(UseTranspose(),X,Y));
198 int Ifpack_DropFilter::
199 ApplyInverse(
const Epetra_MultiVector& X, Epetra_MultiVector& Y)
const 205 int Ifpack_DropFilter::InvRowSums(Epetra_Vector& x)
const 211 int Ifpack_DropFilter::InvColSums(Epetra_Vector& x)
const Ifpack_DropFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix, double DropTol)
Constructor.