[Trilinos-Users] set column to zero in Epetra_FECrsMatrix
Hoemmen, Mark
mhoemme at sandia.gov
Tue Jan 22 15:10:02 MST 2013
Greetings!
On Jan 22, 2013, at 12:00 PM, <trilinos-users-request at software.sandia.gov>
wrote:
> I would like to know if there is a method in Epetra_FECrsMatrix that, given a Row index, sets all the entries the column (of all the processors) to zero.
I'm guessing that what you want to do is set an entire row of the matrix to zero.
You can do this in two steps.
1. Use ExtractGlobalRowView() (if indices are global) or ExtractMyRowView() (if indices are local) to get a view of all the columns in the row that are owned by the calling process. (IndicesAreLocal() tells you whether indices are local.)
2. The view is just an array of the entries in that row. You can then set them all to zero.
If you do this on all processes, it will set all the entries in that row on all processes to zero.
> I saw that there is a method to get the column map. I would like to know also how this map is built, because I think that it is useful to do what I need.
The column Map tells the matrix what entries of the source vector it needs in order to compute a sparse matrix-vector multiply.
If a particular process p owns the set of rows R_p (that is, if all elements in R_p are owned by the row Map on that process), then the column Map on that process is the set of columns for which there is at least one entry of the sparse matrix in any of the rows R_p. For example, if a 3x3 tridiagonal matrix has a row Map where process 0 owns row 0, and process 1 owns rows 1 and 2, then the column Map is {0, 1} on process 0, and {0, 1, 2} on process 1.
Computing the column Map is not so hard if you know the structure of the matrix in advance. You can even do this yourself and give the column Map to the matrix constructor along with the row Map. (This lets you use local indices to fill the sparse matrix, which may be faster.) However, you are not required to do this.
mfh
More information about the Trilinos-Users
mailing list