<div>Thanks Barry,</div>
<div> </div>
<div>I managed to get it working. I realise that I had to call matssemblybegin/end each time after I zero a particular row. I also tried MatSetOption(mat,MAT_KEEP_ZEROED_ROWS) as what you 've suggested.</div>
<div> </div>
<div>So do I have to callMatSetOption(mat,MAT_KEEP_ZEROED_ROWS) everytime just before I need to zero it or just once ie after the 1st matassemblybegin/end?</div>
<div> </div>
<div>Calling matassemblybegin/end each time before matzerorows gives me the impression that it is very inefficient. Is that so?</div>
<div> </div>
<div>In that case, I wonder if it is better for me to :</div>
<div> </div>
<div>1 use matsetvalues to put zeros into those location where I earlier insert in the 1st full i,j sweep</div>
<div>2. insert correct value using matsetvalues</div>
<div>3. finally matassemblybegin/end - just once.</div>
<div> </div>
<div>Lastly, is MatZeroRowsIS exactly the same as matzerorows, except that it is meant for just 1 row instead of consecutive no. of rows?</div>
<div> </div>
<div>Thanks again<br><br> </div>
<div><span class="gmail_quote">On 6/11/07, <b class="gmail_sendername">Barry Smith</b> <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>On Sun, 10 Jun 2007, Ben Tay wrote:<br><br>> Hi,<br>><br>> I need to insert values into a matrix and then solve this poisson eqn as
<br>> part of my cfd code. For efficiency sake, I simply use<br>><br>> "do j=1,size_y<br>><br>> do i=1,size_x<br>><br>> matsetvalue ....<br>><br>> end do<br>><br>> end do"<br>>
<br>> to insert values into all the cells<br>><br>> Then for specific cells, I need to enter some other values. In other words,<br>> for specific rows of the matrix, I need to zero the whole row and insert new
<br>> values. How can I do that?<br>><br>> I tried to use MatZeroRows but it says it's not for unassembled matrix. But<br>> I need to zero the particular row, insert values, and then finally assembly<br>> it. Is there a command to do this?
<br><br> matassemblybegin/end<br> matzerorows<br> matsetvalues, matsetvalues, matsetvalue<br> matssemblybegin/end<br><br> For improved efficiency you will want to call<br> MatSetOption(mat,MAT_KEEP_ZEROED_ROWS); before the matzerorows()
<br><br>><br>> Thanks<br>><br><br></blockquote></div><br>