Use Vectors and Scalars in MatNest matrices
Hi! I would like to ask if it is possible to create a MatNest matrix that contains matrices, vectors and scalars. My (jacobian) matrix looks like the following [[A, B, a, b], [C, D, c, d], [e, f, g, h]] where A-D are sparse square matrices, a-d are dense column vectors, e, f are sparse row vectors and g,h are just scalars. Is there also a petsc4py example that shows how nest objects should be created and how they should be used? Best regards Thomas
Not exactly. But you can make a Mat for each. Mark On Mon, Nov 14, 2022 at 8:59 AM Thomas Hisch <[email protected]> wrote:
Hi!
I would like to ask if it is possible to create a MatNest matrix that contains matrices, vectors and scalars.
My (jacobian) matrix looks like the following
[[A, B, a, b], [C, D, c, d], [e, f, g, h]]
where A-D are sparse square matrices, a-d are dense column vectors, e, f are sparse row vectors and g,h are just scalars.
Is there also a petsc4py example that shows how nest objects should be created and how they should be used?
Best regards Thomas
On Mon, Nov 14, 2022 at 8:59 AM Thomas Hisch <[email protected]> wrote:
Hi!
I would like to ask if it is possible to create a MatNest matrix that contains matrices, vectors and scalars.
No, You would turn everything into a type of matrix, but you can get the effect you want. Vectors can be easily used to create dense matrices, or vice versa. The scalars would also be dense matrices (and can share storage). Sparse vectors are just sparse matrices in PETSc. Thanks, Matt
My (jacobian) matrix looks like the following
[[A, B, a, b], [C, D, c, d], [e, f, g, h]]
where A-D are sparse square matrices, a-d are dense column vectors, e, f are sparse row vectors and g,h are just scalars.
Is there also a petsc4py example that shows how nest objects should be created and how they should be used?
Best regards Thomas
-- 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 https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
On Mon, Nov 14, 2022 at 3:06 PM Matthew Knepley <[email protected]> wrote:
On Mon, Nov 14, 2022 at 8:59 AM Thomas Hisch <[email protected]> wrote:
Hi!
I would like to ask if it is possible to create a MatNest matrix that contains matrices, vectors and scalars.
No, You would turn everything into a type of matrix, but you can get the effect you want. Vectors can be easily used to create dense matrices, or vice versa. The scalars would also be dense matrices (and can share storage). Sparse vectors are just sparse matrices in PETSc.
Good. I'll work on an example and will then ask you if I'm using the api in the correct way. Thx
Thanks,
Matt
My (jacobian) matrix looks like the following
[[A, B, a, b], [C, D, c, d], [e, f, g, h]]
where A-D are sparse square matrices, a-d are dense column vectors, e, f are sparse row vectors and g,h are just scalars.
Is there also a petsc4py example that shows how nest objects should be created and how they should be used?
Best regards Thomas
-- 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
participants (3)
-
Mark Adams -
Matthew Knepley -
Thomas Hisch