[petsc-users] create a sparse symmetric matrix

Matthew Knepley knepley at gmail.com
Thu Aug 9 22:20:40 CDT 2012


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

>
>
> On Thu, Aug 9, 2012 at 10:59 PM, Matthew Knepley <knepley at gmail.com>wrote:
>
>> On Thu, Aug 9, 2012 at 9:53 PM, Yifei Li <yifli82 at gmail.com> wrote:
>>
>>> Matt,
>>>
>>> Thanks.  I have another two related questions:
>>> 1) So just because I did not get the correct value doesn't mean the
>>> symmetric matrix is not setup correctly?
>>>
>>
>> Right.
>>
>>
>>> 2) Which function should I use to retrieve the value then? I can't get
>>> the correct value even though I disabled MPI when  building PETSC?
>>>
>>
>> Since it would require communication, there is no easy way to do this.
>> Why would you need this?
>>
>>
> I just want to make sure the lower triangular part gets the same values as
> the upper triangular part.
>

That is what View() is for.

   Matt


>
>>
>>    Matt
>>
>>
>>> Yifei
>>>
>>>
>>>
>>> On Thu, Aug 9, 2012 at 8:45 PM, Matthew Knepley <knepley at gmail.com>wrote:
>>>
>>>> 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
>>>>
>>>
>>>
>>
>>
>> --
>> 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
>>
>
>


-- 
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/16edf9f8/attachment.html>


More information about the petsc-users mailing list