You can do this directly in PETSc. Create a KSP object with PREONLY and PCCHOLESKY (or just a PC object). Then call KSPSetUp (or PCSetUp) and extract the factored matrix with PCFactorGetMatrix(). Then call MatGetInertia() on the factored matrix. Repeat this for each value of E.
I guess it can be even shorter if you call MatCholeskyFactor() directly. Jose > El 24 mar 2020, a las 11:07, Perceval Desforges > <perceval.desfor...@polytechnique.edu> escribió: > > Dear petsc developers, > > I am interested in calculating the inertias of matrixes. Specifically, for a > certain matrix A, and for different real numbers E, I want to calculate the > inertias of (A - E * I), in order to get the number of eigenvalues less than > E. > > In order to do this I have been setting up a slepc EPS object with spectrum > slicing, and using EPSKrylovSchurGetInertias. I realize this is a bit > convoluted, and was wondering if there is a better way to do this? > > Best regards, > > Perceval, > > P.S. my last email seems to not have been sent (I couldn't find it in the > archives) so I am trying again... >