49 #include "Epetra_Comm.h" 55 int iam = In->Comm().MyPID() ;
57 long long numentries = In->NumGlobalNonzeros64();
58 int NumRowEntries = 0;
59 double *RowValues = 0;
62 long long numrows = In->NumGlobalRows64();
63 long long numcols = In->NumGlobalCols64();
65 std::vector <int> Ap( numcols+1 );
66 std::vector <int> nextAp( numcols+1 );
67 #ifdef EPETRA_NO_32BIT_GLOBAL_INDICES 68 std::vector <long long> Ai( EPETRA_MAX( numcols, numentries) ) ;
70 std::vector <int> Ai( EPETRA_MAX( numcols, numentries) ) ;
72 std::vector <double> Aval( EPETRA_MAX( numcols, numentries) ) ;
76 assert( In->NumMyRows() == In->NumGlobalRows64() ) ;
80 std::vector <int>RowsPerCol( numcols ) ;
81 for (
int i = 0 ; i < numcols ; i++ ) RowsPerCol[i] = 0 ;
82 for (
int MyRow = 0; MyRow <numrows; MyRow++ ) {
83 ierr = In->ExtractMyRowView( MyRow, NumRowEntries, RowValues, ColIndices );
85 for (
int j = 0; j < NumRowEntries; j++ ) {
86 RowsPerCol[ ColIndices[j] ] ++ ;
93 for (
int i = 0 ; i < numcols ; i++ ) {
94 Ap[i+1]= Ap[i] + RowsPerCol[i] ;
100 for (
int MyRow = 0; MyRow <numrows; MyRow++ ) {
101 ierr = In->ExtractMyRowView( MyRow, NumRowEntries, RowValues, ColIndices );
102 assert( ierr == 0 ) ;
103 for (
int j = 0; j < NumRowEntries; j++ ) {
104 Ai[ nextAp[ ColIndices[j] ] ] = MyRow ;
105 Aval[ nextAp[ ColIndices[j] ] ] = RowValues[j] ;
106 nextAp[ ColIndices[j] ] ++ ;
113 for (
int MyRow = 0; MyRow <numrows; MyRow++ ) {
114 int NumInCol = Ap[MyRow+1] - Ap[MyRow] ;
115 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES) 116 Out->InsertGlobalValues( MyRow, NumInCol, &Aval[Ap[MyRow]],
119 assert( Out->IndicesAreGlobal() ) ;
122 assert( In->NumMyRows() == 0 ) ;
125 ierr = Out->FillComplete();
int CrsMatrixTranspose(Epetra_CrsMatrix *In, Epetra_CrsMatrix *Out)