43 #include "Ifpack_ConfigDefs.h"
44 #include "Teuchos_ParameterList.hpp"
45 #include "Teuchos_RefCountPtr.hpp"
46 #include "Epetra_MultiVector.h"
47 #include "Ifpack_Graph.h"
48 #include "Epetra_RowMatrix.h"
49 #include "Ifpack_Graph_Epetra_RowMatrix.h"
50 #include "Ifpack_AMDReordering.h"
53 #include <amesos_amd.h>
67 NumMyRows_(RHS.NumMyRows()),
68 IsComputed_(RHS.IsComputed())
92 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
126 IFPACK_CHK_ERR(
Compute(Graph));
142 vector<int> ia(NumMyRows_+1,0);
143 vector<int> ja(NumNz);
145 for(
int i = 0; i < NumMyRows_; ++i )
147 int * tmpP = &ja[ia[i]];
149 ia[i+1] = ia[i] + cnt;
153 vector<int> iat(NumMyRows_+1);
154 vector<int> jat(NumNz);
156 for(
int i = 0; i < NumMyRows_; ++i )
159 for(
int j = ia[i]; j < ia[i+1]; ++j )
161 if( ja[j] < NumMyRows_ )
167 iat[NumMyRows_] = loc;
170 Reorder_.resize(NumMyRows_);
171 vector<double> info(AMD_INFO);
173 amesos_amd_order( NumMyRows_, &iat[0], &jat[0], &Reorder_[0], NULL, &info[0] );
175 if( info[AMD_STATUS] == AMD_INVALID )
176 cout <<
"AMD ORDERING: Invalid!!!!\n";
179 InvReorder_.resize(NumMyRows_);
181 for (
int i = 0 ; i < NumMyRows_ ; ++i)
184 for (
int i = 0 ; i < NumMyRows_ ; ++i)
185 InvReorder_[Reorder_[i]] = i;
187 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
188 if (InvReorder_[i] == -1)
202 if ((i < 0) || (i >= NumMyRows_))
215 if ((i < 0) || (i >= NumMyRows_))
219 return(InvReorder_[i]);
223 Epetra_MultiVector& X)
const
225 int NumVectors = X.NumVectors();
227 for (
int j = 0 ; j < NumVectors ; ++j) {
228 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
229 int np = Reorder_[i];
230 X[j][np] = Xorig[j][i];
239 Epetra_MultiVector& X)
const
241 int NumVectors = X.NumVectors();
243 for (
int j = 0 ; j < NumVectors ; ++j) {
244 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
245 int np = Reorder_[i];
246 X[j][i] = Xorig[j][np];
256 os <<
"*** Ifpack_AMDReordering" << endl << endl;
258 os <<
"*** Reordering not yet computed." << endl;
260 os <<
"*** Number of local rows = " << NumMyRows_ << endl;
262 os <<
"Local Row\tReorder[i]\tInvReorder[i]" << endl;
263 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
264 os <<
'\t' << i <<
"\t\t" << Reorder_[i] <<
"\t\t" << InvReorder_[i] << endl;
virtual int ExtractMyRowCopy(int MyRow, int LenOfIndices, int &NumIndices, int *Indices) const =0
Extracts a copy of input local row.
ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
int Pinv(const Epetra_MultiVector &Xorig, Epetra_MultiVector &Xinvreord) const
Applies inverse reordering to multivector X, whose local length equals the number of local rows...
virtual int NumMyRows() const =0
Returns the number of local rows.
Ifpack_AMDReordering()
Constructor for Ifpack_Graph's.
int SetParameters(Teuchos::ParameterList &List)
Sets all parameters.
Ifpack_AMDReordering: approximate minimum degree reordering.
Ifpack_AMDReordering & operator=(const Ifpack_AMDReordering &RHS)
Assignment operator.
int P(const Epetra_MultiVector &Xorig, Epetra_MultiVector &Xreord) const
Applies reordering to multivector X, whose local length equals the number of local rows...
bool IsComputed() const
Returns true is the reordering object has been successfully initialized, false otherwise.
int NumMyRows() const
Returns the number of local rows.
int Compute(const Ifpack_Graph &Graph)
Computes all it is necessary to initialize the reordering object.
virtual int NumMyNonzeros() const =0
Returns the number of local nonzero entries.
int Reorder(const int i) const
Returns the reordered index of row i.
int InvReorder(const int i) const
Returns the inverse reordered index of row i.
Ifpack_Graph_Epetra_RowMatrix: a class to define Ifpack_Graph as a light-weight conversion of Epetra_...
Ifpack_Graph: a pure virtual class that defines graphs for IFPACK.
int SetParameter(const string Name, const int Value)
Sets integer parameters `Name'.