I have a matrix K in Petsc. I want to delete the $n^{th}$ row and $n^{th}$ column of this matrix and restructure it. I am a beginner in Petsc. Can you suggest how to do it?

Example: I have matrix K of size 100 x 100. I want to remove the 10th row and 10th column so that the remaining restructured matrix is 99 x 99.


You don't do that for large and sparse matrices. It's an inefficient operation. Rather, you zero out the $n$th row and column and put a nonzero entry on the diagonal. Then you think about what operations that you wanted to do on the $99\times 99$ matrix need to look like on the modified $100\times 100$ matrix.

| cite | improve this answer | |
  • $\begingroup$ Thank you for your reply Sir! I want to compute the smallest magnitude eigenvalues a tangent stiffness matrix (FEM). Assuming I am not concerned with the efficiency, as it is one time calculation, would you suggest a way to restructure the matrix? I agree with your "operations" analogy on modified matrix, in that that case, willI I have unit corresponding eigen values? $\endgroup$ – ARUN KUMAR Jun 3 at 5:24
  • $\begingroup$ Yes, if you delete a row and column and place a value of $a$ on the diagonal, you get one eigenvalue equal to $a$. In other words, if you are looking for the smallest eigenvalue, you want to choose $a$ to equal, for example, the magnitude of the largest diagonal entry in hopes that $a$ is then larger than the smallest eigenvalue. You generally want to ensure that $a$ is on the same order of magnitude as the other entries in the matrix to make sure the resulting matrix remains well-conditioned. $\endgroup$ – Wolfgang Bangerth Jun 3 at 16:33
  • $\begingroup$ I do think that zeroing out rows and columns is much easier to implement than actually shrinking the size of the matrix to $99\times 99$. $\endgroup$ – Wolfgang Bangerth Jun 3 at 16:34
  • $\begingroup$ Got it! Thanks Sir! $\endgroup$ – ARUN KUMAR Jun 4 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.