[petsc-users] is there a function to append matrix

Jed Brown jed at jedbrown.org
Mon Aug 31 22:29:46 CDT 2020


Karl Lin <karl.linkui at gmail.com> writes:

> If I have two matrix A and B with the same number of columns, same
> distribution pattern (column ownership pattern) among processes but
> different number of rows, is there a function to append B to A to make a
> new matrix C = [A; B]? Thanks.

Sort of; you can create a MatNest with the two matrices and (optionally) convert to AIJ format.

Better, you can take the code that builds A and B, but call it on "local" submatrices; see MatGetLocalSubMatrix() or an example like src/snes/tutorials/ex28.c.


More information about the petsc-users mailing list