Epetra_CrsMatrix: InsertMyValues() is not working correctly
Created by: freaklovesmango
I am using the InsertMyValues() method of Epetra_CrsMatrix. However, it does not set the Col Index' correctly and I do not know why. If I change the visibility of the method InsertValues() which is called by InsertMyValues() from protected/private to public and use this instead of the other, the column IDs are set correctly. Basically, what my code does is similar to this short version:
double c = 0.9;
for (int r = 0; r < 6; ++r ){
crsMatrix.InsertMyValues(r, 1, &c, &r);
}
std::cout << "The Matrix with InsertMyValues(): \n " << crsMatrix << std::endl;
where crsMatrix is a Epetra_CrsMatrix with a serial communicator. The output is this:
The Matrix with InsertMyValues():
Epetra::CrsMatrix
Number of Global Rows = 6
Number of Global Cols = 6
Number of Global Diagonals = 0
Number of Global Nonzeros = 0
Global Maximum Num Entries = 0
** Matrix is Lower Triangular **
** Matrix is Upper Triangular **
** Matrix has no diagonal **
Number of My Rows = 6
Number of My Cols = 6
Number of My Diagonals = 0
Number of My Nonzeros = 0
My Maximum Num Entries = 1
Processor Row Index Col Index Value
0 0 -1 0.9
0 1 -1 0.9
0 2 -1 0.9
0 3 -1 0.9
0 4 -1 0.9
0 5 -1 0.9
wheras with InsertValues() the output is correct like this:
The Matrix with InsertValues():
Epetra::CrsMatrix
Number of Global Rows = 6
Number of Global Cols = 6
Number of Global Diagonals = 0
Number of Global Nonzeros = 0
Global Maximum Num Entries = 0
** Matrix is Lower Triangular **
** Matrix is Upper Triangular **
** Matrix has no diagonal **
Number of My Rows = 6
Number of My Cols = 6
Number of My Diagonals = 0
Number of My Nonzeros = 0
My Maximum Num Entries = 1
Processor Row Index Col Index Value
0 0 0 0.9
0 1 1 0.9
0 2 2 0.9
0 3 3 0.9
0 4 4 0.9
0 5 5 0.9