[petsc-users] create a sparse symmetric matrix

Matthew Knepley knepley at gmail.com
Thu Aug 9 19:45:13 CDT 2012


On Thu, Aug 9, 2012 at 5:20 PM, Yifei Li <yifli82 at gmail.com> wrote:

> Hi all,
>
> I only filled the entries in the upper triangular part of the matrix,
> however, I got  0 when I tried to get the value of some entry in the lower
> triangular part.
>
> Here's how I do it:
>
>
> MatCreate(PETSC_COMM_WORLD, &A);
>
> MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, n, n);
>
> MatSetType(A, MATSEQSBAIJ);
>
> MatSetUp(A);
>
> // I set the value for the entry at (0, 2)
>
> int i = 2, j = 0;
>
> MatGetValues(A,1,&i,1,&j,values);
>
MatGetValues() is not synchronous, so it would not be able to communicate
to the
correct process to retrieve the values. Thus, you cannot retrieve the lower
triangle.
This is analogous to only having access to local values with VecGetArray().

   Matt


> Any help is highly appreicated.
>
>
>
> Yifei
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120809/50758be9/attachment.html>


More information about the petsc-users mailing list