<div class="gmail_extra"><div class="gmail_quote">On Sat, Apr 28, 2012 at 03:32, Pham Van <span dir="ltr">&lt;<a href="mailto:pham_ha@yahoo.com" target="_blank">pham_ha@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_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 &quot;diagonal&quot;.<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="gmail_extra">The matrix has row and column ownership ranges. The &quot;diagonal&quot; part is any entry that lies in both the row and column ownership range. The &quot;off-diagonal&quot; part is in the row ownership range, but not in the column ownership range.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Run with -mat_new_nonzero_allocation_err or</div><div class="gmail_extra"><br></div><div class="gmail_extra">ierr = MatSetOption(B,MAT_NEW_NONZERO_ALLOCATION_ERR,flg);CHKERRQ(ierr);</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">to find which entries start going outside your preallocation.</div>