<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Dear </span><font face="Arial" size="2">Jed Brown</font><span>,</span></div><div><br><span></span></div><div><span>I had found a better way: treat the matrix as a square matrix. Since it is spare anyway, so there should be no memory burden by doing so. I also extended the vector size to avoid conformable problem. I guess the size of a vector does not matter that much.<br></span></div><div><span></span></div>This little trick does a great job.<br><div><br></div><div>Nevertheless it would be great if you guy (developers) could consider putting some comments on creation of rectangular matrix.</div><div><br></div><div>Thank you for your very quick response.<br></div><div><br></div><div>Kind regards,</div><div>Pham Van Ha<br></div><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size:
12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Jed Brown <jedbrown@mcs.anl.gov><br> <b><span style="font-weight: bold;">To:</span></b> Pham Van <pham_ha@yahoo.com>; PETSc users list <petsc-users@mcs.anl.gov> <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, April 28, 2012 5:05 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [petsc-users] Preallocation for regtangular matrix<br> </font> </div> <br>
<div id="yiv1342306460"><div class="yiv1342306460gmail_extra"><div class="yiv1342306460gmail_quote">On Sat, Apr 28, 2012 at 03:32, Pham Van <span dir="ltr"><<a rel="nofollow" ymailto="mailto:pham_ha@yahoo.com" target="_blank" href="mailto:pham_ha@yahoo.com">pham_ha@yahoo.com</a>></span> wrote:<br><blockquote class="yiv1342306460gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="font-size:12pt;font-family:times new roman, new york, times, serif;">I am trying to create matrices for a rectangular matrix with number of rows is much bigger than number of columns.<br><br>I create 2 matrices together one square and one rectangular with the same number of rows. To my surprise the smaller matrix (rectangular) creation take much more time than the bigger one (rectangular). I did preallocate for both matrices with predefine number of diagonal and off-diagonal entries. But then again I did not know how to define diagonal part of a rectangular matrix. Only a very small top part of the matrix is "diagonal".<br>
<br>I have try both method: the first one to set diagonal and off-diagonal part as it was a square matrix; and second to set only a small top part of the matrix diagonal. Both method does not work.<br><br>Does anyone know how to preallocate a rectangular
matrix.<br><br>By the way, the same code run pretty fast when I run with single process and painfully slow when 2 processes employed.</div></blockquote></div><br></div><div class="yiv1342306460gmail_extra">The matrix has row and column ownership ranges. The "diagonal" part is any entry that lies in both the row and column ownership range. The "off-diagonal" part is in the row ownership range, but not in the column ownership range.</div>
<div class="yiv1342306460gmail_extra"><br></div><div class="yiv1342306460gmail_extra">Run with -mat_new_nonzero_allocation_err or</div><div class="yiv1342306460gmail_extra"><br></div><div class="yiv1342306460gmail_extra">ierr = MatSetOption(B,MAT_NEW_NONZERO_ALLOCATION_ERR,flg);CHKERRQ(ierr);</div>
<div class="yiv1342306460gmail_extra"><br></div><div class="yiv1342306460gmail_extra">to find which entries start going outside your preallocation.</div>
</div><br><br> </div> </div> </div></body></html>