[petsc-users] MatGetDiagonal

Clemens Domanig clemens.domanig at uibk.ac.at
Tue Aug 9 08:43:35 CDT 2011


Hi,

I already talked to some of you about this in combination with some 
other problem, but somehow I don't get it.
I want the diagonal entries of the matrix M. But my vector 'diag' is 
mainly full of zeros when using MatGetDiagonal().
I can print 'DiagM' (VecView) where I see all the diagonal entries but I 
cannot access them using MatGetValue (Object is in wrong state. Not for 
factored matrix!).
How can I get access to the diagonal?
Thx - Clemens


KSPCreate( coml, &kspBA);
KSPGetPC( kspBA, &precond);
PCSetType( precond, PCCHOLESKY);
PCFactorSetMatSolverPackage( precond, MAT_SOLVER_PETSC);
KSPSetOptionsPrefix( kspBA, "diag_pc_type cholesky");
KSPSetFromOptions( kspBA);
KSPSetOperators( kspBA, Kt, Kt, DIFFERENT_NONZERO_PATTERN);
KSPSetUp( kspBA);
PCFactorGetMatrix( precond, &DiagM);	//DO NOT DESTROY DiagM !!!
MatGetDiagonal( DiagM, diag);


More information about the petsc-users mailing list