44#include <Epetra_CrsGraph.h>
45#include <Epetra_CrsMatrix.h>
46#include <Epetra_Map.h>
47#include <Epetra_Comm.h>
57 if( NewGraph_ )
delete NewGraph_;
58 if( NewColMap_ )
delete NewColMap_;
61 template<
typename int_type>
68 assert( !orig.IndicesAreGlobal() );
72 const Epetra_Map & DomainMap = orig.DomainMap();
78 for(
int i = 0; i < NumCols; ++i )
79 if( DomainMap.GID64(i) != ColMap.GID64(i) )
86 Comm.
SumAll( &Match, &MatchAll, 1 );
95 std::vector<int_type> Cols(NumCols);
97 for(
int i = 0; i < NumCols; ++i )
98 Cols[i] = (int_type) DomainMap.GID64(i);
102 for(
int i = 0; i < NumMyCols; ++i )
103 if( !DomainMap.
MyGID( ColMap.GID64(i) ) ) Cols.push_back( (int_type) ColMap.GID64(i) );
105 int NewNumMyCols = Cols.size();
106 int NewNumGlobalCols;
107 Comm.
SumAll( &NewNumMyCols, &NewNumGlobalCols, 1 );
109 NewColMap_ =
new Epetra_Map( NewNumGlobalCols, NewNumMyCols,&Cols[0], DomainMap.IndexBase64(), Comm );
112 std::vector<int> NumIndicesPerRow( NumMyRows );
113 for(
int i = 0; i < NumMyRows; ++i )
114 NumIndicesPerRow[i] = orig.NumMyEntries(i);
115 NewGraph_ =
new Epetra_CrsGraph( Copy, RowMap, *NewColMap_, &NumIndicesPerRow[0] );
117 int MaxNumEntries = orig.MaxNumEntries();
119 std::vector<int_type> Indices( MaxNumEntries );
120 for(
int i = 0; i < NumMyRows; ++i )
122 int_type RowGID = (int_type) RowMap.GID64(i);
123 orig.Graph().ExtractGlobalRowCopy( RowGID, MaxNumEntries, NumEntries, &Indices[0] );
126 const Epetra_Map & RangeMap = orig.RangeMap();
136 int numMyRows = NewMatrix->NumMyRows();
137 for(
int i = 0; i < numMyRows; ++i )
139 orig.ExtractMyRowView( i, indicesCnt, myValues, myIndices );
142 NewMatrix->InsertMyValues( i, indicesCnt, myValues, myIndices );
145 NewMatrix->FillComplete(DomainMap,RangeMap);
157#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
158 if(orig.RowMap().GlobalIndicesInt()) {
159 return construct<int>(orig);
163#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
164 if(orig.RowMap().GlobalIndicesLongLong()) {
165 return construct<long long>(orig);
169 throw "CrsMatrix_SolverMap::operator(): GlobalIndices type unknown";
NewTypeRef operator()(OriginalTypeRef orig)
Constructs fixed view of Epetra_CrsMatrix as necessary.
~CrsMatrix_SolverMap()
Destructor.
const Epetra_Comm & Comm() const
int NumMyElements() const
bool MyGID(int GID_in) const
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const=0
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
int ExtractMyRowView(int LocalRow, int &NumIndices, int *&Indices) const
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.