add a smaller matrix to a larger one?

Matthew Knepley knepley at
Thu Jan 17 07:40:27 CST 2008

If the small matrix is dense, just use MatSetValues. If not, I do not
know of a nice way to do this, and would switch to using the individual
element matrices.


On Jan 17, 2008 4:20 AM, Zhifeng Sheng <z.sheng at> wrote:
> Dear all
> I have a problem, I want to add a small matrix to a larger matrix, where
> the row and column indexes of the small matrix is mapped to global
> indexes of the global one.
> the problem comes from a kind of finite element method, however, I have
> to do some operations on the small matrix, and it prevent me from
> directly assembling the local entries. So I have local matrices and I
> would like to add it to the global one. At this moment, I have to get
> the matrix value and add it to the global matrix  one by one ...
> is there a better way to do it?
> Thanks
> Best regards
> Zhifeng

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

More information about the petsc-users mailing list