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"
55 int AllowedBandwidth) :
59 AllowedBandwidth_(AllowedBandwidth),
60 AllowedEntries_(AllowedEntries),
68 if (
A_->Comm().NumProc() != 1) {
69 cerr <<
"Ifpack_SparsityFilter can be used with Comm().NumProc() == 1" << endl;
70 cerr <<
"only. This class is a tool for Ifpack_AdditiveSchwarz," << endl;
71 cerr <<
"and it is not meant to be used otherwise." << endl;
76 if ((
A_->NumMyRows() !=
A_->NumMyCols()) ||
77 (
A_->NumMyRows() !=
A_->NumGlobalRows64()))
99 for (
int i = 0 ; i <
A_->NumMyRows() ; ++i) {
115 double *Values,
int * Indices)
const
124 double Threshold = 0.0;
129 std::vector<double> Values2(Nnz);
131 for (
int i = 0 ; i < Nnz ; ++i) {
140 for (
int i = count ; i < Nnz ; ++i)
144 std::sort(Values2.rbegin(),Values2.rend());
155 for (
int i = 0 ; i < Nnz ; ++i) {
163 Values[NumEntries] =
Values_[i];
178 int ierr =
A_->ExtractDiagonalCopy(Diagonal);
189 if (NumVectors != Y.NumVectors())
197 for (
int i = 0 ; i <
A_->NumMyRows() ; ++i) {
201 &Values[0], &Indices[0]);
205 for (
int k = 0 ; k < Nnz ; ++k) {
206 Y[j][i] += Values[k] * X[j][Indices[k]];
213 for (
int k = 0 ; k < Nnz ; ++k) {
214 Y[j][Indices[k]] += Values[k] * X[j][i];
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
int AllowedEntries_
Maximum allowed entries per row.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
std::vector< int > Indices_
Used in ExtractMyRowCopy, to avoid allocation each time.
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
int MaxNumEntries_
Maximum entries in each row.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
std::vector< double > Values_
Used in ExtractMyRowCopy, to avoid allocation each time.
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
#define IFPACK_CHK_ERRV(ifpack_err)
Ifpack_SparsityFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix, int AllowedNumEntries, int AllowedBandwidth=-1)
#define IFPACK_RETURN(ifpack_err)
std::vector< int > NumEntries_
bool UseTranspose() const
int NumNonzeros_
Number of nonzeros for the dropped matrix.
Teuchos::RefCountPtr< Epetra_RowMatrix > A_
Pointer to the matrix to be preconditioned.
#define IFPACK_CHK_ERR(ifpack_err)
int AllowedBandwidth_
Maximum allowed bandwidth.
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const