<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 04/03/2013 01:52 PM, Jed Brown
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAM9tzS=UepFcmEQ_w8AZN1w=-8GNJt2ehmP92Qstx-VnE6H-Pg@mail.gmail.com"
      type="cite">
      <div dir="ltr">On Wed, Apr 3, 2013 at 11:55 AM, Michael
        Povolotskyi <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:mpovolot@purdue.edu" target="_blank">mpovolot@purdue.edu</a>></span>
        wrote:<br>
        <div class="gmail_extra">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear
              PETSc developers,<br>
              I have a following question:<br>
              <br>
              I have a dense serial matrix of M x N size<br>
              I have a N vectors of size M.<br>
              I need to copy content of those vectors to the columns of
              the matrix.<br>
              What is the fastest way of doing this?<br>
            </blockquote>
            <div><br>
            </div>
            <div style="">MatGetLocalSize(A,&m,NULL);</div>
            <div style="">MatDenseGetArray(A,&a);</div>
            <div style="">for (i=0; i<nvecs; i++) {</div>
            <div style="">  const PetscScalar *x;</div>
            <div style="">  VecGetArrayRead(X[i],&x);</div>
            <div style="">  PetscMemcpy(a+i*m,x,m*sizeof(PetscScalar));</div>
            <div style="">  VecRestoreArrayRead(X[i],&x);</div>
            <div style="">}</div>
            <div style="">MatDenseRestoreArray(A,&a);</div>
            <div style=""><br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    Thank you for help.<br>
    Michael.<br>
  </body>
</html>