<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi<div>I tried MatGetSubMatrix() but I am a little confused by the column parameter. For example</div><div>My matrix is U (m * n). I want to get i,j rows to local.</div><div>my code is </div><div><br></div><div>PetscInt* rowindex,colindex;</div><div>PetscMalloc...</div><div>for (k= 0; k < n; k++)</div><div> colindex[k] = k;</div><div><br></div><div>rowindex[0] = i;</div><div>rowindex[1] = j;</div><div><br></div><div>MatGetSubMatrixRaw(U,1,&i,n,indices,n,MAT_INITIAL_MATRIX,&newmat);</div><div><br></div><div>What I hope is newmat is 2 * n matrix. But I failed.</div><div><br></div><div>Thank you</div><div><br><br>--- <b>09年12月1日,周二, Barry Smith <i><bsmith@mcs.anl.gov></i></b> 写道:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>发件人: Barry Smith
<bsmith@mcs.anl.gov><br>主题: Re: How to copy global data to local ?<br>收件人: "PETSc users list" <petsc-users@mcs.anl.gov><br>日期: 2009年12月1日,周二,下午10:35<br><br><div class="plainMail"><br> You misunderstand the usage of MatGetSubMatrix(). Any process can request ANY row, including rows that are not originally owned by that process.<br><br> Barry<br><br>On Dec 1, 2009, at 8:29 AM, ming zhu wrote:<br><br>> It seems that MatGetSubMatrix() only get the local matrix for the processor If U is global(PETSC_COMM_WORLD), the local matrix may not store the column or row I wanted. For example, if U is 4*4, and there are 4 processors, processors one has local matrix 2*2, but i need the third row, Then,MatGetSubmatrix() may not work<br>> <br>> --- 09年12月1日,周二, Barry Smith <<a ymailto="mailto:bsmith@mcs.anl.gov"
href="/mc/compose?to=bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> 写道:<br>> <br>> 发件人: Barry Smith <<a ymailto="mailto:bsmith@mcs.anl.gov" href="/mc/compose?to=bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>><br>> 主题: Re: How to copy global data to local ?<br>> 收件人: "PETSc users list" <<a ymailto="mailto:petsc-users@mcs.anl.gov" href="/mc/compose?to=petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>> 日期: 2009年12月1日,周二,下午10:23<br>> <br>> <br>> On Nov 30, 2009, at 11:21 PM, ming zhu wrote:<br>> <br>> > Hi<br>> > I have a huge matrix U for all processors (PETSC_COMM_WORLD). I only want to copy only two rows (i,j) for each local processor. i,j is different for each processor and not related to rank. I was trying to use a vector filter (like, 00000010000). However, if the vector is PETSC_COMM_WORLD, it will be changed by different processor. So, how to make it
?<br>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>> <br>> I do not understand what this means. To do the multiply you can and should use a vector of PETSC_COMM_WORLD.<br>> <br>> Also multiplying by a vector will not give you back "rows" of a matrix. Do you truly want the entire row of nonzeros of the matrix or something else. If
you want the entire row or part of a row then you can use MatGetSubMatrix().<br>> <br>> Barry<br>> <br>> > Thank you<br>> ><br>> > My original code is<br>> ><br>> > Vec filter<br>> > VecCreate(PETSC_COMM_WORLD,&filter);<br>> > VecSetsizes(filter,PETSC_DECIDE,m);<br>> > VecSetFromOptions(filter);<br>> ><br>> > Vecset(filter,0);<br>> > VecSetValue(filter,i,1,INSERT_VALUES);<br>> ><br>> > ...<br>> > MatMult(U, filter,ui);<br>> ><br>> > If I create filter with PETSC_COMM_SELF, it is impossible for U and filter to multiply.<br>> ><br>> ><br>> ><br>> ><br>> ><br>> > 好玩贺卡等你发,邮箱贺卡全新上线!<br>> <br>> <br>> 好玩贺卡等你发,邮箱贺卡全新上线!<br><br></div></blockquote></div></td></tr></table><br>
<hr size=1><a href="http://cn.rd.yahoo.com/mail_cn/tagline/card/*http://card.mail.cn.yahoo.com/"> 好玩贺卡等你发,邮箱贺卡全新上线!</a>