<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Since the values I want to take from v[] are not contiguous in v[], I found even with<div>MatSetValuesLocal I can not avoid to make a copy of the values(that I want to take) in</div><div>a new array vnew[]. </div><div><div><div><br><div><div>On May 27, 2012, at 2:12 PM, Dmitry Karpeev wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Have you looked at MatSetValuesLocal() <div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesLocal.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesLocal.html</a>?  </div>

<div>That routine might be close enough to what you need.<div>Dmitry.<br><br><div class="gmail_quote">On Sun, May 27, 2012 at 4:01 AM, Hui Zhang <span dir="ltr"><<a href="mailto:mike.hui.zhang@hotmail.com" target="_blank">mike.hui.zhang@hotmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Also, in the case that only a *subset* of v[] is used, the new function sounds easy to me.<div>

<div class="h5"><br><div><div><br></div><br><blockquote type="cite"><div style="word-wrap:break-word"><pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">
Current MatSetValues is</pre><pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">MatSetValues(Mat mat,PetscInt m,const PetscInt idxm[],PetscInt n,const PetscInt idxn[],const PetscScalar v[],InsertMode addv)</pre>

<pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">I want something like</pre><pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">
<span style="font-family:SimSun;white-space:normal"><pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">
MatSetValues(Mat mat,PetscInt m,const PetscInt idxm[],PetscInt n,const PetscInt idxn[],const PetscScalar v[], const PetscInt idxv[], InsertMode addv)</pre></span><div>         -----------------------</div><div>         add a new parameter</div>

<div><br></div><div>such that the values v[0..m*n] are first reordered to v[idxv[0..m*n]] before set to the mat.</div><div>We may first do permutation on v before passing to current MatSetValues.  But won't the </div>

<div>new function be easier to use? </div><div><br></div><div><span style="font-family:SimSun;white-space:normal"><pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">
<div>In the case that idxm[], idxn[] are obtained from a certain application ordering</div><div>but not the ordering of v[], I think I need the new function.</div></pre></span></div><div>Of course, this new function sounds unnecessary because reordering v is equivalent to reordering </div>

<div>idxm[] and idxn[].  But the second method seems not an easy task to me, is it?</div><div><br></div><div>Thanks!  </div><div><br></div></pre><pre style="line-height:normal;text-indent:0px;letter-spacing:normal;text-align:-webkit-auto;font-variant:normal;text-transform:none;font-style:normal;font-weight:normal;word-spacing:0px">
<br></pre><div><br></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div>
</blockquote></div><br></div></div></div></body></html>