43 #include <Epetra_Import.h>
44 #include <Epetra_CrsGraph.h>
45 #include <Epetra_Map.h>
51 #define MATTRANS_F77 F77_FUNC(mattrans,MATTRANS)
52 #define GENBTF_F77 F77_FUNC(genbtf,GENBTF)
54 extern void MATTRANS_F77(
int*,
int*,
int*,
int*,
int*,
int* );
55 extern void GENBTF_F77(
int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
56 int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
int*,
65 if( NewRowMap_ )
delete NewRowMap_;
66 if( NewDomainMap_ )
delete NewDomainMap_;
68 if( NewGraph_ )
delete NewGraph_;
77 if( orig.RowMap().DistributedGlobal() )
78 { cout <<
"FAIL for Global!\n"; abort(); }
79 if( orig.IndicesAreGlobal() )
80 { cout <<
"FAIL for Global Indices!\n"; abort(); }
82 int n = orig.NumMyRows();
83 int nnz = orig.NumMyNonzeros();
86 vector<int> ia(n+1,0);
89 for(
int i = 0; i < n; ++i )
91 int * tmpP = &ja[ia[i]];
92 orig.ExtractMyRowCopy( i, nnz-ia[i], cnt, tmpP );
93 ia[i+1] = ia[i] + cnt;
97 for(
int i = 0; i < n+1; ++i ) ++ia[i];
98 for(
int i = 0; i < nnz; ++i ) ++ja[i];
101 cout <<
"-----------------------------------------\n";
102 cout <<
"CRS Format Graph\n";
103 cout <<
"-----------------------------------------\n";
104 for(
int i = 0; i < n; ++i )
106 cout << i <<
": " << ia[i+1] <<
": ";
107 for(
int j = ia[i]-1; j<ia[i+1]-1; ++j )
108 cout <<
" " << ja[j];
111 cout <<
"-----------------------------------------\n";
114 vector<int> iat(n+1);
115 vector<int> jat(nnz);
118 int * jatf = &jat[0];
119 int * iatf = &iat[0];
123 cout <<
"-----------------------------------------\n";
124 cout <<
"CCS Format Graph\n";
125 cout <<
"-----------------------------------------\n";
126 for(
int i = 0; i < n; ++i )
128 cout << i <<
": " << iat[i+1] <<
": ";
129 for(
int j = iat[i]-1; j<iat[i+1]-1; ++j )
130 cout <<
" " << jat[j];
133 cout <<
"-----------------------------------------\n";
138 vector<int> rowperm(n);
139 vector<int> colperm(n);
142 int nhrows, nhcols, hrzcmp;
146 int nvrows, nvcols, vrtcmp;
148 vector<int> rcmstr(n+1);
149 vector<int> ccmstr(n+1);
154 GENBTF_F77( &n, &n, &iat[0], &jat[0], &ia[0], &ja[0], &w[0],
155 &rowperm[0], &colperm[0], &nhrows, &nhcols,
156 &hrzcmp, &nsrows, &sqcmpn, &nvrows, &nvcols, &vrtcmp,
157 &rcmstr[0], &ccmstr[0], &msglvl, &output );
160 for(
int i = 0; i < n; ++i )
165 for(
int i = 0; (i<n+1) && (rcmstr[i]!=n+1); ++i )
172 cout <<
"-----------------------------------------\n";
173 cout <<
"BTF Output\n";
174 cout <<
"-----------------------------------------\n";
175 cout <<
"RowPerm and ColPerm\n";
176 for(
int i = 0; i<n; ++i )
177 cout << rowperm[i] <<
"\t" << colperm[i] << endl;
180 cout <<
"Num Horizontal: Rows, Cols, Comps\n";
181 cout << nhrows <<
"\t" << nhcols <<
"\t" << hrzcmp << endl;
183 cout <<
"Num Square: Rows, Comps\n";
184 cout << nsrows <<
"\t" << sqcmpn << endl;
187 cout <<
"Num Vertical: Rows, Cols, Comps\n";
188 cout << nvrows <<
"\t" << nvcols <<
"\t" << vrtcmp << endl;
190 cout <<
"Row, Col of upper left pt in blocks\n";
191 for(
int i = 0; (i<n+1) && (rcmstr[i]!=n+1); ++i )
192 cout << i <<
" " << rcmstr[i] <<
" " << ccmstr[i] << endl;
193 cout <<
"-----------------------------------------\n";
196 if( hrzcmp || vrtcmp )
197 { cout <<
"FAILED! hrz cmp's:" << hrzcmp <<
" vrtcmp: " << vrtcmp << endl;
202 vector<int> rowperm_t( n );
203 vector<int> colperm_t( n );
204 for(
int i = 0; i < n; ++i )
208 rowperm_t[i] = rowperm[(n-1)-i];
209 colperm_t[i] = colperm[(n-1)-i];
214 const Epetra_BlockMap & OldMap = orig.RowMap();
215 vector<int> myElements( n );
216 OldMap.MyGlobalElements( &myElements[0] );
218 vector<int> newDomainElements( n );
219 vector<int> newRangeElements( n );
220 for(
int i = 0; i < n; ++i )
222 newDomainElements[ i ] = myElements[ rowperm_t[i] ];
223 newRangeElements[ i ] = myElements[ colperm_t[i] ];
224 cout << i <<
"\t" << rowperm_t[i] <<
"\t" << colperm[i] <<
"\t" << myElements[i] << endl;
227 NewRowMap_ =
new Epetra_Map( n, n, &newDomainElements[0], OldMap.IndexBase(), OldMap.Comm() );
228 NewDomainMap_ =
new Epetra_Map( n, n, &newRangeElements[0], OldMap.IndexBase(), OldMap.Comm() );
231 cout <<
"New Row Map\n";
232 cout << *RowMap << endl;
233 cout <<
"New Domain Map\n";
234 cout << *DomainMap << endl;
238 NewGraph_ =
new Epetra_CrsGraph( Copy, *NewRowMap_, 0 );
239 Epetra_Import Importer( *NewRowMap_, OldMap );
240 NewGraph_->Import( orig, Importer, Insert );
241 NewGraph_->FillComplete( *NewDomainMap_, *NewRowMap_ );
244 cout <<
"New CrsGraph\n";
245 cout << *NewGraph_ << endl;
NewTypeRef operator()(OriginalTypeRef orig)
Construction of BTF ordered Epetra_CrsGraph from orig object.
~CrsGraph_BTF()
Destructor.