[petsc-users] Getting a matrix into PETSc

Umut Tabak u.tabak at tudelft.nl
Mon Sep 27 18:10:25 CDT 2010


Alexis Morris wrote:
> Hi everyone,
>
>    I am new to PETSc, and am really excited about using it in 
> combination with SLEPc to find the eigenvalues of a large hermitian 
> sparse matrix.  I have read through the user manual, and one thing is 
> really confusing me: how do I get my matrix into PETSc?
>
> My code is organized into separate modules (I am using Fortran).  One 
> of the modules calculates my matrix H and stores it in a compressed 
> sparse row format.  I would like to then call from my main program an 
> eigenvalue subroutine and pass the matrix H to it.   In this 
> eigenvalue subroutine, I would use PETSc/SLEPc.  How do I get it to 
> use my pre-calculated matrix?
Assuming the matrices are sparse(otherwise using SLEPc does not mean 
anything.), you should write some routines to form the matrices in Petsc 
format. For this operation, you should start playing with MatSetValues. 
I guess this should give you a starting point.
HTH,
Umut


More information about the petsc-users mailing list