43 #include <Epetra_Import.h>
44 #include <Epetra_CrsGraph.h>
45 #include <Epetra_Map.h>
53 #define MATTRANS_F77 F77_FUNC(mattrans,MATTRANS)
54 #define GENBTF_F77 F77_FUNC(genbtf,GENBTF)
56 extern void MATTRANS_F77(
int*,
int*,
int*,
int*,
int*,
int* );
57 extern void GENBTF_F77(
int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
58 int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
67 if( NewRowMap_ )
delete NewRowMap_;
68 if( NewDomainMap_ )
delete NewDomainMap_;
70 if( NewGraph_ )
delete NewGraph_;
79 if( orig.RowMap().DistributedGlobal() )
80 { cout <<
"FAIL for Global!\n"; abort(); }
81 if( orig.IndicesAreGlobal() )
82 { cout <<
"FAIL for Global Indices!\n"; abort(); }
84 int n = orig.NumMyRows();
85 int nnz = orig.NumMyNonzeros();
88 vector<int> ia(n+1,0);
91 for(
int i = 0; i < n; ++i )
93 int * tmpP = &ja[ia[i]];
94 orig.ExtractMyRowCopy( i, nnz-ia[i], cnt, tmpP );
95 ia[i+1] = ia[i] + cnt;
99 for(
int i = 0; i < n+1; ++i ) ++ia[i];
100 for(
int i = 0; i < nnz; ++i ) ++ja[i];
103 cout <<
"-----------------------------------------\n";
104 cout <<
"CRS Format Graph\n";
105 cout <<
"-----------------------------------------\n";
106 for(
int i = 0; i < n; ++i )
108 cout << i <<
": " << ia[i+1] <<
": ";
109 for(
int j = ia[i]-1; j<ia[i+1]-1; ++j )
110 cout <<
" " << ja[j];
113 cout <<
"-----------------------------------------\n";
116 vector<int> iat(n+1);
117 vector<int> jat(nnz);
120 int * jatf = &jat[0];
121 int * iatf = &iat[0];
125 cout <<
"-----------------------------------------\n";
126 cout <<
"CCS Format Graph\n";
127 cout <<
"-----------------------------------------\n";
128 for(
int i = 0; i < n; ++i )
130 cout << i <<
": " << iat[i+1] <<
": ";
131 for(
int j = iat[i]-1; j<iat[i+1]-1; ++j )
132 cout <<
" " << jat[j];
135 cout <<
"-----------------------------------------\n";
140 vector<int> rowperm(n);
141 vector<int> colperm(n);
144 int nhrows, nhcols, hrzcmp;
148 int nvrows, nvcols, vrtcmp;
150 vector<int> rcmstr(n+1);
151 vector<int> ccmstr(n+1);
156 GENBTF_F77( &n, &n, &iat[0], &jat[0], &ia[0], &ja[0], &w[0],
157 &rowperm[0], &colperm[0], &nhrows, &nhcols,
158 &hrzcmp, &nsrows, &sqcmpn, &nvrows, &nvcols, &vrtcmp,
159 &rcmstr[0], &ccmstr[0], &msglvl, &output );
162 for(
int i = 0; i < n; ++i )
167 for(
int i = 0; (i<n+1) && (rcmstr[i]!=n+1); ++i )
174 cout <<
"-----------------------------------------\n";
175 cout <<
"BTF Output\n";
176 cout <<
"-----------------------------------------\n";
177 cout <<
"RowPerm and ColPerm\n";
178 for(
int i = 0; i<n; ++i )
179 cout << rowperm[i] <<
"\t" << colperm[i] << endl;
182 cout <<
"Num Horizontal: Rows, Cols, Comps\n";
183 cout << nhrows <<
"\t" << nhcols <<
"\t" << hrzcmp << endl;
185 cout <<
"Num Square: Rows, Comps\n";
186 cout << nsrows <<
"\t" << sqcmpn << endl;
189 cout <<
"Num Vertical: Rows, Cols, Comps\n";
190 cout << nvrows <<
"\t" << nvcols <<
"\t" << vrtcmp << endl;
192 cout <<
"Row, Col of upper left pt in blocks\n";
193 for(
int i = 0; (i<n+1) && (rcmstr[i]!=n+1); ++i )
194 cout << i <<
" " << rcmstr[i] <<
" " << ccmstr[i] << endl;
195 cout <<
"-----------------------------------------\n";
198 if( hrzcmp || vrtcmp )
199 { cout <<
"FAILED! hrz cmp's:" << hrzcmp <<
" vrtcmp: " << vrtcmp << endl;
204 vector<int> rowperm_t( n );
205 vector<int> colperm_t( n );
206 for(
int i = 0; i < n; ++i )
210 rowperm_t[i] = rowperm[(n-1)-i];
211 colperm_t[i] = colperm[(n-1)-i];
217 vector<int> myElements( n );
220 vector<int> newDomainElements( n );
221 vector<int> newRangeElements( n );
222 for(
int i = 0; i < n; ++i )
224 newDomainElements[ i ] = myElements[ rowperm_t[i] ];
225 newRangeElements[ i ] = myElements[ colperm_t[i] ];
226 cout << i <<
"\t" << rowperm_t[i] <<
"\t" << colperm[i] <<
"\t" << myElements[i] << endl;
233 cout <<
"New Row Map\n";
234 cout << *RowMap << endl;
235 cout <<
"New Domain Map\n";
236 cout << *DomainMap << endl;
246 cout <<
"New CrsGraph\n";
247 cout << *NewGraph_ << endl;
int MyGlobalElements(int *MyGlobalElementList) const
NewTypeRef operator()(OriginalTypeRef orig)
Construction of BTF ordered Epetra_CrsGraph from orig object.
const Epetra_Comm & Comm() const
~CrsGraph_BTF()
Destructor.
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)