[petsc-users] How to create symmetric matrix?

Faraz Hussain faraz_hussain at yahoo.com
Mon Jun 6 13:02:45 CDT 2016


I am learning petsc and using the following code to insert values into my matrix:
ierr = MatSetValue(A, row, col, value,INSERT_VALUES);
ierr = MatSetValue(A, col, row, value,INSERT_VALUES);

Since my matrix is symmetric, I want to speed things up only calling MatSetValue once. I tried setting: 

 ierr = MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);

However, whenver I solve Ax=b, I get a wrong solution for x ( almost all zeroes ).  I am guessing MAT_SYMMETRIC is not automatically creating the lower triangular matrix from the upper triangular matrix?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160606/706ad8e4/attachment.html>


More information about the petsc-users mailing list