zero out columns
Toby D. Young
tyoung at ippt.gov.pl
Fri Jan 18 04:32:04 CST 2008
The procedure I wish to program with petsc requires setting a series of
matrix elements to zero, and for a given number of rows and columns.
The operation is intended to run for large parallel sparse matrices.
Using MatZeroRowsIS() I can easily achieve zeroing out the rows I want
and now I am wondering how to zero out the columns. I imagine there are
a few other ways of doing this, I've come up with two:
MatGetColumnIJ() // get a specified column
VecSetValues() // set wanted indices to zero
MatRestoreColumnIJ() // restore vector to the matrix
The Petsc manual warns "Since PETSc matrices are usually stored in
compressed row format, this routine will generally be
slow." (of MatGetColumnIJ).
MatTranspose() // Take the transpose of the matrix
MatZeroRowsIS() // Zeroi out the row which was the target column
This requires creating a new matrix, i.e. the transpose and then
releasing memory from the old matrix. The advantage is that it is
relatively straightforward to code up.
The rather obvious third way is to simply force the column elements to
be zero with MatSetValues() which, I am guessing, is not likely to be
efficient and I am not really considering this.
I am wondering if anyone has a clue as to which of the methods above is
likely to be more efficient for large parallel sparse matrices. Perhaps
someone may have a suggesttion for an alternative approach.
Thanks in advance.
Toby D. Young - Adiunkt (Assistant Professor)
Department of Computational Science
Institute of Fundamental Technological Research
Polish Academy of Sciences
Room 206, Swietokrzyska 21
00-049 Warsaw, POLAND
More information about the petsc-users