[petsc-users] 答复: 答复: 答复: 答复: About the MatGetOrdering in Petsc

Wei Deng deng106 at purdue.edu
Sat Apr 23 11:10:27 CDT 2016


Dear Matt, 

 

Really appreciate your help, the attachment are data for Matlab and c, and codes for them.

 

Hope that would help.

 

 

 

Best,

Wei 

 

发件人: Matthew Knepley [mailto:knepley at gmail.com] 
发送时间: Saturday, April 23, 2016 12:01 PM
收件人: Wei Deng <deng106 at purdue.edu>
抄送: Barry Smith <bsmith at mcs.anl.gov>; PETSc users list <petsc-users at mcs.anl.gov>
主题: Re: 答复: [petsc-users] 答复: 答复: About the MatGetOrdering in Petsc

 

On Fri, Apr 22, 2016 at 8:03 PM, Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> > wrote:

There is no bug, as the figure shows, rcm in matlab works well for symmetric matrix, however, petsc rcm has some bad points, like (117,9)

 

Wei,

 

We are not trying to do anything but call SPARSEPAK. It is possible that we have made an error here, which I will check. However,

I believe that RCM depends on the starting row, and perhaps Matlab is doing some preprocessing here. Since we cannot see exactly

what algorithm is being used in Matlab, there is no way for us to verify or match it. Perhaps you could send a small example which we

can verify explicitly what ordering Matlab is using. That way we could see which row becomes 0.

 

  Thanks,

 

      Matt

 

 

发件人: Matthew Knepley [mailto:knepley at gmail.com <mailto:knepley at gmail.com> ] 
发送时间: Friday, April 22, 2016 2:32 PM
收件人: Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> >
抄送: Barry Smith <bsmith at mcs.anl.gov <mailto:bsmith at mcs.anl.gov> >; PETSc users list <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov> >
主题: Re: [petsc-users] 答复: 答复: About the MatGetOrdering in Petsc

 

On Fri, Apr 22, 2016 at 12:18 PM, Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> > wrote:

This is a symmetric matrix and use sysrcm in matlab transform this into banded, however, call rcm in petsc still fails.

 

Fails is not descriptive enough. Please send the screenshot.

 

   Matt

 

filename = 'C:\Users\Wei\Desktop\bcspwr03.mat';
load(filename)
A=Problem.A;
p = symrcm(A);
R = A(p,p);
% change to dense
%B = full(R);
bandwidth(R)
subplot(1,2,2),spy(A),title(name)
subplot(1,2,2),spy(R),title(name)

name = 'Zd_Jac6.mat'
path = 'C:\Users\Wei\Documents\Courses\Parallelism Numerical Linear Algebra\CS515\matlab\'
filename = strcat(path,name);
load(filename)
A=Problem.A;
p = symrcm(A);
R = A(p,p);
% change to dense
%B = full(R);
bandwidth(R)
subplot(1,2,2),spy(A),title(name)
subplot(1,2,2),spy(R),title(name)

-----邮件原件-----
发件人: Barry Smith [mailto:bsmith at mcs.anl.gov <mailto:bsmith at mcs.anl.gov> ]
发送时间: Friday, April 22, 2016 12:38 PM
收件人: Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> >; PETSc users list <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov> >
主题: Re: [petsc-users] 答复: About the MatGetOrdering in Petsc


https://en.wikipedia.org/wiki/Cuthill–McKee_algorithm <https://en.wikipedia.org/wiki/Cuthill%E2%80%93McKee_algorithm>   indicates that these algorithms are for symmetric matrices.

Perhaps MATLAB detects a non-symmetric matrix and does something different in that case.

Barry

> On Apr 22, 2016, at 11:32 AM, Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> > wrote:
>
> So that means that this RCM may be not sufficiently work for a non-symmetric matrix?
>
>
> -----邮件原件-----
> 发件人: Barry Smith [mailto:bsmith at mcs.anl.gov <mailto:bsmith at mcs.anl.gov> ]
> 发送时间: Friday, April 22, 2016 12:30 PM
> 收件人: Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> >
> 抄送: petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov> 
> 主题: Re: [petsc-users] 答复: About the MatGetOrdering in Petsc
>
>
>   It can be applied to any graph but produces only a single permutation (that is it returns the same permutation for the rows and the columns even if the matrix is non-symmetric. From the source code
>
> /*****************************************************************/
> /*****************************************************************/
> /*********   GENRCM ..... GENERAL REVERSE CUTHILL MCKEE   ********/
> /*****************************************************************/
>
> /*    PURPOSE - GENRCM FINDS THE REVERSE CUTHILL-MCKEE*/
> /*       ORDERING FOR A GENERAL GRAPH. FOR EACH CONNECTED*/
> /*       COMPONENT IN THE GRAPH, GENRCM OBTAINS THE ORDERING*/
> /*       BY CALLING THE SUBROUTINE RCM.*/
>
> /*    INPUT PARAMETERS -*/
> /*       NEQNS - NUMBER OF EQUATIONS*/
> /*       (XADJ, ADJNCY) - ARRAY PAIR CONTAINING THE ADJACENCY*/
> /*              STRUCTURE OF THE GRAPH OF THE MATRIX.*/
>
> /*    OUTPUT PARAMETER -*/
> /*       PERM - VECTOR THAT CONTAINS THE RCM ORDERING.*/
>
> /*    WORKING PARAMETERS -*/
> /*       MASK - IS USED TO MARK VARIABLES THAT HAVE BEEN*/
> /*              NUMBERED DURING THE ORDERING PROCESS. IT IS*/
> /*              INITIALIZED TO 1, AND SET TO ZERO AS EACH NODE*/
> /*              IS NUMBERED.*/
> /*       XLS - THE INDEX VECTOR FOR A LEVEL STRUCTURE.  THE*/
> /*              LEVEL STRUCTURE IS STORED IN THE CURRENTLY*/
> /*              UNUSED SPACES IN THE PERMUTATION VECTOR PERM.*/
>
> /*    PROGRAM SUBROUTINES -*/
> /*       FNROOT, RCM.*/
> /*****************************************************************/
> #undef __FUNCT__
>
>> On Apr 22, 2016, at 8:36 AM, Wei Deng <deng106 at purdue.edu <mailto:deng106 at purdue.edu> > wrote:
>>
>> In other words, does the function MatGetOrdering only support symmetric matrix? It can’t work well in other cases?
>>
>> 发件人: Wei Deng [mailto:deng106 at purdue.edu <mailto:deng106 at purdue.edu> ]
>> 发送时间: Thursday, April 21, 2016 11:59 PM
>> 收件人: 'petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov> ' <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov> >
>> 主题: About the MatGetOrdering in Petsc
>>
>> Dear Sir/Madam,
>>
>>
>> When I was trying to change a sparse matrix into a banded one, I can use RCM in matlab to change it perfectly. But this does not work in Petsc, most points were moved to the diagonal position. However, there are still some points left, leading the width unacceptable.
>>
>> Do you know why?
>>
>> The attachment is the code with which I have trouble.
>>
>>
>> Thanks a lot.
>>
>>
>> Wei Deng
>> Purdue Uni.
>
>





 

-- 

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/20160423/5cecd694/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bcspwr03.mat
Type: application/octet-stream
Size: 1314 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160423/5cecd694/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bcspwr03.mtx
Type: application/octet-stream
Size: 2446 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160423/5cecd694/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: matlab.m
Type: application/octet-stream
Size: 319 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160423/5cecd694/attachment-0005.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160423/5cecd694/attachment-0001.c>


More information about the petsc-users mailing list