44 #include <Epetra_Export.h> 45 #include <Epetra_CrsGraph.h> 46 #include <Epetra_Map.h> 64 int nRows = orig.NumMyRows();
65 int nCols = orig.NumMyCols();
67 const Epetra_BlockMap & RowMap = orig.RowMap();
72 Epetra_CrsGraph * TransposeGraph = 0;
76 std::vector<int> TransNumNZ( nCols, 0 );
77 for(
int i = 0; i < nRows; ++i )
79 orig.ExtractMyRowView( i, numIndices, Indices );
80 for(
int j = 0; j < numIndices; ++j ) ++TransNumNZ[ Indices[j] ];
83 std::vector< std::vector<int> > TransIndices( nCols );
84 for(
int i = 0; i < nCols; ++i )
87 TransIndices[i].resize( TransNumNZ[i] );
91 for(
int i = 0; i < nRows; ++i )
93 orig.ExtractMyRowView( i, numIndices, Indices );
94 for(
int j = 0; j < numIndices; ++j )
95 TransIndices[ Indices[j] ][ TransNumNZ[ Indices[j] ]++ ] = i;
98 Epetra_CrsGraph SharedTransGraph(
View, orig.ImportMap(), RowMap, &TransNumNZ[0] );
99 for(
int i = 0; i < nCols; ++i )
100 if( TransNumNZ[i] ) SharedTransGraph.InsertMyIndices( i, TransNumNZ[i], &TransIndices[i][0] );
101 SharedTransGraph.FillComplete();
103 TransposeGraph =
new Epetra_CrsGraph(
Copy, RowMap, 0 );
104 Epetra_Export Exporter( orig.ImportMap(), RowMap );
105 TransposeGraph->Export( SharedTransGraph, Exporter, Add );
106 TransposeGraph->FillComplete();
110 std::vector<int> TransNumNZ( nRows, 0 );
111 for(
int i = 0; i < nRows; ++i )
113 orig.ExtractMyRowView( i, numIndices, Indices );
114 for(
int j = 0; j < numIndices; ++j )
115 if( Indices[j] < nRows ) ++TransNumNZ[ Indices[j] ];
118 std::vector< std::vector<int> > TransIndices( nRows );
119 for(
int i = 0; i < nRows; ++i )
122 TransIndices[i].resize( TransNumNZ[i] );
126 for(
int i = 0; i < nRows; ++i )
128 orig.ExtractMyRowView( i, numIndices, Indices );
129 for(
int j = 0; j < numIndices; ++j )
130 if( Indices[j] < nRows ) TransIndices[ Indices[j] ][ TransNumNZ[ Indices[j] ]++ ] = i;
133 TransposeGraph =
new Epetra_CrsGraph(
Copy, RowMap, RowMap, &TransNumNZ[0] );
135 for(
int i = 0; i < nRows; ++i )
136 if( TransNumNZ[i] ) TransposeGraph->InsertMyIndices( i, TransNumNZ[i], &TransIndices[i][0] );
138 TransposeGraph->FillComplete();
143 return *TransposeGraph;
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
~CrsGraph_Transpose()
Destructor.
NewTypeRef operator()(OriginalTypeRef orig)
Transpose Transform Operator.