[petsc-users] Calling EPSSolve() multiple times

Matthew Knepley knepley at gmail.com
Fri May 20 10:03:47 CDT 2016

On Fri, May 20, 2016 at 9:57 AM, Alejandro Cosimo <alecosimo at gmail.com>

> Hi,
> I would like to know if I'm using EPSSolve() correctly in the following
> situation. I must solve a series of eigenvalue problems where the size of
> the matrix and the EPS options remain the same, but the entries of the
> matrix change for each problem. In pseudo-code, something like this:
> Mat A;
> /* create and set matrix */
> EPSCreate(comm,&eps);
> /* here set EPS options */
> for (i=0;i<n;i++)  {
> /* set entries of matrix A which vary for each index i of the for-loop */
> EPSSetOperators(eps,A,NULL);
> EPSSolve(eps);
> }
> My questions:
> 1* Is it correct to call at each iteration of the loop to
> EPSSetOperators() before proceeding to solve the eigenvalue problem?


> 2* Would be wrong to call EPSSetOperators() before entering the loop and
> to call to EPSReset() at every iteration instead of calling to
> EPSSetOperators()?

Yes, reset frees all memory and destroys the implementation object

> 3* A little different question, but related. Suppose a similar situation
> where you have a KSP solver instead of an EPS solver. In this context, do
> the answers to the previous questions apply similarly? That is, is it
> correct to call at every iteration to KSPSetOperators() before  calling to
> KSPSolve() or KSPSetUp()?



> Thanks,
> Alejandro

What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160520/b004ddca/attachment.html>

More information about the petsc-users mailing list