efficient matrix block assignment

Matthew Knepley knepley at gmail.com
Thu Aug 6 08:29:45 CDT 2009


On Thu, Aug 6, 2009 at 8:18 AM, Umut Tabak <u.tabak at tudelft.nl> wrote:

> Dear all,
>
> I am trying some block matrix assembly in Petsc, so far, I was puzzling
> with the right calling and set up of MatSetValuesBlocked. Matthew Knepley
> confirmed my previous post. I guess it is the function I should use. But it
> accepts the values as a 1D array, which is  represented in row major
> order(by default). So the burden on this approach is to convert my Matrix
> into a 1D array, this seemed as the only solution for the moment. If I would
> like to use this function.


I need to understand what you mean here. The 1D array we accept here is the
input values. It is physically 1D, but conceptually
2D, and by default is in row-major order. This has nothing to do with your
larger Mat object.


>
> Another way I could think of by reading the documentation of Matrices, is
> to use MatGetColumnVector and assign over column vectors, but the above
> approach is far more efficient, I guess.


You cannot assign that way, only through MatSetValues*().


>
> BTW, some blocks are square and some are rectangular, with block size type
> operations, I guess it is not possible to assign rectangular matrices to
> some part of a larger square matrix.


Not true. You can have any mxn dimension to the input values. I think there
is some underlying confusion here
that I do not understand. I would suggest you look at the example in the
manual.

  Matt


>
> Are there any other efficient suggestions?
>
> Best regards,
> Umut
>
-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090806/c50033b6/attachment.htm>


More information about the petsc-users mailing list