<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi Barry,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks for your correction. This mean I have to set up values to be a 3x3 values matrix and set values[0]=1, values[4]=10, values[8]=20 and all other elements of values[i]=0 for i=1,2,3,5,6,7. But, by doing this way, it will also assembly 0 to other 6 location of the global matrix at (0,2) (3,1) (3,2) ..... and it may break the sparse matrix format of A. To prevent this, we must assembly one by one element (do the MatSetValues three times for this case) or is there any other way to set three elements of A at one time?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 21, 2014 at 2:25 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Jan 21, 2014, at 1:22 PM, Que Cat <<a href="mailto:quecat001@gmail.com">quecat001@gmail.com</a>> wrote:<br>
<br>
> Hi Petsc-users,<br>
> I confused about the MatSetValue from the manual.<br>
> For example, I need to assembly three values A[0,1]=1 , A[3,2]=10 , A[5,2]=20 to the parallel matrix A. I can create a dense subblock matrix values that has dimension of m=1, n=3: values=[1 10 20], idxm=[0 3 5], idxn=[1 2 2].<br>
<br>
</div> No this does not do that. the above idxm, idxn does not mean you are setting entries (0,1) (3,2) (5,2) it means you are setting the 1, 2 and 2 columns of the 0th, 3rd and 5th rows so 9 = 3x3 values. (which doesn’t make sense since you won’t set the 2 columns twice).<br>
<div class="HOEnZb"><div class="h5">> But the manual says that "the value to be put in row idxm[i] and column idxn[j] is located in values[i*n+j]". So, for example i=1,j=1 will add values[1*3+1] to the matrix, which does not exist in values. What do I misunderstand the manual? We can set separate value to the parallel matrix, but it says that it is better to set a subblock matrix.<br>
> Thank you.<br>
><br>
> Que.<br>
<br>
</div></div></blockquote></div><br></div>