PETSc sparsity

Mark Adams adams at pppl.gov
Fri Jun 15 14:08:44 CDT 2007


>
> Neat trick. MatGetRow will give me the row of the matrix, so would  
> then
> need a little loop to examine the elements and proceed as you  
> suggested;
> am I right?
>

There is probably more than one way to do this but you do NOT need to  
look at the elements (you can give PETSc a NULL arg for the values  
and it should work fine), you are getting the sparsity pattern from  
MatGetRow via the integer array of column ids.  You use these column  
ids to set the correct sparse *rows* of the column in question.  so  
something like this:

list of colums (j) <-- MatGetRow( row i )
MatsetValues( columns(j), row(i), zero_array, SET_VALEUS )  // note  
the transpose, using the current row (i) as the one column in  
MatSetValues.

Mark

> I guess there is no way to directly access the sparsity pattern then?
>
> Thanks for the suggestion.
>
> Best,
> 	Toby
>
>
> -----
>
> Toby D. Young (Adiunkt)
> Department of Computational Science
> Institute of Fundamental Technological Research
> Polish Academy of Science
> Room 206, ul. Swietokrzyska 21
> 00-049 Warszawa, POLAND
>

**********************************************************************
Mark Adams Ph.D.                                   Columbia University
289 Engineering Terrace                                        MC 4701
New York NY 10027
adams at pppl.gov                                www.columbia.edu/~ma2325
voice: 212.854.4485                                  fax: 212.854.8257
**********************************************************************





More information about the petsc-dev mailing list