how to get a sub-matrix from a GenericMatrix?

Asked by Feiteng

Hi all, I want to get the a sub-matrix from a GenericMatrix with [rows, cols]. Is there any way to do this work ?

Question information

English Edit question
DOLFIN Edit question
No assignee Edit question
Solved by:
Jan Blechta
Last query:
Last reply:
Revision history for this message
Best Jan Blechta (blechta) said :

That depends on situation. You can obtain dense numpy array by Matrix.array() method. Then you could somehow manipulate it using numpy. If you can't afford manipulating with dense representation you have to use some backend specific features. With uBLAS you can use method. For other backends I'm not sure wheter there is an interface in DOLFIN for such kind of operations.

If you intent getting block of matrix corresponding to some subspace of a mixed space you could rather assemble directly on separate spaces and putting blocks together using cbc.block if needed. Sorry if that's off-topic.


Revision history for this message
Feiteng (hftenger) said :

Thanks Jan Blechta, that solved my question.