112 OldGraph_ = &OldMatrix_->
Graph();
113 OldRHS_ = orig.GetRHS();
114 OldLHS_ = orig.GetLHS();
115 OldRowMap_ = &OldMatrix_->
RowMap();
119 if( !OldMatrix_ ) ierr = -2;
120 if( !OldRHS_ ) ierr = -3;
121 if( !OldLHS_ ) ierr = -4;
123 if( OldRowMap_->DistributedGlobal() ) ierr = -5;
124 if( degree_ != 1 ) ierr = -6;
126 int NRows = OldGraph_->NumMyRows();
127 int IndexBase = OldRowMap_->IndexBase();
129 vector<int> ColNZCnt( NRows );
130 vector<int> CS_RowIndices( NRows );
136 for(
int i = 0; i < NRows; ++i )
138 ierr = OldGraph_->ExtractMyRowView( i, NumIndices, Indices );
140 for(
int j = 0; j < NumIndices; ++j )
142 ++ColNZCnt[ Indices[j] ];
143 CS_RowIndices[ Indices[j] ] = i;
146 if( NumIndices == 1 ) RS_Map[i] = Indices[0];
151 cout <<
"-------------------------\n";
152 cout <<
"Row Singletons\n";
153 for( map<int,int>::iterator itM = RS_Map.begin(); itM != RS_Map.end(); ++itM )
154 cout << (*itM).first <<
"\t" << (*itM).second << endl;
155 cout <<
"Col Counts\n";
156 for(
int i = 0; i < NRows; ++i )
157 cout << i <<
"\t" << ColNZCnt[i] <<
"\t" << CS_RowIndices[i] << endl;
158 cout <<
"-------------------------\n";
164 for(
int i = 0; i < NRows; ++i )
165 if( ColNZCnt[i] == 1 )
167 int RowIndex = CS_RowIndices[i];
168 if( RS_Map.count(i) && RS_Map[i] == RowIndex )
171 RS_Set.insert( RowIndex );
177 cout <<
"-------------------------\n";
178 cout <<
"Singletons: " << CS_Set.size() << endl;
179 set<int>::iterator itRS = RS_Set.begin();
180 set<int>::iterator itCS = CS_Set.begin();
181 set<int>::iterator endRS = RS_Set.end();
182 set<int>::iterator endCS = CS_Set.end();
183 for( ; itRS != endRS; ++itRS, ++itCS )
184 cout << *itRS <<
"\t" << *itCS << endl;
185 cout <<
"-------------------------\n";
189 int NSingletons = CS_Set.size();
190 int NReducedRows = NRows - 2* NSingletons;
191 vector<int> ReducedIndices( NReducedRows );
192 vector<int> CSIndices( NSingletons );
193 vector<int> RSIndices( NSingletons );
197 for(
int i = 0; i < NRows; ++i )
199 int GlobalIndex = OldRowMap_->GID(i);
200 if ( RS_Set.count(i) ) RSIndices[RS_Loc++] = GlobalIndex;
201 else if( CS_Set.count(i) ) CSIndices[CS_Loc++] = GlobalIndex;
202 else ReducedIndices[Reduced_Loc++] = GlobalIndex;
205 vector<int> RowPermutedIndices( NRows );
206 copy( RSIndices.begin(), RSIndices.end(), RowPermutedIndices.begin() );
207 copy( ReducedIndices.begin(), ReducedIndices.end(), RowPermutedIndices.begin() + NSingletons );
208 copy( CSIndices.begin(), CSIndices.end(), RowPermutedIndices.begin() + NReducedRows + NSingletons );
210 vector<int> ColPermutedIndices( NRows );
211 copy( CSIndices.begin(), CSIndices.end(), ColPermutedIndices.begin() );
212 copy( ReducedIndices.begin(), ReducedIndices.end(), ColPermutedIndices.begin() + NSingletons );
213 copy( RSIndices.begin(), RSIndices.end(), ColPermutedIndices.begin() + NReducedRows + NSingletons );
215 UMap_ =
new Epetra_Map( NSingletons, NSingletons, &RSIndices[0], IndexBase, CommObj );
216 RMap_ =
new Epetra_Map( NReducedRows, NReducedRows, &ReducedIndices[0], IndexBase, CommObj );
217 LMap_ =
new Epetra_Map( NSingletons, NSingletons, &CSIndices[0], IndexBase, CommObj );
219 NewRowMap_ =
new Epetra_Map( NRows, NRows, &RowPermutedIndices[0], IndexBase, CommObj );
220 NewColMap_ =
new Epetra_Map( NRows, NRows, &ColPermutedIndices[0], IndexBase, CommObj );
234 cout <<
"Permuted Graph:\n" << *NewGraph_;
239 cout <<
"Permuted Matrix:\n" << *NewMatrix_;
244cout <<
"UExporter:\n" << *UExporter_;
245cout <<
"RExporter:\n" << *RExporter_;
246cout <<
"LExporter:\n" << *LExporter_;
250 cout <<
"ULHS:\n" << *ULHS_;
254 cout <<
"RLHS:\n" << *RLHS_;
258 cout <<
"LLHS:\n" << *LLHS_;
262 cout <<
"URHS:\n" << *URHS_;
266 cout <<
"RRHS:\n" << *RRHS_;
270 cout <<
"LRHS:\n" << *LRHS_;
275 cout <<
"UUGraph:\n" << *UUGraph_;
280 cout <<
"UUMatrix:\n" << *UUMatrix_;
285 cout <<
"URGraph:\n" << *URGraph_;
290 cout <<
"URMatrix:\n" << *URMatrix_;
295 cout <<
"ULGraph:\n" << *ULGraph_;
300 cout <<
"ULMatrix:\n" << *ULMatrix_;
305 cout <<
"RRGraph:\n" << *RRGraph_;
310 cout <<
"RRMatrix:\n" << *RRMatrix_;
315 cout <<
"RLGraph:\n" << *RLGraph_;
320 cout <<
"RLMatrix:\n" << *RLMatrix_;
325 cout <<
"LLGraph:\n" << *LLGraph_;
330 cout <<
"LLMatrix:\n" << *LLMatrix_;
334 cout <<
"Full System Characteristics:" << endl
335 <<
"----------------------------" << endl
336 <<
" Dimension = " << NRows << endl
339 <<
"Reduced System Characteristics:" << endl
340 <<
" Dimension = " << NReducedRows << endl
341 <<
" NNZs = " << RRMatrix_->NumGlobalNonzeros() << endl
342 <<
" Max Num Row Entries = " << RRMatrix_->GlobalMaxNumEntries() << endl
343 <<
"Singleton Info:" << endl
344 <<
" Num Singleton = " << NSingletons << endl
346 <<
" % Reduction in Dimension = " << 100.0*(NRows-NReducedRows)/NRows << endl
347 <<
" % Reduction in NNZs = " << (OldMatrix_->
NumGlobalNonzeros()-RRMatrix_->NumGlobalNonzeros())/100.0 << endl
348 <<
"-------------------------------" << endl;
355 cout <<
"done with SC\n";